FileData.h 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. /**
  2. * Copyright (c) 2006-2017 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_FILE_DATA_H
  21. #define LOVE_FILESYSTEM_FILE_DATA_H
  22. // LOVE
  23. #include "common/Data.h"
  24. #include "common/int.h"
  25. #include "common/Exception.h"
  26. #include <string>
  27. namespace love
  28. {
  29. namespace filesystem
  30. {
  31. class FileData : public Data
  32. {
  33. public:
  34. static love::Type type;
  35. FileData(uint64 size, const std::string &filename);
  36. FileData(const FileData &c);
  37. virtual ~FileData();
  38. // Implements Data.
  39. Data *clone() const;
  40. void *getData() const;
  41. size_t getSize() const;
  42. const std::string &getFilename() const;
  43. const std::string &getExtension() const;
  44. const std::string &getName() const;
  45. private:
  46. // The actual data.
  47. char *data;
  48. // Size of the data.
  49. uint64 size;
  50. // The filename used for error purposes.
  51. std::string filename;
  52. // The extension (without dot). Used to identify file type.
  53. std::string extension;
  54. // The file name without the extension (and without the dot).
  55. std::string name;
  56. }; // FileData
  57. } // filesystem
  58. } // love
  59. #endif // LOVE_FILESYSTEM_FILE_DATA_H