diff options
| author | 2014-12-04 22:07:47 -0500 | |
|---|---|---|
| committer | 2014-12-04 22:07:47 -0500 | |
| commit | 5056329a8003115f61859b97c2fc6ef2f460a0d3 (patch) | |
| tree | 9434ac214d06a5d55ff20848f57cb981647991dc /src/core/hle/kernel/archive.cpp | |
| parent | Merge pull request #248 from lioncash/kernel (diff) | |
| parent | Updated archive.cpp functions for proper error handling (diff) | |
| download | yuzu-5056329a8003115f61859b97c2fc6ef2f460a0d3.tar.gz yuzu-5056329a8003115f61859b97c2fc6ef2f460a0d3.tar.xz yuzu-5056329a8003115f61859b97c2fc6ef2f460a0d3.zip | |
Merge pull request #222 from archshift/renamexyz
Implemented RenameFile and RenameDirectory in FS:USER
Diffstat (limited to 'src/core/hle/kernel/archive.cpp')
| -rw-r--r-- | src/core/hle/kernel/archive.cpp | 79 |
1 files changed, 49 insertions, 30 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 | /** |