summaryrefslogtreecommitdiff
path: root/src/core/file_sys
diff options
context:
space:
mode:
authorGravatar mailwl2018-04-24 10:56:05 +0300
committerGravatar mailwl2018-04-24 10:56:05 +0300
commita0179e5ca5bc54491f03ff60d2f971197eb03e88 (patch)
tree99ba0561c6fe429169a40e76a70db7b3f99a71ee /src/core/file_sys
parentMerge pull request #379 from Subv/multi_buffers (diff)
downloadyuzu-a0179e5ca5bc54491f03ff60d2f971197eb03e88.tar.gz
yuzu-a0179e5ca5bc54491f03ff60d2f971197eb03e88.tar.xz
yuzu-a0179e5ca5bc54491f03ff60d2f971197eb03e88.zip
Service/FS: implement IFileSystem::RenameFile
Diffstat (limited to 'src/core/file_sys')
-rw-r--r--src/core/file_sys/disk_filesystem.cpp12
-rw-r--r--src/core/file_sys/disk_filesystem.h2
-rw-r--r--src/core/file_sys/filesystem.h3
-rw-r--r--src/core/file_sys/romfs_filesystem.cpp3
-rw-r--r--src/core/file_sys/romfs_filesystem.h2
5 files changed, 15 insertions, 7 deletions
diff --git a/src/core/file_sys/disk_filesystem.cpp b/src/core/file_sys/disk_filesystem.cpp
index ca1323873..4d00249fa 100644
--- a/src/core/file_sys/disk_filesystem.cpp
+++ b/src/core/file_sys/disk_filesystem.cpp
@@ -67,10 +67,16 @@ ResultCode Disk_FileSystem::DeleteFile(const std::string& path) const {
67 return RESULT_SUCCESS; 67 return RESULT_SUCCESS;
68} 68}
69 69
70ResultCode Disk_FileSystem::RenameFile(const Path& src_path, const Path& dest_path) const { 70ResultCode Disk_FileSystem::RenameFile(const std::string& src_path,
71 LOG_WARNING(Service_FS, "(STUBBED) called"); 71 const std::string& dest_path) const {
72 const std::string full_src_path = base_directory + src_path;
73 const std::string full_dest_path = base_directory + dest_path;
74
75 if (!FileUtil::Exists(full_src_path)) {
76 return ERROR_PATH_NOT_FOUND;
77 }
72 // TODO(wwylele): Use correct error code 78 // TODO(wwylele): Use correct error code
73 return ResultCode(-1); 79 return FileUtil::Rename(full_src_path, full_dest_path) ? RESULT_SUCCESS : ResultCode(-1);
74} 80}
75 81
76ResultCode Disk_FileSystem::DeleteDirectory(const Path& path) const { 82ResultCode Disk_FileSystem::DeleteDirectory(const Path& path) const {
diff --git a/src/core/file_sys/disk_filesystem.h b/src/core/file_sys/disk_filesystem.h
index 8f9e1145a..591e39fda 100644
--- a/src/core/file_sys/disk_filesystem.h
+++ b/src/core/file_sys/disk_filesystem.h
@@ -26,7 +26,7 @@ public:
26 ResultVal<std::unique_ptr<StorageBackend>> OpenFile(const std::string& path, 26 ResultVal<std::unique_ptr<StorageBackend>> OpenFile(const std::string& path,
27 Mode mode) const override; 27 Mode mode) const override;
28 ResultCode DeleteFile(const std::string& path) const override; 28 ResultCode DeleteFile(const std::string& path) const override;
29 ResultCode RenameFile(const Path& src_path, const Path& dest_path) const override; 29 ResultCode RenameFile(const std::string& src_path, const std::string& dest_path) const override;
30 ResultCode DeleteDirectory(const Path& path) const override; 30 ResultCode DeleteDirectory(const Path& path) const override;
31 ResultCode DeleteDirectoryRecursively(const Path& path) const override; 31 ResultCode DeleteDirectoryRecursively(const Path& path) const override;
32 ResultCode CreateFile(const std::string& path, u64 size) const override; 32 ResultCode CreateFile(const std::string& path, u64 size) const override;
diff --git a/src/core/file_sys/filesystem.h b/src/core/file_sys/filesystem.h
index beefcfdb2..295a3133e 100644
--- a/src/core/file_sys/filesystem.h
+++ b/src/core/file_sys/filesystem.h
@@ -126,7 +126,8 @@ public:
126 * @param dest_path Destination path relative to the archive 126 * @param dest_path Destination path relative to the archive
127 * @return Result of the operation 127 * @return Result of the operation
128 */ 128 */
129 virtual ResultCode RenameFile(const Path& src_path, const Path& dest_path) const = 0; 129 virtual ResultCode RenameFile(const std::string& src_path,
130 const std::string& dest_path) const = 0;
130 131
131 /** 132 /**
132 * Rename a Directory specified by its path 133 * Rename a Directory specified by its path
diff --git a/src/core/file_sys/romfs_filesystem.cpp b/src/core/file_sys/romfs_filesystem.cpp
index 3d77e2d5f..b9982e6fa 100644
--- a/src/core/file_sys/romfs_filesystem.cpp
+++ b/src/core/file_sys/romfs_filesystem.cpp
@@ -27,7 +27,8 @@ ResultCode RomFS_FileSystem::DeleteFile(const std::string& path) const {
27 return ResultCode(-1); 27 return ResultCode(-1);
28} 28}
29 29
30ResultCode RomFS_FileSystem::RenameFile(const Path& src_path, const Path& dest_path) const { 30ResultCode RomFS_FileSystem::RenameFile(const std::string& src_path,
31 const std::string& dest_path) const {
31 LOG_CRITICAL(Service_FS, "Attempted to rename a file within an ROMFS archive (%s).", 32 LOG_CRITICAL(Service_FS, "Attempted to rename a file within an ROMFS archive (%s).",
32 GetName().c_str()); 33 GetName().c_str());
33 // TODO(wwylele): Use correct error code 34 // TODO(wwylele): Use correct error code
diff --git a/src/core/file_sys/romfs_filesystem.h b/src/core/file_sys/romfs_filesystem.h
index 1b5cac409..ba9d85823 100644
--- a/src/core/file_sys/romfs_filesystem.h
+++ b/src/core/file_sys/romfs_filesystem.h
@@ -32,7 +32,7 @@ public:
32 ResultVal<std::unique_ptr<StorageBackend>> OpenFile(const std::string& path, 32 ResultVal<std::unique_ptr<StorageBackend>> OpenFile(const std::string& path,
33 Mode mode) const override; 33 Mode mode) const override;
34 ResultCode DeleteFile(const std::string& path) const override; 34 ResultCode DeleteFile(const std::string& path) const override;
35 ResultCode RenameFile(const Path& src_path, const Path& dest_path) const override; 35 ResultCode RenameFile(const std::string& src_path, const std::string& dest_path) const override;
36 ResultCode DeleteDirectory(const Path& path) const override; 36 ResultCode DeleteDirectory(const Path& path) const override;
37 ResultCode DeleteDirectoryRecursively(const Path& path) const override; 37 ResultCode DeleteDirectoryRecursively(const Path& path) const override;
38 ResultCode CreateFile(const std::string& path, u64 size) const override; 38 ResultCode CreateFile(const std::string& path, u64 size) const override;