Filesystem.h 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141
  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_PHYSFS_FILESYSTEM_H
  21. #define LOVE_FILESYSTEM_PHYSFS_FILESYSTEM_H
  22. // STD
  23. #include <cstdlib>
  24. #include <cstring>
  25. // LOVE
  26. #include "filesystem/Filesystem.h"
  27. namespace love
  28. {
  29. namespace filesystem
  30. {
  31. namespace physfs
  32. {
  33. class Filesystem : public love::filesystem::Filesystem
  34. {
  35. public:
  36. Filesystem();
  37. virtual ~Filesystem();
  38. // Implements Module.
  39. const char *getName() const;
  40. void init(const char *arg0);
  41. void setFused(bool fused);
  42. bool isFused() const;
  43. bool setupWriteDirectory();
  44. bool setIdentity(const char *ident, bool appendToPath = false);
  45. const char *getIdentity() const;
  46. bool setSource(const char *source);
  47. const char *getSource() const;
  48. bool mount(const char *archive, const char *mountpoint, bool appendToPath = false);
  49. bool unmount(const char *archive);
  50. File *newFile(const char *filename) const;
  51. FileData *newFileData(void *data, unsigned int size, const char *filename) const;
  52. FileData *newFileData(const char *b64, const char *filename) const;
  53. const char *getWorkingDirectory();
  54. std::string getUserDirectory();
  55. std::string getAppdataDirectory();
  56. const char *getSaveDirectory();
  57. std::string getSourceBaseDirectory() const;
  58. std::string getRealDirectory(const char *filename) const;
  59. bool exists(const char *path) const;
  60. bool isDirectory(const char *dir) const;
  61. bool isFile(const char *file) const;
  62. bool isSymlink(const char *filename) const;
  63. bool createDirectory(const char *dir);
  64. bool remove(const char *file);
  65. FileData *read(const char *filename, int64 size = File::ALL) const;
  66. void write(const char *filename, const void *data, int64 size) const;
  67. void append(const char *filename, const void *data, int64 size) const;
  68. void getDirectoryItems(const char *dir, std::vector<std::string> &items);
  69. int64 getLastModified(const char *filename) const;
  70. int64 getSize(const char *filename) const;
  71. void setSymlinksEnabled(bool enable);
  72. bool areSymlinksEnabled() const;
  73. std::vector<std::string> &getRequirePath();
  74. std::vector<std::string> &getCRequirePath();
  75. void allowMountingForPath(const std::string &path);
  76. private:
  77. // Contains the current working directory (UTF8).
  78. std::string cwd;
  79. // %APPDATA% on Windows.
  80. std::string appdata;
  81. // This name will be used to create the folder
  82. // in the appdata/userdata folder.
  83. std::string save_identity;
  84. // Full and relative paths of the game save folder.
  85. // (Relative to the %APPDATA% folder, meaning that the
  86. // relative string will look something like: ./LOVE/game)
  87. std::string save_path_relative, save_path_full;
  88. // The full path to the source of the game.
  89. std::string game_source;
  90. // Allow saving outside of the LOVE_APPDATA_FOLDER
  91. // for release 'builds'
  92. bool fused;
  93. bool fusedSet;
  94. // Search path for require
  95. std::vector<std::string> requirePath;
  96. std::vector<std::string> cRequirePath;
  97. std::vector<std::string> allowedMountPaths;
  98. }; // Filesystem
  99. } // physfs
  100. } // filesystem
  101. } // love
  102. #endif // LOVE_FILESYSTEM_PHYSFS_FILESYSTEM_H