diff options
Diffstat (limited to 'src/core/hle/kernel')
| -rw-r--r-- | src/core/hle/kernel/archive.cpp | 79 | ||||
| -rw-r--r-- | src/core/hle/kernel/archive.h | 28 |
2 files changed, 74 insertions, 33 deletions
diff --git a/src/core/hle/kernel/archive.cpp b/src/core/hle/kernel/archive.cpp index e273444c9..647f0dea9 100644 --- a/src/core/hle/kernel/archive.cpp +++ b/src/core/hle/kernel/archive.cpp | |||
| @@ -340,49 +340,68 @@ ResultVal<Handle> OpenFileFromArchive(Handle archive_handle, const FileSys::Path | |||
| 340 | return MakeResult<Handle>(handle); | 340 | return MakeResult<Handle>(handle); |
| 341 | } | 341 | } |
| 342 | 342 | ||
| 343 | /** | 343 | ResultCode DeleteFileFromArchive(Handle archive_handle, const FileSys::Path& path) { |
| 344 | * Delete a File from an Archive | ||
| 345 | * @param archive_handle Handle to an open Archive object | ||
| 346 | * @param path Path to the File inside of the Archive | ||
| 347 | * @return Whether deletion succeeded | ||
| 348 | */ | ||
| 349 | Result DeleteFileFromArchive(Handle archive_handle, const FileSys::Path& path) { | ||
| 350 | Archive* archive = Kernel::g_object_pool.GetFast<Archive>(archive_handle); | 344 | Archive* archive = Kernel::g_object_pool.GetFast<Archive>(archive_handle); |
| 351 | if (archive == nullptr) | 345 | if (archive == nullptr) |
| 352 | return -1; | 346 | return InvalidHandle(ErrorModule::FS); |
| 353 | if (archive->backend->DeleteFile(path)) | 347 | if (archive->backend->DeleteFile(path)) |
| 354 | return 0; | 348 | return RESULT_SUCCESS; |
| 355 | return -1; | 349 | return ResultCode(ErrorDescription::NoData, ErrorModule::FS, // TODO: verify description |
| 350 | ErrorSummary::Canceled, ErrorLevel::Status); | ||
| 356 | } | 351 | } |
| 357 | 352 | ||
| 358 | /** | 353 | ResultCode RenameFileBetweenArchives(Handle src_archive_handle, const FileSys::Path& src_path, |
| 359 | * Delete a Directory from an Archive | 354 | Handle dest_archive_handle, const FileSys::Path& dest_path) { |
| 360 | * @param archive_handle Handle to an open Archive object | 355 | Archive* src_archive = Kernel::g_object_pool.GetFast<Archive>(src_archive_handle); |
| 361 | * @param path Path to the Directory inside of the Archive | 356 | Archive* dest_archive = Kernel::g_object_pool.GetFast<Archive>(dest_archive_handle); |
| 362 | * @return Whether deletion succeeded | 357 | if (src_archive == nullptr || dest_archive == nullptr) |
| 363 | */ | 358 | return InvalidHandle(ErrorModule::FS); |
| 364 | Result DeleteDirectoryFromArchive(Handle archive_handle, const FileSys::Path& path) { | 359 | if (src_archive == dest_archive) { |
| 360 | if (src_archive->backend->RenameFile(src_path, dest_path)) | ||
| 361 | return RESULT_SUCCESS; | ||
| 362 | } else { | ||
| 363 | // TODO: Implement renaming across archives | ||
| 364 | return UnimplementedFunction(ErrorModule::FS); | ||
| 365 | } | ||
| 366 | return ResultCode(ErrorDescription::NoData, ErrorModule::FS, // TODO: verify description | ||
| 367 | ErrorSummary::NothingHappened, ErrorLevel::Status); | ||
| 368 | } | ||
| 369 | |||
| 370 | ResultCode DeleteDirectoryFromArchive(Handle archive_handle, const FileSys::Path& path) { | ||
| 365 | Archive* archive = Kernel::g_object_pool.GetFast<Archive>(archive_handle); | 371 | Archive* archive = Kernel::g_object_pool.GetFast<Archive>(archive_handle); |
| 366 | if (archive == nullptr) | 372 | if (archive == nullptr) |
| 367 | return -1; | 373 | return InvalidHandle(ErrorModule::FS); |
| 368 | if (archive->backend->DeleteDirectory(path)) | 374 | if (archive->backend->DeleteDirectory(path)) |
| 369 | return 0; | 375 | return RESULT_SUCCESS; |
| 370 | return -1; | 376 | return ResultCode(ErrorDescription::NoData, ErrorModule::FS, // TODO: verify description |
| 377 | ErrorSummary::Canceled, ErrorLevel::Status); | ||
| 371 | } | 378 | } |
| 372 | 379 | ||
| 373 | /** | 380 | ResultCode CreateDirectoryFromArchive(Handle archive_handle, const FileSys::Path& path) { |
| 374 | * Create a Directory from an Archive | ||
| 375 | * @param archive_handle Handle to an open Archive object | ||
| 376 | * @param path Path to the Directory inside of the Archive | ||
| 377 | * @return Whether creation succeeded | ||
| 378 | */ | ||
| 379 | Result CreateDirectoryFromArchive(Handle archive_handle, const FileSys::Path& path) { | ||
| 380 | Archive* archive = Kernel::g_object_pool.GetFast<Archive>(archive_handle); | 381 | Archive* archive = Kernel::g_object_pool.GetFast<Archive>(archive_handle); |
| 381 | if (archive == nullptr) | 382 | if (archive == nullptr) |
| 382 | return -1; | 383 | return InvalidHandle(ErrorModule::FS); |
| 383 | if (archive->backend->CreateDirectory(path)) | 384 | if (archive->backend->CreateDirectory(path)) |
| 384 | return 0; | 385 | return RESULT_SUCCESS; |
| 385 | return -1; | 386 | return ResultCode(ErrorDescription::NoData, ErrorModule::FS, // TODO: verify description |
| 387 | ErrorSummary::Canceled, ErrorLevel::Status); | ||
| 388 | } | ||
| 389 | |||
| 390 | ResultCode RenameDirectoryBetweenArchives(Handle src_archive_handle, const FileSys::Path& src_path, | ||
| 391 | Handle dest_archive_handle, const FileSys::Path& dest_path) { | ||
| 392 | Archive* src_archive = Kernel::g_object_pool.GetFast<Archive>(src_archive_handle); | ||
| 393 | Archive* dest_archive = Kernel::g_object_pool.GetFast<Archive>(dest_archive_handle); | ||
| 394 | if (src_archive == nullptr || dest_archive == nullptr) | ||
| 395 | return InvalidHandle(ErrorModule::FS); | ||
| 396 | if (src_archive == dest_archive) { | ||
| 397 | if (src_archive->backend->RenameDirectory(src_path, dest_path)) | ||
| 398 | return RESULT_SUCCESS; | ||
| 399 | } else { | ||
| 400 | // TODO: Implement renaming across archives | ||
| 401 | return UnimplementedFunction(ErrorModule::FS); | ||
| 402 | } | ||
| 403 | return ResultCode(ErrorDescription::NoData, ErrorModule::FS, // TODO: verify description | ||
| 404 | ErrorSummary::NothingHappened, ErrorLevel::Status); | ||
| 386 | } | 405 | } |
| 387 | 406 | ||
| 388 | /** | 407 | /** |
diff --git a/src/core/hle/kernel/archive.h b/src/core/hle/kernel/archive.h index 6fc4f0f25..b50833a2b 100644 --- a/src/core/hle/kernel/archive.h +++ b/src/core/hle/kernel/archive.h | |||
| @@ -50,7 +50,18 @@ ResultVal<Handle> OpenFileFromArchive(Handle archive_handle, const FileSys::Path | |||
| 50 | * @param path Path to the File inside of the Archive | 50 | * @param path Path to the File inside of the Archive |
| 51 | * @return Whether deletion succeeded | 51 | * @return Whether deletion succeeded |
| 52 | */ | 52 | */ |
| 53 | Result DeleteFileFromArchive(Handle archive_handle, const FileSys::Path& path); | 53 | ResultCode DeleteFileFromArchive(Handle archive_handle, const FileSys::Path& path); |
| 54 | |||
| 55 | /** | ||
| 56 | * Rename a File between two Archives | ||
| 57 | * @param src_archive_handle Handle to the source Archive object | ||
| 58 | * @param src_path Path to the File inside of the source Archive | ||
| 59 | * @param dest_archive_handle Handle to the destination Archive object | ||
| 60 | * @param dest_path Path to the File inside of the destination Archive | ||
| 61 | * @return Whether rename succeeded | ||
| 62 | */ | ||
| 63 | ResultCode RenameFileBetweenArchives(Handle src_archive_handle, const FileSys::Path& src_path, | ||
| 64 | Handle dest_archive_handle, const FileSys::Path& dest_path); | ||
| 54 | 65 | ||
| 55 | /** | 66 | /** |
| 56 | * Delete a Directory from an Archive | 67 | * Delete a Directory from an Archive |
| @@ -58,7 +69,7 @@ Result DeleteFileFromArchive(Handle archive_handle, const FileSys::Path& path); | |||
| 58 | * @param path Path to the Directory inside of the Archive | 69 | * @param path Path to the Directory inside of the Archive |
| 59 | * @return Whether deletion succeeded | 70 | * @return Whether deletion succeeded |
| 60 | */ | 71 | */ |
| 61 | Result DeleteDirectoryFromArchive(Handle archive_handle, const FileSys::Path& path); | 72 | ResultCode DeleteDirectoryFromArchive(Handle archive_handle, const FileSys::Path& path); |
| 62 | 73 | ||
| 63 | /** | 74 | /** |
| 64 | * Create a Directory from an Archive | 75 | * Create a Directory from an Archive |
| @@ -66,7 +77,18 @@ Result DeleteDirectoryFromArchive(Handle archive_handle, const FileSys::Path& pa | |||
| 66 | * @param path Path to the Directory inside of the Archive | 77 | * @param path Path to the Directory inside of the Archive |
| 67 | * @return Whether creation of directory succeeded | 78 | * @return Whether creation of directory succeeded |
| 68 | */ | 79 | */ |
| 69 | Result CreateDirectoryFromArchive(Handle archive_handle, const FileSys::Path& path); | 80 | ResultCode CreateDirectoryFromArchive(Handle archive_handle, const FileSys::Path& path); |
| 81 | |||
| 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 | ResultCode RenameDirectoryBetweenArchives(Handle src_archive_handle, const FileSys::Path& src_path, | ||
| 91 | Handle dest_archive_handle, const FileSys::Path& dest_path); | ||
| 70 | 92 | ||
| 71 | /** | 93 | /** |
| 72 | * Open a Directory from an Archive | 94 | * Open a Directory from an Archive |