FS.Archive: Clean up treatment of archives and their handles

- Refactor FS::Archive internals to make Archive creation and lifetime
  management clearer.
- Remove the "Archive as a File" hack.
- Implement 64-bit Archive handles.
This commit is contained in:
Yuri Kunde Schlesner
2014-12-15 06:41:02 -02:00
parent 0931a42af0
commit 83e6e4ffec
11 changed files with 208 additions and 398 deletions

View File

@ -5,24 +5,19 @@
#include "common/common_types.h"
#include "core/file_sys/file_romfs.h"
#include "core/file_sys/archive_romfs.h"
////////////////////////////////////////////////////////////////////////////////////////////////////
// FileSys namespace
namespace FileSys {
File_RomFS::File_RomFS() {
}
File_RomFS::~File_RomFS() {
}
/**
* Open the file
* @return true if the file opened correctly
*/
bool File_RomFS::Open() {
return false;
return true;
}
/**
@ -33,7 +28,9 @@ bool File_RomFS::Open() {
* @return Number of bytes read
*/
size_t File_RomFS::Read(const u64 offset, const u32 length, u8* buffer) const {
return -1;
LOG_TRACE(Service_FS, "called offset=%llu, length=%d", offset, length);
memcpy(buffer, &archive->raw_data[(u32)offset], length);
return length;
}
/**
@ -45,7 +42,8 @@ size_t File_RomFS::Read(const u64 offset, const u32 length, u8* buffer) const {
* @return Number of bytes written
*/
size_t File_RomFS::Write(const u64 offset, const u32 length, const u32 flush, const u8* buffer) const {
return -1;
LOG_WARNING(Service_FS, "Attempted to write to ROMFS.");
return 0;
}
/**
@ -53,7 +51,7 @@ size_t File_RomFS::Write(const u64 offset, const u32 length, const u32 flush, co
* @return Size of the file in bytes
*/
size_t File_RomFS::GetSize() const {
return -1;
return sizeof(u8) * archive->raw_data.size();
}
/**
@ -62,6 +60,7 @@ size_t File_RomFS::GetSize() const {
* @return true if successful
*/
bool File_RomFS::SetSize(const u64 size) const {
LOG_WARNING(Service_FS, "Attempted to set the size of ROMFS");
return false;
}