diff options
| author | 2014-11-24 15:45:20 -0800 | |
|---|---|---|
| committer | 2014-12-03 22:50:44 -0800 | |
| commit | 139a4d91d9e8482d8ceeef591b08ab20b0f7e8ee (patch) | |
| tree | c30714dea3bff0ac20e171509427fabfec26ba17 /src/core/hle/kernel/archive.cpp | |
| parent | Implemented RenameDirectory in FS:USER (diff) | |
| download | yuzu-139a4d91d9e8482d8ceeef591b08ab20b0f7e8ee.tar.gz yuzu-139a4d91d9e8482d8ceeef591b08ab20b0f7e8ee.tar.xz yuzu-139a4d91d9e8482d8ceeef591b08ab20b0f7e8ee.zip | |
Updated archive.cpp functions for proper error handling
Diffstat (limited to 'src/core/hle/kernel/archive.cpp')
| -rw-r--r-- | src/core/hle/kernel/archive.cpp | 87 |
1 files changed, 29 insertions, 58 deletions
diff --git a/src/core/hle/kernel/archive.cpp b/src/core/hle/kernel/archive.cpp index bffe59952..647f0dea9 100644 --- a/src/core/hle/kernel/archive.cpp +++ b/src/core/hle/kernel/archive.cpp | |||
| @@ -340,97 +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 | * Rename a File between two Archives | 354 | Handle dest_archive_handle, const FileSys::Path& dest_path) { |
| 360 | * @param src_archive_handle Handle to the source Archive object | ||
| 361 | * @param src_path Path to the File inside of the source Archive | ||
| 362 | * @param dest_archive_handle Handle to the destination Archive object | ||
| 363 | * @param dest_path Path to the File inside of the destination Archive | ||
| 364 | * @return Whether rename succeeded | ||
| 365 | */ | ||
| 366 | Result RenameFileBetweenArchives(Handle src_archive_handle, const FileSys::Path& src_path, | ||
| 367 | Handle dest_archive_handle, const FileSys::Path& dest_path) { | ||
| 368 | Archive* src_archive = Kernel::g_object_pool.GetFast<Archive>(src_archive_handle); | 355 | Archive* src_archive = Kernel::g_object_pool.GetFast<Archive>(src_archive_handle); |
| 369 | Archive* dest_archive = Kernel::g_object_pool.GetFast<Archive>(dest_archive_handle); | 356 | Archive* dest_archive = Kernel::g_object_pool.GetFast<Archive>(dest_archive_handle); |
| 370 | if (src_archive == nullptr || dest_archive == nullptr) | 357 | if (src_archive == nullptr || dest_archive == nullptr) |
| 371 | return -1; | 358 | return InvalidHandle(ErrorModule::FS); |
| 372 | if (src_archive == dest_archive) { | 359 | if (src_archive == dest_archive) { |
| 373 | if (src_archive->backend->RenameFile(src_path, dest_path)) | 360 | if (src_archive->backend->RenameFile(src_path, dest_path)) |
| 374 | return 0; | 361 | return RESULT_SUCCESS; |
| 375 | } else { | 362 | } else { |
| 376 | // TODO: Implement renaming across archives | 363 | // TODO: Implement renaming across archives |
| 377 | return -1; | 364 | return UnimplementedFunction(ErrorModule::FS); |
| 378 | } | 365 | } |
| 379 | return -1; | 366 | return ResultCode(ErrorDescription::NoData, ErrorModule::FS, // TODO: verify description |
| 367 | ErrorSummary::NothingHappened, ErrorLevel::Status); | ||
| 380 | } | 368 | } |
| 381 | 369 | ||
| 382 | /** | 370 | ResultCode DeleteDirectoryFromArchive(Handle archive_handle, const FileSys::Path& path) { |
| 383 | * Delete a Directory from an Archive | ||
| 384 | * @param archive_handle Handle to an open Archive object | ||
| 385 | * @param path Path to the Directory inside of the Archive | ||
| 386 | * @return Whether deletion succeeded | ||
| 387 | */ | ||
| 388 | Result DeleteDirectoryFromArchive(Handle archive_handle, const FileSys::Path& path) { | ||
| 389 | Archive* archive = Kernel::g_object_pool.GetFast<Archive>(archive_handle); | 371 | Archive* archive = Kernel::g_object_pool.GetFast<Archive>(archive_handle); |
| 390 | if (archive == nullptr) | 372 | if (archive == nullptr) |
| 391 | return -1; | 373 | return InvalidHandle(ErrorModule::FS); |
| 392 | if (archive->backend->DeleteDirectory(path)) | 374 | if (archive->backend->DeleteDirectory(path)) |
| 393 | return 0; | 375 | return RESULT_SUCCESS; |
| 394 | return -1; | 376 | return ResultCode(ErrorDescription::NoData, ErrorModule::FS, // TODO: verify description |
| 377 | ErrorSummary::Canceled, ErrorLevel::Status); | ||
| 395 | } | 378 | } |
| 396 | 379 | ||
| 397 | /** | 380 | ResultCode CreateDirectoryFromArchive(Handle archive_handle, const FileSys::Path& path) { |
| 398 | * Create a Directory from an Archive | ||
| 399 | * @param archive_handle Handle to an open Archive object | ||
| 400 | * @param path Path to the Directory inside of the Archive | ||
| 401 | * @return Whether creation succeeded | ||
| 402 | */ | ||
| 403 | Result CreateDirectoryFromArchive(Handle archive_handle, const FileSys::Path& path) { | ||
| 404 | Archive* archive = Kernel::g_object_pool.GetFast<Archive>(archive_handle); | 381 | Archive* archive = Kernel::g_object_pool.GetFast<Archive>(archive_handle); |
| 405 | if (archive == nullptr) | 382 | if (archive == nullptr) |
| 406 | return -1; | 383 | return InvalidHandle(ErrorModule::FS); |
| 407 | if (archive->backend->CreateDirectory(path)) | 384 | if (archive->backend->CreateDirectory(path)) |
| 408 | return 0; | 385 | return RESULT_SUCCESS; |
| 409 | return -1; | 386 | return ResultCode(ErrorDescription::NoData, ErrorModule::FS, // TODO: verify description |
| 387 | ErrorSummary::Canceled, ErrorLevel::Status); | ||
| 410 | } | 388 | } |
| 411 | 389 | ||
| 412 | /** | 390 | ResultCode RenameDirectoryBetweenArchives(Handle src_archive_handle, const FileSys::Path& src_path, |
| 413 | * Rename a Directory between two Archives | 391 | Handle dest_archive_handle, const FileSys::Path& dest_path) { |
| 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); | 392 | 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); | 393 | Archive* dest_archive = Kernel::g_object_pool.GetFast<Archive>(dest_archive_handle); |
| 424 | if (src_archive == nullptr || dest_archive == nullptr) | 394 | if (src_archive == nullptr || dest_archive == nullptr) |
| 425 | return -1; | 395 | return InvalidHandle(ErrorModule::FS); |
| 426 | if (src_archive == dest_archive) { | 396 | if (src_archive == dest_archive) { |
| 427 | if (src_archive->backend->RenameDirectory(src_path, dest_path)) | 397 | if (src_archive->backend->RenameDirectory(src_path, dest_path)) |
| 428 | return 0; | 398 | return RESULT_SUCCESS; |
| 429 | } else { | 399 | } else { |
| 430 | // TODO: Implement renaming across archives | 400 | // TODO: Implement renaming across archives |
| 431 | return -1; | 401 | return UnimplementedFunction(ErrorModule::FS); |
| 432 | } | 402 | } |
| 433 | return -1; | 403 | return ResultCode(ErrorDescription::NoData, ErrorModule::FS, // TODO: verify description |
| 404 | ErrorSummary::NothingHappened, ErrorLevel::Status); | ||
| 434 | } | 405 | } |
| 435 | 406 | ||
| 436 | /** | 407 | /** |