diff options
Diffstat (limited to 'src')
| -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 703742a1f..5ea75361e 100644 --- a/src/core/file_sys/archive.h +++ b/src/core/file_sys/archive.h | |||
| @@ -214,6 +214,14 @@ public: | |||
| 214 | virtual bool CreateDirectory(const Path& path) const = 0; | 214 | virtual bool CreateDirectory(const Path& path) const = 0; |
| 215 | 215 | ||
| 216 | /** | 216 | /** |
| 217 | * Rename a Directory specified by its path | ||
| 218 | * @param src_path Source path relative to the archive | ||
| 219 | * @param dest_path Destination path relative to the archive | ||
| 220 | * @return Whether rename succeeded | ||
| 221 | */ | ||
| 222 | virtual bool RenameDirectory(const FileSys::Path& src_path, const FileSys::Path& dest_path) const = 0; | ||
| 223 | |||
| 224 | /** | ||
| 217 | * Open a directory specified by its path | 225 | * Open a directory specified by its path |
| 218 | * @param path Path relative to the archive | 226 | * @param path Path relative to the archive |
| 219 | * @return Opened directory, or nullptr | 227 | * @return Opened directory, or nullptr |
diff --git a/src/core/file_sys/archive_romfs.cpp b/src/core/file_sys/archive_romfs.cpp index 5594c5910..d0ca7d380 100644 --- a/src/core/file_sys/archive_romfs.cpp +++ b/src/core/file_sys/archive_romfs.cpp | |||
| @@ -75,6 +75,17 @@ bool Archive_RomFS::CreateDirectory(const Path& path) const { | |||
| 75 | } | 75 | } |
| 76 | 76 | ||
| 77 | /** | 77 | /** |
| 78 | * Rename a Directory specified by its path | ||
| 79 | * @param src_path Source path relative to the archive | ||
| 80 | * @param dest_path Destination path relative to the archive | ||
| 81 | * @return Whether rename succeeded | ||
| 82 | */ | ||
| 83 | bool Archive_RomFS::RenameDirectory(const FileSys::Path& src_path, const FileSys::Path& dest_path) const { | ||
| 84 | ERROR_LOG(FILESYS, "Attempted to rename a file within ROMFS."); | ||
| 85 | return false; | ||
| 86 | } | ||
| 87 | |||
| 88 | /** | ||
| 78 | * Open a directory specified by its path | 89 | * Open a directory specified by its path |
| 79 | * @param path Path relative to the archive | 90 | * @param path Path relative to the archive |
| 80 | * @return Opened directory, or nullptr | 91 | * @return Opened directory, or nullptr |
diff --git a/src/core/file_sys/archive_romfs.h b/src/core/file_sys/archive_romfs.h index d14372a01..222bdc356 100644 --- a/src/core/file_sys/archive_romfs.h +++ b/src/core/file_sys/archive_romfs.h | |||
| @@ -66,6 +66,14 @@ public: | |||
| 66 | bool CreateDirectory(const Path& path) const override; | 66 | bool CreateDirectory(const Path& path) const override; |
| 67 | 67 | ||
| 68 | /** | 68 | /** |
| 69 | * Rename a Directory specified by its path | ||
| 70 | * @param src_path Source path relative to the archive | ||
| 71 | * @param dest_path Destination path relative to the archive | ||
| 72 | * @return Whether rename succeeded | ||
| 73 | */ | ||
| 74 | bool RenameDirectory(const FileSys::Path& src_path, const FileSys::Path& dest_path) const override; | ||
| 75 | |||
| 76 | /** | ||
| 69 | * Open a directory specified by its path | 77 | * Open a directory specified by its path |
| 70 | * @param path Path relative to the archive | 78 | * @param path Path relative to the archive |
| 71 | * @return Opened directory, or nullptr | 79 | * @return Opened directory, or nullptr |
diff --git a/src/core/file_sys/archive_sdmc.cpp b/src/core/file_sys/archive_sdmc.cpp index 24bc43a02..c8958a0eb 100644 --- a/src/core/file_sys/archive_sdmc.cpp +++ b/src/core/file_sys/archive_sdmc.cpp | |||
| @@ -95,6 +95,16 @@ bool Archive_SDMC::CreateDirectory(const Path& path) const { | |||
| 95 | } | 95 | } |
| 96 | 96 | ||
| 97 | /** | 97 | /** |
| 98 | * Rename a Directory specified by its path | ||
| 99 | * @param src_path Source path relative to the archive | ||
| 100 | * @param dest_path Destination path relative to the archive | ||
| 101 | * @return Whether rename succeeded | ||
| 102 | */ | ||
| 103 | bool Archive_SDMC::RenameDirectory(const FileSys::Path& src_path, const FileSys::Path& dest_path) const { | ||
| 104 | return FileUtil::Rename(GetMountPoint() + src_path.AsString(), GetMountPoint() + dest_path.AsString()); | ||
| 105 | } | ||
| 106 | |||
| 107 | /** | ||
| 98 | * Open a directory specified by its path | 108 | * Open a directory specified by its path |
| 99 | * @param path Path relative to the archive | 109 | * @param path Path relative to the archive |
| 100 | * @return Opened directory, or nullptr | 110 | * @return Opened directory, or nullptr |
diff --git a/src/core/file_sys/archive_sdmc.h b/src/core/file_sys/archive_sdmc.h index 0dbed987b..19f563a62 100644 --- a/src/core/file_sys/archive_sdmc.h +++ b/src/core/file_sys/archive_sdmc.h | |||
| @@ -70,6 +70,14 @@ public: | |||
| 70 | bool CreateDirectory(const Path& path) const override; | 70 | bool CreateDirectory(const Path& path) const override; |
| 71 | 71 | ||
| 72 | /** | 72 | /** |
| 73 | * Rename a Directory specified by its path | ||
| 74 | * @param src_path Source path relative to the archive | ||
| 75 | * @param dest_path Destination path relative to the archive | ||
| 76 | * @return Whether rename succeeded | ||
| 77 | */ | ||
| 78 | bool RenameDirectory(const FileSys::Path& src_path, const FileSys::Path& dest_path) const override; | ||
| 79 | |||
| 80 | /** | ||
| 73 | * Open a directory specified by its path | 81 | * Open a directory specified by its path |
| 74 | * @param path Path relative to the archive | 82 | * @param path Path relative to the archive |
| 75 | * @return Opened directory, or nullptr | 83 | * @return Opened directory, or nullptr |
diff --git a/src/core/hle/kernel/archive.cpp b/src/core/hle/kernel/archive.cpp index 0bf31ea2f..bffe59952 100644 --- a/src/core/hle/kernel/archive.cpp +++ b/src/core/hle/kernel/archive.cpp | |||
| @@ -410,6 +410,30 @@ Result CreateDirectoryFromArchive(Handle archive_handle, const FileSys::Path& pa | |||
| 410 | } | 410 | } |
| 411 | 411 | ||
| 412 | /** | 412 | /** |
| 413 | * Rename a Directory between two Archives | ||
| 414 | * @param src_archive_handle Handle to the source Archive object | ||
| 415 | * @param src_path Path to the Directory inside of the source Archive | ||
| 416 | * @param dest_archive_handle Handle to the destination Archive object | ||
| 417 | * @param dest_path Path to the Directory inside of the destination Archive | ||
| 418 | * @return Whether rename succeeded | ||
| 419 | */ | ||
| 420 | Result RenameDirectoryBetweenArchives(Handle src_archive_handle, const FileSys::Path& src_path, | ||
| 421 | Handle dest_archive_handle, const FileSys::Path& dest_path) { | ||
| 422 | Archive* src_archive = Kernel::g_object_pool.GetFast<Archive>(src_archive_handle); | ||
| 423 | Archive* dest_archive = Kernel::g_object_pool.GetFast<Archive>(dest_archive_handle); | ||
| 424 | if (src_archive == nullptr || dest_archive == nullptr) | ||
| 425 | return -1; | ||
| 426 | if (src_archive == dest_archive) { | ||
| 427 | if (src_archive->backend->RenameDirectory(src_path, dest_path)) | ||
| 428 | return 0; | ||
| 429 | } else { | ||
| 430 | // TODO: Implement renaming across archives | ||
| 431 | return -1; | ||
| 432 | } | ||
| 433 | return -1; | ||
| 434 | } | ||
| 435 | |||
| 436 | /** | ||
| 413 | * Open a Directory from an Archive | 437 | * Open a Directory from an Archive |
| 414 | * @param archive_handle Handle to an open Archive object | 438 | * @param archive_handle Handle to an open Archive object |
| 415 | * @param path Path to the Directory inside of the Archive | 439 | * @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 5158fbae8..9d071d315 100644 --- a/src/core/hle/kernel/archive.h +++ b/src/core/hle/kernel/archive.h | |||
| @@ -80,6 +80,17 @@ Result DeleteDirectoryFromArchive(Handle archive_handle, const FileSys::Path& pa | |||
| 80 | Result CreateDirectoryFromArchive(Handle archive_handle, const FileSys::Path& path); | 80 | Result CreateDirectoryFromArchive(Handle archive_handle, const FileSys::Path& path); |
| 81 | 81 | ||
| 82 | /** | 82 | /** |
| 83 | * Rename a Directory between two Archives | ||
| 84 | * @param src_archive_handle Handle to the source Archive object | ||
| 85 | * @param src_path Path to the Directory inside of the source Archive | ||
| 86 | * @param dest_archive_handle Handle to the destination Archive object | ||
| 87 | * @param dest_path Path to the Directory inside of the destination Archive | ||
| 88 | * @return Whether rename succeeded | ||
| 89 | */ | ||
| 90 | Result RenameDirectoryBetweenArchives(Handle src_archive_handle, const FileSys::Path& src_path, | ||
| 91 | Handle dest_archive_handle, const FileSys::Path& dest_path); | ||
| 92 | |||
| 93 | /** | ||
| 83 | * Open a Directory from an Archive | 94 | * Open a Directory from an Archive |
| 84 | * @param archive_handle Handle to an open Archive object | 95 | * @param archive_handle Handle to an open Archive object |
| 85 | * @param path Path to the Directory inside of the Archive | 96 | * @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 e9756e2eb..f4b1a879c 100644 --- a/src/core/hle/service/fs_user.cpp +++ b/src/core/hle/service/fs_user.cpp | |||
| @@ -267,6 +267,48 @@ static void CreateDirectory(Service::Interface* self) { | |||
| 267 | DEBUG_LOG(KERNEL, "called"); | 267 | DEBUG_LOG(KERNEL, "called"); |
| 268 | } | 268 | } |
| 269 | 269 | ||
| 270 | /* | ||
| 271 | * FS_User::RenameDirectory service function | ||
| 272 | * Inputs: | ||
| 273 | * 2 : Source archive handle lower word | ||
| 274 | * 3 : Source archive handle upper word | ||
| 275 | * 4 : Source dir path type | ||
| 276 | * 5 : Source dir path size | ||
| 277 | * 6 : Dest archive handle lower word | ||
| 278 | * 7 : Dest archive handle upper word | ||
| 279 | * 8 : Dest dir path type | ||
| 280 | * 9 : Dest dir path size | ||
| 281 | * 11: Source dir path string data | ||
| 282 | * 13: Dest dir path string | ||
| 283 | * Outputs: | ||
| 284 | * 1 : Result of function, 0 on success, otherwise error code | ||
| 285 | */ | ||
| 286 | void RenameDirectory(Service::Interface* self) { | ||
| 287 | u32* cmd_buff = Service::GetCommandBuffer(); | ||
| 288 | |||
| 289 | // TODO(Link Mauve): cmd_buff[2] and cmd_buff[6], aka archive handle lower word, aren't used according to | ||
| 290 | // 3dmoo's or ctrulib's implementations. Triple check if it's really the case. | ||
| 291 | Handle src_archive_handle = static_cast<Handle>(cmd_buff[3]); | ||
| 292 | auto src_dirname_type = static_cast<FileSys::LowPathType>(cmd_buff[4]); | ||
| 293 | u32 src_dirname_size = cmd_buff[5]; | ||
| 294 | Handle dest_archive_handle = static_cast<Handle>(cmd_buff[7]); | ||
| 295 | auto dest_dirname_type = static_cast<FileSys::LowPathType>(cmd_buff[8]); | ||
| 296 | u32 dest_dirname_size = cmd_buff[9]; | ||
| 297 | u32 src_dirname_ptr = cmd_buff[11]; | ||
| 298 | u32 dest_dirname_ptr = cmd_buff[13]; | ||
| 299 | |||
| 300 | FileSys::Path src_dir_path(src_dirname_type, src_dirname_size, src_dirname_ptr); | ||
| 301 | FileSys::Path dest_dir_path(dest_dirname_type, dest_dirname_size, dest_dirname_ptr); | ||
| 302 | |||
| 303 | DEBUG_LOG(KERNEL, "src_type=%d src_size=%d src_data=%s dest_type=%d dest_size=%d dest_data=%s", | ||
| 304 | src_dirname_type, src_dirname_size, src_dir_path.DebugStr().c_str(), | ||
| 305 | dest_dirname_type, dest_dirname_size, dest_dir_path.DebugStr().c_str()); | ||
| 306 | |||
| 307 | cmd_buff[1] = Kernel::RenameDirectoryBetweenArchives(src_archive_handle, src_dir_path, dest_archive_handle, dest_dir_path); | ||
| 308 | |||
| 309 | DEBUG_LOG(KERNEL, "called"); | ||
| 310 | } | ||
| 311 | |||
| 270 | static void OpenDirectory(Service::Interface* self) { | 312 | static void OpenDirectory(Service::Interface* self) { |
| 271 | u32* cmd_buff = Service::GetCommandBuffer(); | 313 | u32* cmd_buff = Service::GetCommandBuffer(); |
| 272 | 314 | ||
| @@ -361,7 +403,7 @@ const Interface::FunctionInfo FunctionTable[] = { | |||
| 361 | {0x08070142, nullptr, "DeleteDirectoryRecursively"}, | 403 | {0x08070142, nullptr, "DeleteDirectoryRecursively"}, |
| 362 | {0x08080202, nullptr, "CreateFile"}, | 404 | {0x08080202, nullptr, "CreateFile"}, |
| 363 | {0x08090182, CreateDirectory, "CreateDirectory"}, | 405 | {0x08090182, CreateDirectory, "CreateDirectory"}, |
| 364 | {0x080A0244, nullptr, "RenameDirectory"}, | 406 | {0x080A0244, RenameDirectory, "RenameDirectory"}, |
| 365 | {0x080B0102, OpenDirectory, "OpenDirectory"}, | 407 | {0x080B0102, OpenDirectory, "OpenDirectory"}, |
| 366 | {0x080C00C2, OpenArchive, "OpenArchive"}, | 408 | {0x080C00C2, OpenArchive, "OpenArchive"}, |
| 367 | {0x080D0144, nullptr, "ControlArchive"}, | 409 | {0x080D0144, nullptr, "ControlArchive"}, |