diff options
author | archshift <admin@archshift.com> | 2014-11-24 08:20:04 +0100 |
---|---|---|
committer | archshift <admin@archshift.com> | 2014-11-25 00:09:11 +0100 |
commit | 45afc15aa6b9b1798a321bc053171deb765d7681 (patch) | |
tree | 54da02809c463f89462c3b29a48fb1564f699f01 /src/core | |
parent | Merge pull request #147 from yuriks/error-codes (diff) | |
download | yuzu-45afc15aa6b9b1798a321bc053171deb765d7681.tar yuzu-45afc15aa6b9b1798a321bc053171deb765d7681.tar.gz yuzu-45afc15aa6b9b1798a321bc053171deb765d7681.tar.bz2 yuzu-45afc15aa6b9b1798a321bc053171deb765d7681.tar.lz yuzu-45afc15aa6b9b1798a321bc053171deb765d7681.tar.xz yuzu-45afc15aa6b9b1798a321bc053171deb765d7681.tar.zst yuzu-45afc15aa6b9b1798a321bc053171deb765d7681.zip |
Diffstat (limited to 'src/core')
-rw-r--r-- | src/core/file_sys/archive.h | 8 | ||||
-rw-r--r-- | src/core/file_sys/archive_romfs.cpp | 11 | ||||
-rw-r--r-- | src/core/file_sys/archive_romfs.h | 8 | ||||
-rw-r--r-- | src/core/file_sys/archive_sdmc.cpp | 10 | ||||
-rw-r--r-- | src/core/file_sys/archive_sdmc.h | 8 | ||||
-rw-r--r-- | src/core/hle/kernel/archive.cpp | 24 | ||||
-rw-r--r-- | src/core/hle/kernel/archive.h | 11 | ||||
-rw-r--r-- | src/core/hle/service/fs_user.cpp | 44 |
8 files changed, 123 insertions, 1 deletions
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 @@ -192,6 +192,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 * @return Whether the directory could be deleted 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 @@ -44,6 +44,17 @@ bool Archive_RomFS::DeleteFile(const FileSys::Path& path) const { } /** + * 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 * @return Whether the directory could be deleted 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 @@ -44,6 +44,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 * @return Whether the directory could be deleted 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 @@ -67,6 +67,16 @@ bool Archive_SDMC::DeleteFile(const FileSys::Path& path) const { } /** + * 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 * @return Whether the directory could be deleted 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 @@ -48,6 +48,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 * @return Whether the directory could be deleted diff --git a/src/core/hle/kernel/archive.cpp b/src/core/hle/kernel/archive.cpp index e273444c9..0bf31ea2f 100644 --- a/src/core/hle/kernel/archive.cpp +++ b/src/core/hle/kernel/archive.cpp @@ -356,6 +356,30 @@ Result DeleteFileFromArchive(Handle archive_handle, const FileSys::Path& path) { } /** + * Rename a File between two Archives + * @param src_archive_handle Handle to the source Archive object + * @param src_path Path to the File inside of the source Archive + * @param dest_archive_handle Handle to the destination Archive object + * @param dest_path Path to the File inside of the destination Archive + * @return Whether rename succeeded + */ +Result RenameFileBetweenArchives(Handle src_archive_handle, const FileSys::Path& src_path, + Handle dest_archive_handle, const FileSys::Path& dest_path) { + Archive* src_archive = Kernel::g_object_pool.GetFast<Archive>(src_archive_handle); + Archive* dest_archive = Kernel::g_object_pool.GetFast<Archive>(dest_archive_handle); + if (src_archive == nullptr || dest_archive == nullptr) + return -1; + if (src_archive == dest_archive) { + if (src_archive->backend->RenameFile(src_path, dest_path)) + return 0; + } else { + // TODO: Implement renaming across archives + return -1; + } + return -1; +} + +/** * Delete a Directory from an Archive * @param archive_handle Handle to an open Archive object * @param path Path to the Directory inside of the Archive diff --git a/src/core/hle/kernel/archive.h b/src/core/hle/kernel/archive.h index 6fc4f0f25..5158fbae8 100644 --- a/src/core/hle/kernel/archive.h +++ b/src/core/hle/kernel/archive.h @@ -53,6 +53,17 @@ ResultVal<Handle> OpenFileFromArchive(Handle archive_handle, const FileSys::Path Result DeleteFileFromArchive(Handle archive_handle, const FileSys::Path& path); /** + * Rename a File between two Archives + * @param src_archive_handle Handle to the source Archive object + * @param src_path Path to the File inside of the source Archive + * @param dest_archive_handle Handle to the destination Archive object + * @param dest_path Path to the File inside of the destination Archive + * @return Whether rename succeeded + */ +Result RenameFileBetweenArchives(Handle src_archive_handle, const FileSys::Path& src_path, + Handle dest_archive_handle, const FileSys::Path& dest_path); + +/** * Delete a Directory from an Archive * @param archive_handle Handle to an open Archive object * @param path Path to the Directory inside of the Archive diff --git a/src/core/hle/service/fs_user.cpp b/src/core/hle/service/fs_user.cpp index 435be5b5d..e9756e2eb 100644 --- a/src/core/hle/service/fs_user.cpp +++ b/src/core/hle/service/fs_user.cpp @@ -165,6 +165,48 @@ void DeleteFile(Service::Interface* self) { } /* + * FS_User::RenameFile service function + * Inputs: + * 2 : Source archive handle lower word + * 3 : Source archive handle upper word + * 4 : Source file path type + * 5 : Source file path size + * 6 : Dest archive handle lower word + * 7 : Dest archive handle upper word + * 8 : Dest file path type + * 9 : Dest file path size + * 11: Source file path string data + * 13: Dest file path string + * Outputs: + * 1 : Result of function, 0 on success, otherwise error code + */ +void RenameFile(Service::Interface* self) { + u32* cmd_buff = Service::GetCommandBuffer(); + + // TODO(Link Mauve): cmd_buff[2] and cmd_buff[6], aka archive handle lower word, aren't used according to + // 3dmoo's or ctrulib's implementations. Triple check if it's really the case. + Handle src_archive_handle = static_cast<Handle>(cmd_buff[3]); + auto src_filename_type = static_cast<FileSys::LowPathType>(cmd_buff[4]); + u32 src_filename_size = cmd_buff[5]; + Handle dest_archive_handle = static_cast<Handle>(cmd_buff[7]); + auto dest_filename_type = static_cast<FileSys::LowPathType>(cmd_buff[8]); + u32 dest_filename_size = cmd_buff[9]; + u32 src_filename_ptr = cmd_buff[11]; + u32 dest_filename_ptr = cmd_buff[13]; + + FileSys::Path src_file_path(src_filename_type, src_filename_size, src_filename_ptr); + FileSys::Path dest_file_path(dest_filename_type, dest_filename_size, dest_filename_ptr); + + DEBUG_LOG(KERNEL, "src_type=%d src_size=%d src_data=%s dest_type=%d dest_size=%d dest_data=%s", + src_filename_type, src_filename_size, src_file_path.DebugStr().c_str(), + dest_filename_type, dest_filename_size, dest_file_path.DebugStr().c_str()); + + cmd_buff[1] = Kernel::RenameFileBetweenArchives(src_archive_handle, src_file_path, dest_archive_handle, dest_file_path); + + DEBUG_LOG(KERNEL, "called"); +} + +/* * FS_User::DeleteDirectory service function * Inputs: * 2 : Archive handle lower word @@ -314,7 +356,7 @@ const Interface::FunctionInfo FunctionTable[] = { {0x080201C2, OpenFile, "OpenFile"}, {0x08030204, OpenFileDirectly, "OpenFileDirectly"}, {0x08040142, DeleteFile, "DeleteFile"}, - {0x08050244, nullptr, "RenameFile"}, + {0x08050244, RenameFile, "RenameFile"}, {0x08060142, DeleteDirectory, "DeleteDirectory"}, {0x08070142, nullptr, "DeleteDirectoryRecursively"}, {0x08080202, nullptr, "CreateFile"}, |