1 /** 2 * Copyright (c) 2006-2019 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 21 #ifndef LOVE_FILESYSTEM_PHYSFS_FILESYSTEM_H 22 #define LOVE_FILESYSTEM_PHYSFS_FILESYSTEM_H 23 24 // STD 25 #include <cstdlib> 26 #include <cstring> 27 #include <map> 28 29 // LOVE 30 #include "filesystem/Filesystem.h" 31 32 namespace love 33 { 34 namespace filesystem 35 { 36 namespace physfs 37 { 38 39 class Filesystem final : public love::filesystem::Filesystem 40 { 41 public: 42 43 Filesystem(); 44 virtual ~Filesystem(); 45 46 // Implements Module. 47 const char *getName() const override; 48 49 void init(const char *arg0) override; 50 51 void setFused(bool fused) override; 52 bool isFused() const override; 53 54 bool setupWriteDirectory() override; 55 56 bool setIdentity(const char *ident, bool appendToPath = false) override; 57 const char *getIdentity() const override; 58 59 bool setSource(const char *source) override; 60 61 const char *getSource() const override; 62 63 bool mount(const char *archive, const char *mountpoint, bool appendToPath = false) override; 64 bool mount(Data *data, const char *archivename, const char *mountpoint, bool appendToPath = false) override; 65 66 bool unmount(const char *archive) override; 67 bool unmount(Data *data) override; 68 69 love::filesystem::File *newFile(const char *filename) const override; 70 71 const char *getWorkingDirectory() override; 72 std::string getUserDirectory() override; 73 std::string getAppdataDirectory() override; 74 const char *getSaveDirectory() override; 75 std::string getSourceBaseDirectory() const override; 76 77 std::string getRealDirectory(const char *filename) const override; 78 79 bool getInfo(const char *filepath, Info &info) const override; 80 81 bool createDirectory(const char *dir) override; 82 83 bool remove(const char *file) override; 84 85 FileData *read(const char *filename, int64 size = File::ALL) const override; 86 void write(const char *filename, const void *data, int64 size) const override; 87 void append(const char *filename, const void *data, int64 size) const override; 88 89 void getDirectoryItems(const char *dir, std::vector<std::string> &items) override; 90 91 void setSymlinksEnabled(bool enable) override; 92 bool areSymlinksEnabled() const override; 93 94 std::vector<std::string> &getRequirePath() override; 95 std::vector<std::string> &getCRequirePath() override; 96 97 void allowMountingForPath(const std::string &path) override; 98 99 private: 100 101 // Contains the current working directory (UTF8). 102 std::string cwd; 103 104 // %APPDATA% on Windows. 105 std::string appdata; 106 107 // This name will be used to create the folder 108 // in the appdata/userdata folder. 109 std::string save_identity; 110 111 // Full and relative paths of the game save folder. 112 // (Relative to the %APPDATA% folder, meaning that the 113 // relative string will look something like: ./LOVE/game) 114 std::string save_path_relative, save_path_full; 115 116 // The full path to the source of the game. 117 std::string game_source; 118 119 // Allow saving outside of the LOVE_APPDATA_FOLDER 120 // for release 'builds' 121 bool fused; 122 bool fusedSet; 123 124 // Search path for require 125 std::vector<std::string> requirePath; 126 std::vector<std::string> cRequirePath; 127 128 std::vector<std::string> allowedMountPaths; 129 130 std::map<std::string, StrongRef<Data>> mountedData; 131 132 }; // Filesystem 133 134 } // physfs 135 } // filesystem 136 } // love 137 138 #endif // LOVE_FILESYSTEM_PHYSFS_FILESYSTEM_H 139