From 45afc15aa6b9b1798a321bc053171deb765d7681 Mon Sep 17 00:00:00 2001 From: archshift Date: Sun, 23 Nov 2014 23:20:04 -0800 Subject: Implemented RenameFile in FS:USER --- src/core/file_sys/archive.h | 8 ++++++++ src/core/file_sys/archive_romfs.cpp | 11 +++++++++++ src/core/file_sys/archive_romfs.h | 8 ++++++++ src/core/file_sys/archive_sdmc.cpp | 10 ++++++++++ src/core/file_sys/archive_sdmc.h | 8 ++++++++ 5 files changed, 45 insertions(+) (limited to 'src/core/file_sys') diff --git a/src/core/file_sys/archive.h b/src/core/file_sys/archive.h index 2e79bb883..703742a1f 100644 --- a/src/core/file_sys/archive.h +++ b/src/core/file_sys/archive.h @@ -191,6 +191,14 @@ public: */ virtual bool DeleteFile(const FileSys::Path& path) const = 0; + /** + * Rename a File specified by its path + * @param src_path Source path relative to the archive + * @param dest_path Destination path relative to the archive + * @return Whether rename succeeded + */ + virtual bool RenameFile(const FileSys::Path& src_path, const FileSys::Path& dest_path) const = 0; + /** * Delete a directory specified by its path * @param path Path relative to the archive diff --git a/src/core/file_sys/archive_romfs.cpp b/src/core/file_sys/archive_romfs.cpp index 53dc57954..5594c5910 100644 --- a/src/core/file_sys/archive_romfs.cpp +++ b/src/core/file_sys/archive_romfs.cpp @@ -43,6 +43,17 @@ bool Archive_RomFS::DeleteFile(const FileSys::Path& path) const { return false; } +/** + * Rename a File specified by its path + * @param src_path Source path relative to the archive + * @param dest_path Destination path relative to the archive + * @return Whether rename succeeded + */ +bool Archive_RomFS::RenameFile(const FileSys::Path& src_path, const FileSys::Path& dest_path) const { + ERROR_LOG(FILESYS, "Attempted to rename a file within ROMFS."); + return false; +} + /** * Delete a directory specified by its path * @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..d14372a01 100644 --- a/src/core/file_sys/archive_romfs.h +++ b/src/core/file_sys/archive_romfs.h @@ -43,6 +43,14 @@ public: */ bool DeleteFile(const FileSys::Path& path) const override; + /** + * Rename a File specified by its path + * @param src_path Source path relative to the archive + * @param dest_path Destination path relative to the archive + * @return Whether rename succeeded + */ + bool RenameFile(const FileSys::Path& src_path, const FileSys::Path& dest_path) const override; + /** * Delete a directory specified by its path * @param path Path relative to the archive diff --git a/src/core/file_sys/archive_sdmc.cpp b/src/core/file_sys/archive_sdmc.cpp index c2ffcd40d..24bc43a02 100644 --- a/src/core/file_sys/archive_sdmc.cpp +++ b/src/core/file_sys/archive_sdmc.cpp @@ -66,6 +66,16 @@ bool Archive_SDMC::DeleteFile(const FileSys::Path& path) const { return FileUtil::Delete(GetMountPoint() + path.AsString()); } +/** + * Rename a File specified by its path + * @param src_path Source path relative to the archive + * @param dest_path Destination path relative to the archive + * @return Whether rename succeeded + */ +bool Archive_SDMC::RenameFile(const FileSys::Path& src_path, const FileSys::Path& dest_path) const { + return FileUtil::Rename(GetMountPoint() + src_path.AsString(), GetMountPoint() + dest_path.AsString()); +} + /** * Delete a directory specified by its path * @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..0dbed987b 100644 --- a/src/core/file_sys/archive_sdmc.h +++ b/src/core/file_sys/archive_sdmc.h @@ -47,6 +47,14 @@ public: */ bool DeleteFile(const FileSys::Path& path) const override; + /** + * Rename a File specified by its path + * @param src_path Source path relative to the archive + * @param dest_path Destination path relative to the archive + * @return Whether rename succeeded + */ + bool RenameFile(const FileSys::Path& src_path, const FileSys::Path& dest_path) const override; + /** * Delete a directory specified by its path * @param path Path relative to the archive -- cgit v1.2.3