diff options
author | bunnei <bunneidev@gmail.com> | 2017-10-10 05:56:20 +0200 |
---|---|---|
committer | bunnei <bunneidev@gmail.com> | 2017-10-10 05:56:20 +0200 |
commit | b1d5db1cf60344b6b081c9d03cb6ccc3264326cd (patch) | |
tree | fde377c4ba3c0f92c032e6f5ec8627aae37270ef /src/core/file_sys/archive_sdmc.cpp | |
parent | loader: Various improvements for NSO/NRO loaders. (diff) | |
parent | Merge pull request #2996 from MerryMage/split-travis (diff) | |
download | yuzu-b1d5db1cf60344b6b081c9d03cb6ccc3264326cd.tar yuzu-b1d5db1cf60344b6b081c9d03cb6ccc3264326cd.tar.gz yuzu-b1d5db1cf60344b6b081c9d03cb6ccc3264326cd.tar.bz2 yuzu-b1d5db1cf60344b6b081c9d03cb6ccc3264326cd.tar.lz yuzu-b1d5db1cf60344b6b081c9d03cb6ccc3264326cd.tar.xz yuzu-b1d5db1cf60344b6b081c9d03cb6ccc3264326cd.tar.zst yuzu-b1d5db1cf60344b6b081c9d03cb6ccc3264326cd.zip |
Diffstat (limited to 'src/core/file_sys/archive_sdmc.cpp')
-rw-r--r-- | src/core/file_sys/archive_sdmc.cpp | 41 |
1 files changed, 39 insertions, 2 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. |