diff options
| author | 2014-11-24 01:12:58 -0800 | |
|---|---|---|
| committer | 2014-11-24 15:09:12 -0800 | |
| commit | e5ff01c2cde0fe903140f0215461a68d4f489132 (patch) | |
| tree | 1ce6d82dcc1d154a98d5931d57c30e12ef0cc18f /src/core/hle | |
| parent | Implemented RenameFile in FS:USER (diff) | |
| download | yuzu-e5ff01c2cde0fe903140f0215461a68d4f489132.tar.gz yuzu-e5ff01c2cde0fe903140f0215461a68d4f489132.tar.xz yuzu-e5ff01c2cde0fe903140f0215461a68d4f489132.zip | |
Implemented RenameDirectory in FS:USER
Diffstat (limited to 'src/core/hle')
| -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 |
3 files changed, 78 insertions, 1 deletions
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"}, |