diff options
| author | 2015-10-18 15:52:37 -0700 | |
|---|---|---|
| committer | 2015-10-27 23:33:59 -0700 | |
| commit | 5dfd2dba70b15cead6358b40b980d5be1b32039e (patch) | |
| tree | bda933874f35988982444c9e4e934fe64a6e0a9c /src | |
| 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')
| -rw-r--r-- | src/core/file_sys/archive_backend.h | 6 | ||||
| -rw-r--r-- | src/core/file_sys/disk_archive.cpp | 5 | ||||
| -rw-r--r-- | src/core/file_sys/disk_archive.h | 1 | ||||
| -rw-r--r-- | src/core/file_sys/ivfc_archive.cpp | 5 | ||||
| -rw-r--r-- | src/core/file_sys/ivfc_archive.h | 1 | ||||
| -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 |
8 files changed, 60 insertions, 1 deletions
diff --git a/src/core/file_sys/archive_backend.h b/src/core/file_sys/archive_backend.h index c6a1be79d..e7a59a1ed 100644 --- a/src/core/file_sys/archive_backend.h +++ b/src/core/file_sys/archive_backend.h | |||
| @@ -131,6 +131,12 @@ public: | |||
| 131 | * @return Opened directory, or nullptr | 131 | * @return Opened directory, or nullptr |
| 132 | */ | 132 | */ |
| 133 | virtual std::unique_ptr<DirectoryBackend> OpenDirectory(const Path& path) const = 0; | 133 | virtual std::unique_ptr<DirectoryBackend> OpenDirectory(const Path& path) const = 0; |
| 134 | |||
| 135 | /** | ||
| 136 | * Get the free space | ||
| 137 | * @return The number of free bytes in the archive | ||
| 138 | */ | ||
| 139 | virtual u64 GetFreeBytes() const = 0; | ||
| 134 | }; | 140 | }; |
| 135 | 141 | ||
| 136 | class ArchiveFactory : NonCopyable { | 142 | class ArchiveFactory : NonCopyable { |
diff --git a/src/core/file_sys/disk_archive.cpp b/src/core/file_sys/disk_archive.cpp index e9ecd2b1c..0ba502200 100644 --- a/src/core/file_sys/disk_archive.cpp +++ b/src/core/file_sys/disk_archive.cpp | |||
| @@ -74,6 +74,11 @@ std::unique_ptr<DirectoryBackend> DiskArchive::OpenDirectory(const Path& path) c | |||
| 74 | return std::move(directory); | 74 | return std::move(directory); |
| 75 | } | 75 | } |
| 76 | 76 | ||
| 77 | u64 DiskArchive::GetFreeBytes() const { | ||
| 78 | // TODO: Stubbed to return 1GiB | ||
| 79 | return 1024 * 1024 * 1024; | ||
| 80 | } | ||
| 81 | |||
| 77 | //////////////////////////////////////////////////////////////////////////////////////////////////// | 82 | //////////////////////////////////////////////////////////////////////////////////////////////////// |
| 78 | 83 | ||
| 79 | DiskFile::DiskFile(const DiskArchive& archive, const Path& path, const Mode mode) { | 84 | DiskFile::DiskFile(const DiskArchive& archive, const Path& path, const Mode mode) { |
diff --git a/src/core/file_sys/disk_archive.h b/src/core/file_sys/disk_archive.h index aaac65b17..ef9a98057 100644 --- a/src/core/file_sys/disk_archive.h +++ b/src/core/file_sys/disk_archive.h | |||
| @@ -41,6 +41,7 @@ public: | |||
| 41 | bool CreateDirectory(const Path& path) const override; | 41 | bool CreateDirectory(const Path& path) const override; |
| 42 | bool RenameDirectory(const Path& src_path, const Path& dest_path) const override; | 42 | bool RenameDirectory(const Path& src_path, const Path& dest_path) const override; |
| 43 | std::unique_ptr<DirectoryBackend> OpenDirectory(const Path& path) const override; | 43 | std::unique_ptr<DirectoryBackend> OpenDirectory(const Path& path) const override; |
| 44 | u64 GetFreeBytes() const override; | ||
| 44 | 45 | ||
| 45 | protected: | 46 | protected: |
| 46 | friend class DiskFile; | 47 | friend class DiskFile; |
diff --git a/src/core/file_sys/ivfc_archive.cpp b/src/core/file_sys/ivfc_archive.cpp index 441ca9b53..2efc31a8c 100644 --- a/src/core/file_sys/ivfc_archive.cpp +++ b/src/core/file_sys/ivfc_archive.cpp | |||
| @@ -59,6 +59,11 @@ std::unique_ptr<DirectoryBackend> IVFCArchive::OpenDirectory(const Path& path) c | |||
| 59 | return Common::make_unique<IVFCDirectory>(); | 59 | return Common::make_unique<IVFCDirectory>(); |
| 60 | } | 60 | } |
| 61 | 61 | ||
| 62 | u64 IVFCArchive::GetFreeBytes() const { | ||
| 63 | LOG_WARNING(Service_FS, "Attempted to get the free space in an IVFC archive"); | ||
| 64 | return 0; | ||
| 65 | } | ||
| 66 | |||
| 62 | //////////////////////////////////////////////////////////////////////////////////////////////////// | 67 | //////////////////////////////////////////////////////////////////////////////////////////////////// |
| 63 | 68 | ||
| 64 | size_t IVFCFile::Read(const u64 offset, const size_t length, u8* buffer) const { | 69 | size_t IVFCFile::Read(const u64 offset, const size_t length, u8* buffer) const { |
diff --git a/src/core/file_sys/ivfc_archive.h b/src/core/file_sys/ivfc_archive.h index c15a6c4ae..f3fd82de4 100644 --- a/src/core/file_sys/ivfc_archive.h +++ b/src/core/file_sys/ivfc_archive.h | |||
| @@ -42,6 +42,7 @@ public: | |||
| 42 | bool CreateDirectory(const Path& path) const override; | 42 | bool CreateDirectory(const Path& path) const override; |
| 43 | bool RenameDirectory(const Path& src_path, const Path& dest_path) const override; | 43 | bool RenameDirectory(const Path& src_path, const Path& dest_path) const override; |
| 44 | std::unique_ptr<DirectoryBackend> OpenDirectory(const Path& path) const override; | 44 | std::unique_ptr<DirectoryBackend> OpenDirectory(const Path& path) const override; |
| 45 | u64 GetFreeBytes() const override; | ||
| 45 | 46 | ||
| 46 | protected: | 47 | protected: |
| 47 | std::shared_ptr<FileUtil::IOFile> romfs_file; | 48 | std::shared_ptr<FileUtil::IOFile> romfs_file; |
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"}, |