diff options
| author | 2014-11-11 19:27:35 -0500 | |
|---|---|---|
| committer | 2014-11-17 21:49:24 -0500 | |
| commit | a3107a6b571dedb8828b20ddcb709ec17db9715a (patch) | |
| tree | 367848a8e6e445e062f10378d45aa6a4abfcb63b /src/core/file_sys | |
| parent | FileSys: Added DebugStr method to Path class. (diff) | |
| download | yuzu-a3107a6b571dedb8828b20ddcb709ec17db9715a.tar.gz yuzu-a3107a6b571dedb8828b20ddcb709ec17db9715a.tar.xz yuzu-a3107a6b571dedb8828b20ddcb709ec17db9715a.zip | |
FileSys: Updated backend code to use FileSys::Path instead of string for paths.
Diffstat (limited to 'src/core/file_sys')
| -rw-r--r-- | src/core/file_sys/archive.h | 6 | ||||
| -rw-r--r-- | src/core/file_sys/archive_romfs.cpp | 6 | ||||
| -rw-r--r-- | src/core/file_sys/archive_romfs.h | 6 | ||||
| -rw-r--r-- | src/core/file_sys/archive_sdmc.cpp | 12 | ||||
| -rw-r--r-- | src/core/file_sys/archive_sdmc.h | 6 | ||||
| -rw-r--r-- | src/core/file_sys/directory_sdmc.cpp | 4 | ||||
| -rw-r--r-- | src/core/file_sys/directory_sdmc.h | 2 | ||||
| -rw-r--r-- | src/core/file_sys/file_sdmc.cpp | 4 | ||||
| -rw-r--r-- | src/core/file_sys/file_sdmc.h | 2 |
9 files changed, 24 insertions, 24 deletions
diff --git a/src/core/file_sys/archive.h b/src/core/file_sys/archive.h index 7b3130f16..dc2d2ced9 100644 --- a/src/core/file_sys/archive.h +++ b/src/core/file_sys/archive.h | |||
| @@ -182,21 +182,21 @@ public: | |||
| 182 | * @param mode Mode to open the file with | 182 | * @param mode Mode to open the file with |
| 183 | * @return Opened file, or nullptr | 183 | * @return Opened file, or nullptr |
| 184 | */ | 184 | */ |
| 185 | virtual std::unique_ptr<File> OpenFile(const std::string& path, const Mode mode) const = 0; | 185 | virtual std::unique_ptr<File> OpenFile(const Path& path, const Mode mode) const = 0; |
| 186 | 186 | ||
| 187 | /** | 187 | /** |
| 188 | * Create a directory specified by its path | 188 | * Create a directory specified by its path |
| 189 | * @param path Path relative to the archive | 189 | * @param path Path relative to the archive |
| 190 | * @return Whether the directory could be created | 190 | * @return Whether the directory could be created |
| 191 | */ | 191 | */ |
| 192 | virtual bool CreateDirectory(const std::string& path) const = 0; | 192 | virtual bool CreateDirectory(const Path& path) const = 0; |
| 193 | 193 | ||
| 194 | /** | 194 | /** |
| 195 | * Open a directory specified by its path | 195 | * Open a directory specified by its path |
| 196 | * @param path Path relative to the archive | 196 | * @param path Path relative to the archive |
| 197 | * @return Opened directory, or nullptr | 197 | * @return Opened directory, or nullptr |
| 198 | */ | 198 | */ |
| 199 | virtual std::unique_ptr<Directory> OpenDirectory(const std::string& path) const = 0; | 199 | virtual std::unique_ptr<Directory> OpenDirectory(const Path& path) const = 0; |
| 200 | 200 | ||
| 201 | /** | 201 | /** |
| 202 | * Read data from the archive | 202 | * Read data from the archive |
diff --git a/src/core/file_sys/archive_romfs.cpp b/src/core/file_sys/archive_romfs.cpp index cc759faa8..3ea60134f 100644 --- a/src/core/file_sys/archive_romfs.cpp +++ b/src/core/file_sys/archive_romfs.cpp | |||
| @@ -29,7 +29,7 @@ Archive_RomFS::~Archive_RomFS() { | |||
| 29 | * @param mode Mode to open the file with | 29 | * @param mode Mode to open the file with |
| 30 | * @return Opened file, or nullptr | 30 | * @return Opened file, or nullptr |
| 31 | */ | 31 | */ |
| 32 | std::unique_ptr<File> Archive_RomFS::OpenFile(const std::string& path, const Mode mode) const { | 32 | std::unique_ptr<File> Archive_RomFS::OpenFile(const Path& path, const Mode mode) const { |
| 33 | return std::unique_ptr<File>(new File_RomFS); | 33 | return std::unique_ptr<File>(new File_RomFS); |
| 34 | } | 34 | } |
| 35 | 35 | ||
| @@ -38,7 +38,7 @@ std::unique_ptr<File> Archive_RomFS::OpenFile(const std::string& path, const Mod | |||
| 38 | * @param path Path relative to the archive | 38 | * @param path Path relative to the archive |
| 39 | * @return Whether the directory could be created | 39 | * @return Whether the directory could be created |
| 40 | */ | 40 | */ |
| 41 | bool Archive_RomFS::CreateDirectory(const std::string& path) const { | 41 | bool Archive_RomFS::CreateDirectory(const Path& path) const { |
| 42 | ERROR_LOG(FILESYS, "Attempted to create a directory in ROMFS."); | 42 | ERROR_LOG(FILESYS, "Attempted to create a directory in ROMFS."); |
| 43 | return false; | 43 | return false; |
| 44 | }; | 44 | }; |
| @@ -48,7 +48,7 @@ bool Archive_RomFS::CreateDirectory(const std::string& path) const { | |||
| 48 | * @param path Path relative to the archive | 48 | * @param path Path relative to the archive |
| 49 | * @return Opened directory, or nullptr | 49 | * @return Opened directory, or nullptr |
| 50 | */ | 50 | */ |
| 51 | std::unique_ptr<Directory> Archive_RomFS::OpenDirectory(const std::string& path) const { | 51 | std::unique_ptr<Directory> Archive_RomFS::OpenDirectory(const Path& path) const { |
| 52 | return std::unique_ptr<Directory>(new Directory_RomFS); | 52 | return std::unique_ptr<Directory>(new Directory_RomFS); |
| 53 | } | 53 | } |
| 54 | 54 | ||
diff --git a/src/core/file_sys/archive_romfs.h b/src/core/file_sys/archive_romfs.h index ae2344e82..8d5715734 100644 --- a/src/core/file_sys/archive_romfs.h +++ b/src/core/file_sys/archive_romfs.h | |||
| @@ -34,21 +34,21 @@ public: | |||
| 34 | * @param mode Mode to open the file with | 34 | * @param mode Mode to open the file with |
| 35 | * @return Opened file, or nullptr | 35 | * @return Opened file, or nullptr |
| 36 | */ | 36 | */ |
| 37 | std::unique_ptr<File> OpenFile(const std::string& path, const Mode mode) const override; | 37 | std::unique_ptr<File> OpenFile(const Path& path, const Mode mode) const override; |
| 38 | 38 | ||
| 39 | /** | 39 | /** |
| 40 | * Create a directory specified by its path | 40 | * Create a directory specified by its path |
| 41 | * @param path Path relative to the archive | 41 | * @param path Path relative to the archive |
| 42 | * @return Whether the directory could be created | 42 | * @return Whether the directory could be created |
| 43 | */ | 43 | */ |
| 44 | bool CreateDirectory(const std::string& path) const override; | 44 | bool CreateDirectory(const Path& path) const override; |
| 45 | 45 | ||
| 46 | /** | 46 | /** |
| 47 | * Open a directory specified by its path | 47 | * Open a directory specified by its path |
| 48 | * @param path Path relative to the archive | 48 | * @param path Path relative to the archive |
| 49 | * @return Opened directory, or nullptr | 49 | * @return Opened directory, or nullptr |
| 50 | */ | 50 | */ |
| 51 | std::unique_ptr<Directory> OpenDirectory(const std::string& path) const override; | 51 | std::unique_ptr<Directory> OpenDirectory(const Path& path) const override; |
| 52 | 52 | ||
| 53 | /** | 53 | /** |
| 54 | * Read data from the archive | 54 | * Read data from the archive |
diff --git a/src/core/file_sys/archive_sdmc.cpp b/src/core/file_sys/archive_sdmc.cpp index 66931e93e..ecdb7f211 100644 --- a/src/core/file_sys/archive_sdmc.cpp +++ b/src/core/file_sys/archive_sdmc.cpp | |||
| @@ -49,8 +49,8 @@ bool Archive_SDMC::Initialize() { | |||
| 49 | * @param mode Mode to open the file with | 49 | * @param mode Mode to open the file with |
| 50 | * @return Opened file, or nullptr | 50 | * @return Opened file, or nullptr |
| 51 | */ | 51 | */ |
| 52 | std::unique_ptr<File> Archive_SDMC::OpenFile(const std::string& path, const Mode mode) const { | 52 | std::unique_ptr<File> Archive_SDMC::OpenFile(const Path& path, const Mode mode) const { |
| 53 | DEBUG_LOG(FILESYS, "called path=%s mode=%d", path.c_str(), mode); | 53 | DEBUG_LOG(FILESYS, "called path=%s mode=%d", path.DebugStr().c_str(), mode); |
| 54 | File_SDMC* file = new File_SDMC(this, path, mode); | 54 | File_SDMC* file = new File_SDMC(this, path, mode); |
| 55 | if (!file->Open()) | 55 | if (!file->Open()) |
| 56 | return nullptr; | 56 | return nullptr; |
| @@ -62,8 +62,8 @@ std::unique_ptr<File> Archive_SDMC::OpenFile(const std::string& path, const Mode | |||
| 62 | * @param path Path relative to the archive | 62 | * @param path Path relative to the archive |
| 63 | * @return Whether the directory could be created | 63 | * @return Whether the directory could be created |
| 64 | */ | 64 | */ |
| 65 | bool Archive_SDMC::CreateDirectory(const std::string& path) const { | 65 | bool Archive_SDMC::CreateDirectory(const Path& path) const { |
| 66 | return FileUtil::CreateDir(GetMountPoint() + path); | 66 | return FileUtil::CreateDir(GetMountPoint() + path.AsString()); |
| 67 | } | 67 | } |
| 68 | 68 | ||
| 69 | /** | 69 | /** |
| @@ -71,8 +71,8 @@ bool Archive_SDMC::CreateDirectory(const std::string& path) const { | |||
| 71 | * @param path Path relative to the archive | 71 | * @param path Path relative to the archive |
| 72 | * @return Opened directory, or nullptr | 72 | * @return Opened directory, or nullptr |
| 73 | */ | 73 | */ |
| 74 | std::unique_ptr<Directory> Archive_SDMC::OpenDirectory(const std::string& path) const { | 74 | std::unique_ptr<Directory> Archive_SDMC::OpenDirectory(const Path& path) const { |
| 75 | DEBUG_LOG(FILESYS, "called path=%s", path.c_str()); | 75 | DEBUG_LOG(FILESYS, "called path=%s", path.DebugStr().c_str()); |
| 76 | Directory_SDMC* directory = new Directory_SDMC(this, path); | 76 | Directory_SDMC* directory = new Directory_SDMC(this, path); |
| 77 | return std::unique_ptr<Directory>(directory); | 77 | return std::unique_ptr<Directory>(directory); |
| 78 | } | 78 | } |
diff --git a/src/core/file_sys/archive_sdmc.h b/src/core/file_sys/archive_sdmc.h index 0e059b635..1f621b3f7 100644 --- a/src/core/file_sys/archive_sdmc.h +++ b/src/core/file_sys/archive_sdmc.h | |||
| @@ -38,21 +38,21 @@ public: | |||
| 38 | * @param mode Mode to open the file with | 38 | * @param mode Mode to open the file with |
| 39 | * @return Opened file, or nullptr | 39 | * @return Opened file, or nullptr |
| 40 | */ | 40 | */ |
| 41 | std::unique_ptr<File> OpenFile(const std::string& path, const Mode mode) const override; | 41 | std::unique_ptr<File> OpenFile(const Path& path, const Mode mode) const override; |
| 42 | 42 | ||
| 43 | /** | 43 | /** |
| 44 | * Create a directory specified by its path | 44 | * Create a directory specified by its path |
| 45 | * @param path Path relative to the archive | 45 | * @param path Path relative to the archive |
| 46 | * @return Whether the directory could be created | 46 | * @return Whether the directory could be created |
| 47 | */ | 47 | */ |
| 48 | bool CreateDirectory(const std::string& path) const override; | 48 | bool CreateDirectory(const Path& path) const override; |
| 49 | 49 | ||
| 50 | /** | 50 | /** |
| 51 | * Open a directory specified by its path | 51 | * Open a directory specified by its path |
| 52 | * @param path Path relative to the archive | 52 | * @param path Path relative to the archive |
| 53 | * @return Opened directory, or nullptr | 53 | * @return Opened directory, or nullptr |
| 54 | */ | 54 | */ |
| 55 | std::unique_ptr<Directory> OpenDirectory(const std::string& path) const override; | 55 | std::unique_ptr<Directory> OpenDirectory(const Path& path) const override; |
| 56 | 56 | ||
| 57 | /** | 57 | /** |
| 58 | * Read data from the archive | 58 | * Read data from the archive |
diff --git a/src/core/file_sys/directory_sdmc.cpp b/src/core/file_sys/directory_sdmc.cpp index fd558def9..923ca6862 100644 --- a/src/core/file_sys/directory_sdmc.cpp +++ b/src/core/file_sys/directory_sdmc.cpp | |||
| @@ -15,11 +15,11 @@ | |||
| 15 | 15 | ||
| 16 | namespace FileSys { | 16 | namespace FileSys { |
| 17 | 17 | ||
| 18 | Directory_SDMC::Directory_SDMC(const Archive_SDMC* archive, const std::string& path) { | 18 | Directory_SDMC::Directory_SDMC(const Archive_SDMC* archive, const Path& path) { |
| 19 | // TODO(Link Mauve): normalize path into an absolute path without "..", it can currently bypass | 19 | // TODO(Link Mauve): normalize path into an absolute path without "..", it can currently bypass |
| 20 | // the root directory we set while opening the archive. | 20 | // the root directory we set while opening the archive. |
| 21 | // For example, opening /../../usr/bin can give the emulated program your installed programs. | 21 | // For example, opening /../../usr/bin can give the emulated program your installed programs. |
| 22 | std::string absolute_path = archive->GetMountPoint() + path; | 22 | std::string absolute_path = archive->GetMountPoint() + path.AsString(); |
| 23 | FileUtil::ScanDirectoryTree(absolute_path, directory); | 23 | FileUtil::ScanDirectoryTree(absolute_path, directory); |
| 24 | children_iterator = directory.children.begin(); | 24 | children_iterator = directory.children.begin(); |
| 25 | } | 25 | } |
diff --git a/src/core/file_sys/directory_sdmc.h b/src/core/file_sys/directory_sdmc.h index cb8d32fda..4520d0401 100644 --- a/src/core/file_sys/directory_sdmc.h +++ b/src/core/file_sys/directory_sdmc.h | |||
| @@ -19,7 +19,7 @@ namespace FileSys { | |||
| 19 | class Directory_SDMC final : public Directory { | 19 | class Directory_SDMC final : public Directory { |
| 20 | public: | 20 | public: |
| 21 | Directory_SDMC(); | 21 | Directory_SDMC(); |
| 22 | Directory_SDMC(const Archive_SDMC* archive, const std::string& path); | 22 | Directory_SDMC(const Archive_SDMC* archive, const Path& path); |
| 23 | ~Directory_SDMC() override; | 23 | ~Directory_SDMC() override; |
| 24 | 24 | ||
| 25 | /** | 25 | /** |
diff --git a/src/core/file_sys/file_sdmc.cpp b/src/core/file_sys/file_sdmc.cpp index 26204392c..a4b90670a 100644 --- a/src/core/file_sys/file_sdmc.cpp +++ b/src/core/file_sys/file_sdmc.cpp | |||
| @@ -15,11 +15,11 @@ | |||
| 15 | 15 | ||
| 16 | namespace FileSys { | 16 | namespace FileSys { |
| 17 | 17 | ||
| 18 | File_SDMC::File_SDMC(const Archive_SDMC* archive, const std::string& path, const Mode mode) { | 18 | File_SDMC::File_SDMC(const Archive_SDMC* archive, const Path& path, const Mode mode) { |
| 19 | // TODO(Link Mauve): normalize path into an absolute path without "..", it can currently bypass | 19 | // TODO(Link Mauve): normalize path into an absolute path without "..", it can currently bypass |
| 20 | // the root directory we set while opening the archive. | 20 | // the root directory we set while opening the archive. |
| 21 | // For example, opening /../../etc/passwd can give the emulated program your users list. | 21 | // For example, opening /../../etc/passwd can give the emulated program your users list. |
| 22 | this->path = archive->GetMountPoint() + path; | 22 | this->path = archive->GetMountPoint() + path.AsString(); |
| 23 | this->mode.hex = mode.hex; | 23 | this->mode.hex = mode.hex; |
| 24 | } | 24 | } |
| 25 | 25 | ||
diff --git a/src/core/file_sys/file_sdmc.h b/src/core/file_sys/file_sdmc.h index df032f7c0..80b445968 100644 --- a/src/core/file_sys/file_sdmc.h +++ b/src/core/file_sys/file_sdmc.h | |||
| @@ -19,7 +19,7 @@ namespace FileSys { | |||
| 19 | class File_SDMC final : public File { | 19 | class File_SDMC final : public File { |
| 20 | public: | 20 | public: |
| 21 | File_SDMC(); | 21 | File_SDMC(); |
| 22 | File_SDMC(const Archive_SDMC* archive, const std::string& path, const Mode mode); | 22 | File_SDMC(const Archive_SDMC* archive, const Path& path, const Mode mode); |
| 23 | ~File_SDMC() override; | 23 | ~File_SDMC() override; |
| 24 | 24 | ||
| 25 | /** | 25 | /** |