diff options
| author | 2014-12-04 22:07:47 -0500 | |
|---|---|---|
| committer | 2014-12-04 22:07:47 -0500 | |
| commit | 5056329a8003115f61859b97c2fc6ef2f460a0d3 (patch) | |
| tree | 9434ac214d06a5d55ff20848f57cb981647991dc /src/core/file_sys | |
| parent | Merge pull request #248 from lioncash/kernel (diff) | |
| parent | Updated archive.cpp functions for proper error handling (diff) | |
| download | yuzu-5056329a8003115f61859b97c2fc6ef2f460a0d3.tar.gz yuzu-5056329a8003115f61859b97c2fc6ef2f460a0d3.tar.xz yuzu-5056329a8003115f61859b97c2fc6ef2f460a0d3.zip | |
Merge pull request #222 from archshift/renamexyz
Implemented RenameFile and RenameDirectory in FS:USER
Diffstat (limited to 'src/core/file_sys')
| -rw-r--r-- | src/core/file_sys/archive.h | 16 | ||||
| -rw-r--r-- | src/core/file_sys/archive_romfs.cpp | 10 | ||||
| -rw-r--r-- | src/core/file_sys/archive_romfs.h | 16 | ||||
| -rw-r--r-- | src/core/file_sys/archive_sdmc.cpp | 8 | ||||
| -rw-r--r-- | src/core/file_sys/archive_sdmc.h | 16 |
5 files changed, 66 insertions, 0 deletions
diff --git a/src/core/file_sys/archive.h b/src/core/file_sys/archive.h index c2426a153..f3cb11133 100644 --- a/src/core/file_sys/archive.h +++ b/src/core/file_sys/archive.h | |||
| @@ -194,6 +194,14 @@ public: | |||
| 194 | virtual bool DeleteFile(const FileSys::Path& path) const = 0; | 194 | virtual bool DeleteFile(const FileSys::Path& path) const = 0; |
| 195 | 195 | ||
| 196 | /** | 196 | /** |
| 197 | * Rename a File specified by its path | ||
| 198 | * @param src_path Source path relative to the archive | ||
| 199 | * @param dest_path Destination path relative to the archive | ||
| 200 | * @return Whether rename succeeded | ||
| 201 | */ | ||
| 202 | virtual bool RenameFile(const FileSys::Path& src_path, const FileSys::Path& dest_path) const = 0; | ||
| 203 | |||
| 204 | /** | ||
| 197 | * Delete a directory specified by its path | 205 | * Delete a directory specified by its path |
| 198 | * @param path Path relative to the archive | 206 | * @param path Path relative to the archive |
| 199 | * @return Whether the directory could be deleted | 207 | * @return Whether the directory could be deleted |
| @@ -208,6 +216,14 @@ public: | |||
| 208 | virtual bool CreateDirectory(const Path& path) const = 0; | 216 | virtual bool CreateDirectory(const Path& path) const = 0; |
| 209 | 217 | ||
| 210 | /** | 218 | /** |
| 219 | * Rename a Directory specified by its path | ||
| 220 | * @param src_path Source path relative to the archive | ||
| 221 | * @param dest_path Destination path relative to the archive | ||
| 222 | * @return Whether rename succeeded | ||
| 223 | */ | ||
| 224 | virtual bool RenameDirectory(const FileSys::Path& src_path, const FileSys::Path& dest_path) const = 0; | ||
| 225 | |||
| 226 | /** | ||
| 211 | * Open a directory specified by its path | 227 | * Open a directory specified by its path |
| 212 | * @param path Path relative to the archive | 228 | * @param path Path relative to the archive |
| 213 | * @return Opened directory, or nullptr | 229 | * @return Opened directory, or nullptr |
diff --git a/src/core/file_sys/archive_romfs.cpp b/src/core/file_sys/archive_romfs.cpp index 53dc57954..8c2dbeda5 100644 --- a/src/core/file_sys/archive_romfs.cpp +++ b/src/core/file_sys/archive_romfs.cpp | |||
| @@ -43,6 +43,11 @@ bool Archive_RomFS::DeleteFile(const FileSys::Path& path) const { | |||
| 43 | return false; | 43 | return false; |
| 44 | } | 44 | } |
| 45 | 45 | ||
| 46 | bool Archive_RomFS::RenameFile(const FileSys::Path& src_path, const FileSys::Path& dest_path) const { | ||
| 47 | ERROR_LOG(FILESYS, "Attempted to rename a file within ROMFS."); | ||
| 48 | return false; | ||
| 49 | } | ||
| 50 | |||
| 46 | /** | 51 | /** |
| 47 | * Delete a directory specified by its path | 52 | * Delete a directory specified by its path |
| 48 | * @param path Path relative to the archive | 53 | * @param path Path relative to the archive |
| @@ -63,6 +68,11 @@ bool Archive_RomFS::CreateDirectory(const Path& path) const { | |||
| 63 | return false; | 68 | return false; |
| 64 | } | 69 | } |
| 65 | 70 | ||
| 71 | bool Archive_RomFS::RenameDirectory(const FileSys::Path& src_path, const FileSys::Path& dest_path) const { | ||
| 72 | ERROR_LOG(FILESYS, "Attempted to rename a file within ROMFS."); | ||
| 73 | return false; | ||
| 74 | } | ||
| 75 | |||
| 66 | /** | 76 | /** |
| 67 | * Open a directory specified by its path | 77 | * Open a directory specified by its path |
| 68 | * @param path Path relative to the archive | 78 | * @param path Path relative to the archive |
diff --git a/src/core/file_sys/archive_romfs.h b/src/core/file_sys/archive_romfs.h index 0649dde99..222bdc356 100644 --- a/src/core/file_sys/archive_romfs.h +++ b/src/core/file_sys/archive_romfs.h | |||
| @@ -44,6 +44,14 @@ public: | |||
| 44 | bool DeleteFile(const FileSys::Path& path) const override; | 44 | bool DeleteFile(const FileSys::Path& path) const override; |
| 45 | 45 | ||
| 46 | /** | 46 | /** |
| 47 | * Rename a File specified by its path | ||
| 48 | * @param src_path Source path relative to the archive | ||
| 49 | * @param dest_path Destination path relative to the archive | ||
| 50 | * @return Whether rename succeeded | ||
| 51 | */ | ||
| 52 | bool RenameFile(const FileSys::Path& src_path, const FileSys::Path& dest_path) const override; | ||
| 53 | |||
| 54 | /** | ||
| 47 | * Delete a directory specified by its path | 55 | * Delete a directory specified by its path |
| 48 | * @param path Path relative to the archive | 56 | * @param path Path relative to the archive |
| 49 | * @return Whether the directory could be deleted | 57 | * @return Whether the directory could be deleted |
| @@ -58,6 +66,14 @@ public: | |||
| 58 | bool CreateDirectory(const Path& path) const override; | 66 | bool CreateDirectory(const Path& path) const override; |
| 59 | 67 | ||
| 60 | /** | 68 | /** |
| 69 | * Rename a Directory specified by its path | ||
| 70 | * @param src_path Source path relative to the archive | ||
| 71 | * @param dest_path Destination path relative to the archive | ||
| 72 | * @return Whether rename succeeded | ||
| 73 | */ | ||
| 74 | bool RenameDirectory(const FileSys::Path& src_path, const FileSys::Path& dest_path) const override; | ||
| 75 | |||
| 76 | /** | ||
| 61 | * Open a directory specified by its path | 77 | * Open a directory specified by its path |
| 62 | * @param path Path relative to the archive | 78 | * @param path Path relative to the archive |
| 63 | * @return Opened directory, or nullptr | 79 | * @return Opened directory, or nullptr |
diff --git a/src/core/file_sys/archive_sdmc.cpp b/src/core/file_sys/archive_sdmc.cpp index 789212b17..169ab0f1c 100644 --- a/src/core/file_sys/archive_sdmc.cpp +++ b/src/core/file_sys/archive_sdmc.cpp | |||
| @@ -66,6 +66,10 @@ bool Archive_SDMC::DeleteFile(const FileSys::Path& path) const { | |||
| 66 | return FileUtil::Delete(GetMountPoint() + path.AsString()); | 66 | return FileUtil::Delete(GetMountPoint() + path.AsString()); |
| 67 | } | 67 | } |
| 68 | 68 | ||
| 69 | bool Archive_SDMC::RenameFile(const FileSys::Path& src_path, const FileSys::Path& dest_path) const { | ||
| 70 | return FileUtil::Rename(GetMountPoint() + src_path.AsString(), GetMountPoint() + dest_path.AsString()); | ||
| 71 | } | ||
| 72 | |||
| 69 | /** | 73 | /** |
| 70 | * Delete a directory specified by its path | 74 | * Delete a directory specified by its path |
| 71 | * @param path Path relative to the archive | 75 | * @param path Path relative to the archive |
| @@ -84,6 +88,10 @@ bool Archive_SDMC::CreateDirectory(const Path& path) const { | |||
| 84 | return FileUtil::CreateDir(GetMountPoint() + path.AsString()); | 88 | return FileUtil::CreateDir(GetMountPoint() + path.AsString()); |
| 85 | } | 89 | } |
| 86 | 90 | ||
| 91 | bool Archive_SDMC::RenameDirectory(const FileSys::Path& src_path, const FileSys::Path& dest_path) const { | ||
| 92 | return FileUtil::Rename(GetMountPoint() + src_path.AsString(), GetMountPoint() + dest_path.AsString()); | ||
| 93 | } | ||
| 94 | |||
| 87 | /** | 95 | /** |
| 88 | * Open a directory specified by its path | 96 | * Open a directory specified by its path |
| 89 | * @param path Path relative to the archive | 97 | * @param path Path relative to the archive |
diff --git a/src/core/file_sys/archive_sdmc.h b/src/core/file_sys/archive_sdmc.h index 74ce29c0d..19f563a62 100644 --- a/src/core/file_sys/archive_sdmc.h +++ b/src/core/file_sys/archive_sdmc.h | |||
| @@ -48,6 +48,14 @@ public: | |||
| 48 | bool DeleteFile(const FileSys::Path& path) const override; | 48 | bool DeleteFile(const FileSys::Path& path) const override; |
| 49 | 49 | ||
| 50 | /** | 50 | /** |
| 51 | * Rename a File specified by its path | ||
| 52 | * @param src_path Source path relative to the archive | ||
| 53 | * @param dest_path Destination path relative to the archive | ||
| 54 | * @return Whether rename succeeded | ||
| 55 | */ | ||
| 56 | bool RenameFile(const FileSys::Path& src_path, const FileSys::Path& dest_path) const override; | ||
| 57 | |||
| 58 | /** | ||
| 51 | * Delete a directory specified by its path | 59 | * Delete a directory specified by its path |
| 52 | * @param path Path relative to the archive | 60 | * @param path Path relative to the archive |
| 53 | * @return Whether the directory could be deleted | 61 | * @return Whether the directory could be deleted |
| @@ -62,6 +70,14 @@ public: | |||
| 62 | bool CreateDirectory(const Path& path) const override; | 70 | bool CreateDirectory(const Path& path) const override; |
| 63 | 71 | ||
| 64 | /** | 72 | /** |
| 73 | * Rename a Directory specified by its path | ||
| 74 | * @param src_path Source path relative to the archive | ||
| 75 | * @param dest_path Destination path relative to the archive | ||
| 76 | * @return Whether rename succeeded | ||
| 77 | */ | ||
| 78 | bool RenameDirectory(const FileSys::Path& src_path, const FileSys::Path& dest_path) const override; | ||
| 79 | |||
| 80 | /** | ||
| 65 | * Open a directory specified by its path | 81 | * Open a directory specified by its path |
| 66 | * @param path Path relative to the archive | 82 | * @param path Path relative to the archive |
| 67 | * @return Opened directory, or nullptr | 83 | * @return Opened directory, or nullptr |