mirror of
https://github.com/citra-emu/citra.git
synced 2024-11-23 05:10:10 +00:00
Added Write() function to Archive and Archive_RomFS
This commit is contained in:
parent
2386764756
commit
4b94f103dc
@ -44,6 +44,15 @@ public:
|
||||
*/
|
||||
virtual size_t Read(const u64 offset, const u32 length, u8* buffer) const = 0;
|
||||
|
||||
/**
|
||||
* Write data to the archive
|
||||
* @param offset Offset in bytes to start writing archive to
|
||||
* @param length Length in bytes to write data to archive
|
||||
* @param buffer Buffer to write data from
|
||||
* @return Number of bytes written
|
||||
*/
|
||||
virtual size_t Write(const u64 offset, const u32 length, u8* buffer) = 0;
|
||||
|
||||
/**
|
||||
* Get the size of the archive in bytes
|
||||
* @return Size of the archive in bytes
|
||||
|
@ -34,6 +34,21 @@ size_t Archive_RomFS::Read(const u64 offset, const u32 length, u8* buffer) const
|
||||
return length;
|
||||
}
|
||||
|
||||
/**
|
||||
* Write data to the archive
|
||||
* @param offset Offset in bytes to start writing archive to
|
||||
* @param length Length in bytes to write data to archive
|
||||
* @param buffer Buffer to write data from
|
||||
* @return Number of bytes written
|
||||
*/
|
||||
size_t Archive_RomFS::Write(const u64 offset, const u32 length, u8* buffer) {
|
||||
DEBUG_LOG(FILESYS, "called offset=%d, length=%d", offset, length);
|
||||
|
||||
raw_data.reserve(offset + length);
|
||||
raw_data.insert(raw_data.begin() + offset, buffer, buffer + length);
|
||||
return length;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the size of the archive in bytes
|
||||
* @return Size of the archive in bytes
|
||||
|
@ -37,6 +37,15 @@ public:
|
||||
*/
|
||||
size_t Read(const u64 offset, const u32 length, u8* buffer) const override;
|
||||
|
||||
/**
|
||||
* Write data to the archive
|
||||
* @param offset Offset in bytes to start writing archive to
|
||||
* @param length Length in bytes to write data to archive
|
||||
* @param buffer Buffer to write data from
|
||||
* @return Number of bytes written
|
||||
*/
|
||||
size_t Write(const u64 offset, const u32 length, u8* buffer) override;
|
||||
|
||||
/**
|
||||
* Get the size of the archive in bytes
|
||||
* @return Size of the archive in bytes
|
||||
|
@ -48,8 +48,8 @@ public:
|
||||
Result SyncRequest(bool* wait) {
|
||||
u32* cmd_buff = Service::GetCommandBuffer();
|
||||
FileCommand cmd = static_cast<FileCommand>(cmd_buff[0]);
|
||||
|
||||
switch (cmd) {
|
||||
|
||||
// Read from archive...
|
||||
case FileCommand::Read:
|
||||
{
|
||||
@ -59,12 +59,22 @@ public:
|
||||
cmd_buff[2] = backend->Read(offset, length, Memory::GetPointer(address));
|
||||
break;
|
||||
}
|
||||
|
||||
// Write to archive...
|
||||
case FileCommand::Write:
|
||||
{
|
||||
u64 offset = cmd_buff[1] | ((u64) cmd_buff[2]) << 32;
|
||||
u32 length = cmd_buff[3];
|
||||
u32 address = cmd_buff[5];
|
||||
cmd_buff[2] = backend->Write(offset, length, Memory::GetPointer(address));
|
||||
break;
|
||||
}
|
||||
// Unknown command...
|
||||
default:
|
||||
{
|
||||
ERROR_LOG(KERNEL, "Unknown command=0x%08X!", cmd);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
cmd_buff[1] = 0; // No error
|
||||
return 0;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user