DroppedFile.h 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. /**
  2. * Copyright (c) 2006-2015 LOVE Development Team
  3. *
  4. * This software is provided 'as-is', without any express or implied
  5. * warranty. In no event will the authors be held liable for any damages
  6. * arising from the use of this software.
  7. *
  8. * Permission is granted to anyone to use this software for any purpose,
  9. * including commercial applications, and to alter it and redistribute it
  10. * freely, subject to the following restrictions:
  11. *
  12. * 1. The origin of this software must not be misrepresented; you must not
  13. * claim that you wrote the original software. If you use this software
  14. * in a product, an acknowledgment in the product documentation would be
  15. * appreciated but is not required.
  16. * 2. Altered source versions must be plainly marked as such, and must not be
  17. * misrepresented as being the original software.
  18. * 3. This notice may not be removed or altered from any source distribution.
  19. **/
  20. #ifndef LOVE_FILESYSTEM_DROPPED_FILE_H
  21. #define LOVE_FILESYSTEM_DROPPED_FILE_H
  22. // LOVE
  23. #include "common/config.h"
  24. #include "File.h"
  25. // C
  26. #include <cstdio>
  27. namespace love
  28. {
  29. namespace filesystem
  30. {
  31. /**
  32. * File which is created when a user drags and drops an actual file onto the
  33. * LOVE game. Uses C's stdio. Filenames are system-dependent full paths.
  34. **/
  35. class DroppedFile : public File
  36. {
  37. public:
  38. DroppedFile(const std::string &filename);
  39. virtual ~DroppedFile();
  40. // Implements File.
  41. using File::read;
  42. using File::write;
  43. bool open(Mode mode) override;
  44. bool close() override;
  45. bool isOpen() const override;
  46. int64 getSize() override;
  47. int64 read(void *dst, int64 size) override;
  48. bool write(const void *data, int64 size) override;
  49. bool flush() override;
  50. bool isEOF() override;
  51. int64 tell() override;
  52. bool seek(uint64 pos) override;
  53. bool setBuffer(BufferMode bufmode, int64 size) override;
  54. BufferMode getBuffer(int64 &size) const override;
  55. Mode getMode() const override;
  56. const std::string &getFilename() const override;
  57. private:
  58. static const char *getModeString(Mode mode);
  59. std::string filename;
  60. FILE *file;
  61. Mode mode;
  62. BufferMode bufferMode;
  63. int64 bufferSize;
  64. }; // DroppedFile
  65. } // filesystem
  66. } // love
  67. #endif // LOVE_FILESYSTEM_DROPPED_FILE_H