diff options
| author | 2014-08-20 22:03:31 -0700 | |
|---|---|---|
| committer | 2014-08-22 15:45:10 -0700 | |
| commit | 4c4a01bf413eab37394e76683790cebe08d57922 (patch) | |
| tree | 850d82660ff575580012161f2c1c47403ef20365 /src/core/hle/kernel/archive.cpp | |
| parent | Merge pull request #62 from archshift/revert-49-redundantloop (diff) | |
| download | yuzu-4c4a01bf413eab37394e76683790cebe08d57922.tar.gz yuzu-4c4a01bf413eab37394e76683790cebe08d57922.tar.xz yuzu-4c4a01bf413eab37394e76683790cebe08d57922.zip | |
Added FS functions to Archive and Archive_RomFS
Diffstat (limited to 'src/core/hle/kernel/archive.cpp')
| -rw-r--r-- | src/core/hle/kernel/archive.cpp | 34 |
1 files changed, 31 insertions, 3 deletions
diff --git a/src/core/hle/kernel/archive.cpp b/src/core/hle/kernel/archive.cpp index 5079fcb84..1596367c3 100644 --- a/src/core/hle/kernel/archive.cpp +++ b/src/core/hle/kernel/archive.cpp | |||
| @@ -3,6 +3,7 @@ | |||
| 3 | // Refer to the license.txt file included. | 3 | // Refer to the license.txt file included. |
| 4 | 4 | ||
| 5 | #include "common/common_types.h" | 5 | #include "common/common_types.h" |
| 6 | #include "common/math_util.h" | ||
| 6 | 7 | ||
| 7 | #include "core/file_sys/archive.h" | 8 | #include "core/file_sys/archive.h" |
| 8 | #include "core/hle/service/service.h" | 9 | #include "core/hle/service/service.h" |
| @@ -48,23 +49,50 @@ public: | |||
| 48 | Result SyncRequest(bool* wait) { | 49 | Result SyncRequest(bool* wait) { |
| 49 | u32* cmd_buff = Service::GetCommandBuffer(); | 50 | u32* cmd_buff = Service::GetCommandBuffer(); |
| 50 | FileCommand cmd = static_cast<FileCommand>(cmd_buff[0]); | 51 | FileCommand cmd = static_cast<FileCommand>(cmd_buff[0]); |
| 52 | |||
| 51 | switch (cmd) { | 53 | switch (cmd) { |
| 52 | |||
| 53 | // Read from archive... | 54 | // Read from archive... |
| 54 | case FileCommand::Read: | 55 | case FileCommand::Read: |
| 55 | { | 56 | { |
| 56 | u64 offset = cmd_buff[1] | ((u64) cmd_buff[2]) << 32; | 57 | u64 offset = cmd_buff[1] | ((u64)cmd_buff[2] << 32); |
| 57 | u32 length = cmd_buff[3]; | 58 | u32 length = cmd_buff[3]; |
| 58 | u32 address = cmd_buff[5]; | 59 | u32 address = cmd_buff[5]; |
| 60 | |||
| 61 | // Number of bytes read | ||
| 59 | cmd_buff[2] = backend->Read(offset, length, Memory::GetPointer(address)); | 62 | cmd_buff[2] = backend->Read(offset, length, Memory::GetPointer(address)); |
| 60 | break; | 63 | break; |
| 61 | } | 64 | } |
| 65 | // Write to archive... | ||
| 66 | case FileCommand::Write: | ||
| 67 | { | ||
| 68 | u64 offset = cmd_buff[1] | ((u64)cmd_buff[2] << 32); | ||
| 69 | u32 length = cmd_buff[3]; | ||
| 70 | u32 flush = cmd_buff[4]; | ||
| 71 | u32 address = cmd_buff[6]; | ||
| 62 | 72 | ||
| 73 | // Number of bytes written | ||
| 74 | cmd_buff[2] = backend->Write(offset, length, flush, Memory::GetPointer(address)); | ||
| 75 | break; | ||
| 76 | } | ||
| 77 | case FileCommand::GetSize: | ||
| 78 | { | ||
| 79 | u64 filesize = (u64) backend->GetSize(); | ||
| 80 | cmd_buff[2] = (u32) filesize; // Lower word | ||
| 81 | cmd_buff[3] = (u32) (filesize >> 32); // Upper word | ||
| 82 | break; | ||
| 83 | } | ||
| 84 | case FileCommand::SetSize: | ||
| 85 | { | ||
| 86 | backend->SetSize(cmd_buff[1] | ((u64)cmd_buff[2] << 32)); | ||
| 87 | break; | ||
| 88 | } | ||
| 63 | // Unknown command... | 89 | // Unknown command... |
| 64 | default: | 90 | default: |
| 91 | { | ||
| 65 | ERROR_LOG(KERNEL, "Unknown command=0x%08X!", cmd); | 92 | ERROR_LOG(KERNEL, "Unknown command=0x%08X!", cmd); |
| 66 | return -1; | 93 | return -1; |
| 67 | } | 94 | } |
| 95 | } | ||
| 68 | cmd_buff[1] = 0; // No error | 96 | cmd_buff[1] = 0; // No error |
| 69 | return 0; | 97 | return 0; |
| 70 | } | 98 | } |
| @@ -140,7 +168,7 @@ Archive* CreateArchive(Handle& handle, FileSys::Archive* backend, const std::str | |||
| 140 | */ | 168 | */ |
| 141 | Handle CreateArchive(FileSys::Archive* backend, const std::string& name) { | 169 | Handle CreateArchive(FileSys::Archive* backend, const std::string& name) { |
| 142 | Handle handle; | 170 | Handle handle; |
| 143 | Archive* archive = CreateArchive(handle, backend, name); | 171 | CreateArchive(handle, backend, name); |
| 144 | return handle; | 172 | return handle; |
| 145 | } | 173 | } |
| 146 | 174 | ||