diff options
| author | 2015-10-18 15:52:37 -0700 | |
|---|---|---|
| committer | 2015-10-27 23:33:59 -0700 | |
| commit | 5dfd2dba70b15cead6358b40b980d5be1b32039e (patch) | |
| tree | bda933874f35988982444c9e4e934fe64a6e0a9c /src/core/hle | |
| parent | Merge pull request #1194 from linkmauve/no-newline (diff) | |
| download | yuzu-5dfd2dba70b15cead6358b40b980d5be1b32039e.tar.gz yuzu-5dfd2dba70b15cead6358b40b980d5be1b32039e.tar.xz yuzu-5dfd2dba70b15cead6358b40b980d5be1b32039e.zip | |
Implement FS_User::GetFreeBytes
Diffstat (limited to 'src/core/hle')
| -rw-r--r-- | src/core/hle/service/fs/archive.cpp | 7 | ||||
| -rw-r--r-- | src/core/hle/service/fs/archive.h | 7 | ||||
| -rw-r--r-- | src/core/hle/service/fs/fs_user.cpp | 29 |
3 files changed, 42 insertions, 1 deletions
diff --git a/src/core/hle/service/fs/archive.cpp b/src/core/hle/service/fs/archive.cpp index 6c0df67c3..d64b3656a 100644 --- a/src/core/hle/service/fs/archive.cpp +++ b/src/core/hle/service/fs/archive.cpp | |||
| @@ -403,6 +403,13 @@ ResultVal<Kernel::SharedPtr<Directory>> OpenDirectoryFromArchive(ArchiveHandle a | |||
| 403 | return MakeResult<Kernel::SharedPtr<Directory>>(std::move(directory)); | 403 | return MakeResult<Kernel::SharedPtr<Directory>>(std::move(directory)); |
| 404 | } | 404 | } |
| 405 | 405 | ||
| 406 | ResultVal<u64> GetFreeBytesInArchive(ArchiveHandle archive_handle) { | ||
| 407 | ArchiveBackend* archive = GetArchive(archive_handle); | ||
| 408 | if (archive == nullptr) | ||
| 409 | return ERR_INVALID_HANDLE; | ||
| 410 | return MakeResult<u64>(archive->GetFreeBytes()); | ||
| 411 | } | ||
| 412 | |||
| 406 | ResultCode FormatArchive(ArchiveIdCode id_code, const FileSys::Path& path) { | 413 | ResultCode FormatArchive(ArchiveIdCode id_code, const FileSys::Path& path) { |
| 407 | auto archive_itr = id_code_map.find(id_code); | 414 | auto archive_itr = id_code_map.find(id_code); |
| 408 | if (archive_itr == id_code_map.end()) { | 415 | if (archive_itr == id_code_map.end()) { |
diff --git a/src/core/hle/service/fs/archive.h b/src/core/hle/service/fs/archive.h index 6f7048710..952deb4d4 100644 --- a/src/core/hle/service/fs/archive.h +++ b/src/core/hle/service/fs/archive.h | |||
| @@ -167,6 +167,13 @@ ResultVal<Kernel::SharedPtr<Directory>> OpenDirectoryFromArchive(ArchiveHandle a | |||
| 167 | const FileSys::Path& path); | 167 | const FileSys::Path& path); |
| 168 | 168 | ||
| 169 | /** | 169 | /** |
| 170 | * Get the free space in an Archive | ||
| 171 | * @param archive_handle Handle to an open Archive object | ||
| 172 | * @return The number of free bytes in the archive | ||
| 173 | */ | ||
| 174 | ResultVal<u64> GetFreeBytesInArchive(ArchiveHandle archive_handle); | ||
| 175 | |||
| 176 | /** | ||
| 170 | * Erases the contents of the physical folder that contains the archive | 177 | * Erases the contents of the physical folder that contains the archive |
| 171 | * identified by the specified id code and path | 178 | * identified by the specified id code and path |
| 172 | * @param id_code The id of the archive to format | 179 | * @param id_code The id of the archive to format |
diff --git a/src/core/hle/service/fs/fs_user.cpp b/src/core/hle/service/fs/fs_user.cpp index ae52083f9..b3fa89302 100644 --- a/src/core/hle/service/fs/fs_user.cpp +++ b/src/core/hle/service/fs/fs_user.cpp | |||
| @@ -497,6 +497,33 @@ static void FormatThisUserSaveData(Service::Interface* self) { | |||
| 497 | } | 497 | } |
| 498 | 498 | ||
| 499 | /** | 499 | /** |
| 500 | * FS_User::GetFreeBytes service function | ||
| 501 | * Inputs: | ||
| 502 | * 0: 0x08120080 | ||
| 503 | * 1: Archive handle low word | ||
| 504 | * 2: Archive handle high word | ||
| 505 | * Outputs: | ||
| 506 | * 1: Result of function, 0 on success, otherwise error code | ||
| 507 | * 2: Free byte count low word | ||
| 508 | * 3: Free byte count high word | ||
| 509 | */ | ||
| 510 | static void GetFreeBytes(Service::Interface* self) { | ||
| 511 | u32* cmd_buff = Kernel::GetCommandBuffer(); | ||
| 512 | |||
| 513 | ArchiveHandle archive_handle = MakeArchiveHandle(cmd_buff[1], cmd_buff[2]); | ||
| 514 | ResultVal<u64> bytes_res = GetFreeBytesInArchive(archive_handle); | ||
| 515 | |||
| 516 | cmd_buff[1] = bytes_res.Code().raw; | ||
| 517 | if (bytes_res.Succeeded()) { | ||
| 518 | cmd_buff[2] = (u32)*bytes_res; | ||
| 519 | cmd_buff[3] = *bytes_res >> 32; | ||
| 520 | } else { | ||
| 521 | cmd_buff[2] = 0; | ||
| 522 | cmd_buff[3] = 0; | ||
| 523 | } | ||
| 524 | } | ||
| 525 | |||
| 526 | /** | ||
| 500 | * FS_User::CreateExtSaveData service function | 527 | * FS_User::CreateExtSaveData service function |
| 501 | * Inputs: | 528 | * Inputs: |
| 502 | * 0 : 0x08510242 | 529 | * 0 : 0x08510242 |
| @@ -700,7 +727,7 @@ const Interface::FunctionInfo FunctionTable[] = { | |||
| 700 | {0x080F0180, FormatThisUserSaveData,"FormatThisUserSaveData"}, | 727 | {0x080F0180, FormatThisUserSaveData,"FormatThisUserSaveData"}, |
| 701 | {0x08100200, nullptr, "CreateSystemSaveData"}, | 728 | {0x08100200, nullptr, "CreateSystemSaveData"}, |
| 702 | {0x08110040, nullptr, "DeleteSystemSaveData"}, | 729 | {0x08110040, nullptr, "DeleteSystemSaveData"}, |
| 703 | {0x08120080, nullptr, "GetFreeBytes"}, | 730 | {0x08120080, GetFreeBytes, "GetFreeBytes"}, |
| 704 | {0x08130000, nullptr, "GetCardType"}, | 731 | {0x08130000, nullptr, "GetCardType"}, |
| 705 | {0x08140000, nullptr, "GetSdmcArchiveResource"}, | 732 | {0x08140000, nullptr, "GetSdmcArchiveResource"}, |
| 706 | {0x08150000, nullptr, "GetNandArchiveResource"}, | 733 | {0x08150000, nullptr, "GetNandArchiveResource"}, |