summaryrefslogtreecommitdiffstats
path: root/src/core/file_sys
diff options
context:
space:
mode:
authorJames <jselby@jselby.net>2017-07-31 08:59:34 +0200
committerJames <jselby@jselby.net>2017-07-31 09:11:53 +0200
commit941a722ff1d862fa7b0c2ba73ff9c003324da281 (patch)
tree52f3da0860c429449e42f05ecf3454d2b1ab9435 /src/core/file_sys
parentMerge pull request #2848 from wwylele/shader-loop-fix (diff)
downloadyuzu-941a722ff1d862fa7b0c2ba73ff9c003324da281.tar
yuzu-941a722ff1d862fa7b0c2ba73ff9c003324da281.tar.gz
yuzu-941a722ff1d862fa7b0c2ba73ff9c003324da281.tar.bz2
yuzu-941a722ff1d862fa7b0c2ba73ff9c003324da281.tar.lz
yuzu-941a722ff1d862fa7b0c2ba73ff9c003324da281.tar.xz
yuzu-941a722ff1d862fa7b0c2ba73ff9c003324da281.tar.zst
yuzu-941a722ff1d862fa7b0c2ba73ff9c003324da281.zip
Diffstat (limited to 'src/core/file_sys')
-rw-r--r--src/core/file_sys/archive_sdmc.cpp41
-rw-r--r--src/core/file_sys/savedata_archive.cpp41
2 files changed, 78 insertions, 4 deletions
diff --git a/src/core/file_sys/archive_sdmc.cpp b/src/core/file_sys/archive_sdmc.cpp
index 679909d06..fe3dce5d4 100644
--- a/src/core/file_sys/archive_sdmc.cpp
+++ b/src/core/file_sys/archive_sdmc.cpp
@@ -121,7 +121,25 @@ ResultCode SDMCArchive::DeleteFile(const Path& path) const {
}
ResultCode SDMCArchive::RenameFile(const Path& src_path, const Path& dest_path) const {
- if (FileUtil::Rename(mount_point + src_path.AsString(), mount_point + dest_path.AsString())) {
+ const PathParser path_parser_src(src_path);
+
+ // TODO: Verify these return codes with HW
+ if (!path_parser_src.IsValid()) {
+ LOG_ERROR(Service_FS, "Invalid src path %s", src_path.DebugStr().c_str());
+ return ERROR_INVALID_PATH;
+ }
+
+ const PathParser path_parser_dest(dest_path);
+
+ if (!path_parser_dest.IsValid()) {
+ LOG_ERROR(Service_FS, "Invalid dest path %s", dest_path.DebugStr().c_str());
+ return ERROR_INVALID_PATH;
+ }
+
+ const auto src_path_full = path_parser_src.BuildHostPath(mount_point);
+ const auto dest_path_full = path_parser_dest.BuildHostPath(mount_point);
+
+ if (FileUtil::Rename(src_path_full, dest_path_full)) {
return RESULT_SUCCESS;
}
@@ -260,8 +278,27 @@ ResultCode SDMCArchive::CreateDirectory(const Path& path) const {
}
ResultCode SDMCArchive::RenameDirectory(const Path& src_path, const Path& dest_path) const {
- if (FileUtil::Rename(mount_point + src_path.AsString(), mount_point + dest_path.AsString()))
+ const PathParser path_parser_src(src_path);
+
+ // TODO: Verify these return codes with HW
+ if (!path_parser_src.IsValid()) {
+ LOG_ERROR(Service_FS, "Invalid src path %s", src_path.DebugStr().c_str());
+ return ERROR_INVALID_PATH;
+ }
+
+ const PathParser path_parser_dest(dest_path);
+
+ if (!path_parser_dest.IsValid()) {
+ LOG_ERROR(Service_FS, "Invalid dest path %s", dest_path.DebugStr().c_str());
+ return ERROR_INVALID_PATH;
+ }
+
+ const auto src_path_full = path_parser_src.BuildHostPath(mount_point);
+ const auto dest_path_full = path_parser_dest.BuildHostPath(mount_point);
+
+ if (FileUtil::Rename(src_path_full, dest_path_full)) {
return RESULT_SUCCESS;
+ }
// TODO(yuriks): This code probably isn't right, it'll return a Status even if the file didn't
// exist or similar. Verify.
diff --git a/src/core/file_sys/savedata_archive.cpp b/src/core/file_sys/savedata_archive.cpp
index f540c4a93..f8f811ba0 100644
--- a/src/core/file_sys/savedata_archive.cpp
+++ b/src/core/file_sys/savedata_archive.cpp
@@ -106,7 +106,25 @@ ResultCode SaveDataArchive::DeleteFile(const Path& path) const {
}
ResultCode SaveDataArchive::RenameFile(const Path& src_path, const Path& dest_path) const {
- if (FileUtil::Rename(mount_point + src_path.AsString(), mount_point + dest_path.AsString())) {
+ const PathParser path_parser_src(src_path);
+
+ // TODO: Verify these return codes with HW
+ if (!path_parser_src.IsValid()) {
+ LOG_ERROR(Service_FS, "Invalid src path %s", src_path.DebugStr().c_str());
+ return ERROR_INVALID_PATH;
+ }
+
+ const PathParser path_parser_dest(dest_path);
+
+ if (!path_parser_dest.IsValid()) {
+ LOG_ERROR(Service_FS, "Invalid dest path %s", dest_path.DebugStr().c_str());
+ return ERROR_INVALID_PATH;
+ }
+
+ const auto src_path_full = path_parser_src.BuildHostPath(mount_point);
+ const auto dest_path_full = path_parser_dest.BuildHostPath(mount_point);
+
+ if (FileUtil::Rename(src_path_full, dest_path_full)) {
return RESULT_SUCCESS;
}
@@ -247,8 +265,27 @@ ResultCode SaveDataArchive::CreateDirectory(const Path& path) const {
}
ResultCode SaveDataArchive::RenameDirectory(const Path& src_path, const Path& dest_path) const {
- if (FileUtil::Rename(mount_point + src_path.AsString(), mount_point + dest_path.AsString()))
+ const PathParser path_parser_src(src_path);
+
+ // TODO: Verify these return codes with HW
+ if (!path_parser_src.IsValid()) {
+ LOG_ERROR(Service_FS, "Invalid src path %s", src_path.DebugStr().c_str());
+ return ERROR_INVALID_PATH;
+ }
+
+ const PathParser path_parser_dest(dest_path);
+
+ if (!path_parser_dest.IsValid()) {
+ LOG_ERROR(Service_FS, "Invalid dest path %s", dest_path.DebugStr().c_str());
+ return ERROR_INVALID_PATH;
+ }
+
+ const auto src_path_full = path_parser_src.BuildHostPath(mount_point);
+ const auto dest_path_full = path_parser_dest.BuildHostPath(mount_point);
+
+ if (FileUtil::Rename(src_path_full, dest_path_full)) {
return RESULT_SUCCESS;
+ }
// TODO(yuriks): This code probably isn't right, it'll return a Status even if the file didn't
// exist or similar. Verify.