DroppedFile.h 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. /**
  2. * Copyright (c) 2006-2016 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. static love::Type type;
  39. DroppedFile(const std::string &filename);
  40. virtual ~DroppedFile();
  41. // Implements File.
  42. using File::read;
  43. using File::write;
  44. bool open(Mode mode) override;
  45. bool close() override;
  46. bool isOpen() const override;
  47. int64 getSize() override;
  48. int64 read(void *dst, int64 size) override;
  49. bool write(const void *data, int64 size) override;
  50. bool flush() override;
  51. bool isEOF() override;
  52. int64 tell() override;
  53. bool seek(uint64 pos) override;
  54. bool setBuffer(BufferMode bufmode, int64 size) override;
  55. BufferMode getBuffer(int64 &size) const override;
  56. Mode getMode() const override;
  57. const std::string &getFilename() const override;
  58. private:
  59. static const char *getModeString(Mode mode);
  60. std::string filename;
  61. FILE *file;
  62. Mode mode;
  63. BufferMode bufferMode;
  64. int64 bufferSize;
  65. }; // DroppedFile
  66. } // filesystem
  67. } // love
  68. #endif // LOVE_FILESYSTEM_DROPPED_FILE_H