|
|
@ -16,15 +16,12 @@
|
|
|
|
|
|
|
|
|
|
|
|
namespace FileSys {
|
|
|
|
namespace FileSys {
|
|
|
|
|
|
|
|
|
|
|
|
IVFCArchive::IVFCArchive(std::shared_ptr<const std::vector<u8>> data) : data(data) {
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
std::string IVFCArchive::GetName() const {
|
|
|
|
std::string IVFCArchive::GetName() const {
|
|
|
|
return "IVFC";
|
|
|
|
return "IVFC";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
std::unique_ptr<FileBackend> IVFCArchive::OpenFile(const Path& path, const Mode mode) const {
|
|
|
|
std::unique_ptr<FileBackend> IVFCArchive::OpenFile(const Path& path, const Mode mode) const {
|
|
|
|
return Common::make_unique<IVFCFile>(data);
|
|
|
|
return Common::make_unique<IVFCFile>(romfs_file, data_offset, data_size);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool IVFCArchive::DeleteFile(const Path& path) const {
|
|
|
|
bool IVFCArchive::DeleteFile(const Path& path) const {
|
|
|
@ -66,8 +63,10 @@ std::unique_ptr<DirectoryBackend> IVFCArchive::OpenDirectory(const Path& path) c
|
|
|
|
|
|
|
|
|
|
|
|
size_t IVFCFile::Read(const u64 offset, const u32 length, u8* buffer) const {
|
|
|
|
size_t IVFCFile::Read(const u64 offset, const u32 length, u8* buffer) const {
|
|
|
|
LOG_TRACE(Service_FS, "called offset=%llu, length=%d", offset, length);
|
|
|
|
LOG_TRACE(Service_FS, "called offset=%llu, length=%d", offset, length);
|
|
|
|
memcpy(buffer, data->data() + offset, length);
|
|
|
|
romfs_file->Seek(data_offset + offset, SEEK_SET);
|
|
|
|
return length;
|
|
|
|
u32 read_length = (u32)std::min((u64)length, data_size - offset);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return romfs_file->ReadBytes(buffer, read_length);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
size_t IVFCFile::Write(const u64 offset, const u32 length, const u32 flush, const u8* buffer) const {
|
|
|
|
size_t IVFCFile::Write(const u64 offset, const u32 length, const u32 flush, const u8* buffer) const {
|
|
|
@ -76,7 +75,7 @@ size_t IVFCFile::Write(const u64 offset, const u32 length, const u32 flush, cons
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
size_t IVFCFile::GetSize() const {
|
|
|
|
size_t IVFCFile::GetSize() const {
|
|
|
|
return sizeof(u8) * data->size();
|
|
|
|
return data_size; // TODO: return value will overflow on 32-bit machines
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool IVFCFile::SetSize(const u64 size) const {
|
|
|
|
bool IVFCFile::SetSize(const u64 size) const {
|
|
|
|