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/file_sys | |
| 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/file_sys')
| -rw-r--r-- | src/core/file_sys/archive.h | 19 | ||||
| -rw-r--r-- | src/core/file_sys/archive_romfs.cpp | 27 | ||||
| -rw-r--r-- | src/core/file_sys/archive_romfs.h | 19 |
3 files changed, 57 insertions, 8 deletions
diff --git a/src/core/file_sys/archive.h b/src/core/file_sys/archive.h index ed2d83640..ac5630bea 100644 --- a/src/core/file_sys/archive.h +++ b/src/core/file_sys/archive.h | |||
| @@ -37,18 +37,33 @@ public: | |||
| 37 | 37 | ||
| 38 | /** | 38 | /** |
| 39 | * Read data from the archive | 39 | * Read data from the archive |
| 40 | * @param offset Offset in bytes to start reading archive from | 40 | * @param offset Offset in bytes to start reading data from |
| 41 | * @param length Length in bytes to read data from archive | 41 | * @param length Length in bytes of data to read from archive |
| 42 | * @param buffer Buffer to read data into | 42 | * @param buffer Buffer to read data into |
| 43 | * @return Number of bytes read | 43 | * @return Number of bytes read |
| 44 | */ | 44 | */ |
| 45 | virtual size_t Read(const u64 offset, const u32 length, u8* buffer) const = 0; | 45 | virtual size_t Read(const u64 offset, const u32 length, u8* buffer) const = 0; |
| 46 | 46 | ||
| 47 | /** | 47 | /** |
| 48 | * Write data to the archive | ||
| 49 | * @param offset Offset in bytes to start writing data to | ||
| 50 | * @param length Length in bytes of data to write to archive | ||
| 51 | * @param buffer Buffer to write data from | ||
| 52 | * @param flush The flush parameters (0 == do not flush) | ||
| 53 | * @return Number of bytes written | ||
| 54 | */ | ||
| 55 | virtual size_t Write(const u64 offset, const u32 length, const u32 flush, u8* buffer) = 0; | ||
| 56 | |||
| 57 | /** | ||
| 48 | * Get the size of the archive in bytes | 58 | * Get the size of the archive in bytes |
| 49 | * @return Size of the archive in bytes | 59 | * @return Size of the archive in bytes |
| 50 | */ | 60 | */ |
| 51 | virtual size_t GetSize() const = 0; | 61 | virtual size_t GetSize() const = 0; |
| 62 | |||
| 63 | /** | ||
| 64 | * Set the size of the archive in bytes | ||
| 65 | */ | ||
| 66 | virtual void SetSize(const u64 size) = 0; | ||
| 52 | }; | 67 | }; |
| 53 | 68 | ||
| 54 | } // namespace FileSys | 69 | } // namespace FileSys |
diff --git a/src/core/file_sys/archive_romfs.cpp b/src/core/file_sys/archive_romfs.cpp index fd84b9c8c..dc3fb1807 100644 --- a/src/core/file_sys/archive_romfs.cpp +++ b/src/core/file_sys/archive_romfs.cpp | |||
| @@ -23,8 +23,8 @@ Archive_RomFS::~Archive_RomFS() { | |||
| 23 | 23 | ||
| 24 | /** | 24 | /** |
| 25 | * Read data from the archive | 25 | * Read data from the archive |
| 26 | * @param offset Offset in bytes to start reading archive from | 26 | * @param offset Offset in bytes to start reading data from |
| 27 | * @param length Length in bytes to read data from archive | 27 | * @param length Length in bytes of data to read from archive |
| 28 | * @param buffer Buffer to read data into | 28 | * @param buffer Buffer to read data into |
| 29 | * @return Number of bytes read | 29 | * @return Number of bytes read |
| 30 | */ | 30 | */ |
| @@ -35,12 +35,31 @@ size_t Archive_RomFS::Read(const u64 offset, const u32 length, u8* buffer) const | |||
| 35 | } | 35 | } |
| 36 | 36 | ||
| 37 | /** | 37 | /** |
| 38 | * Write data to the archive | ||
| 39 | * @param offset Offset in bytes to start writing data to | ||
| 40 | * @param length Length in bytes of data to write to archive | ||
| 41 | * @param buffer Buffer to write data from | ||
| 42 | * @param flush The flush parameters (0 == do not flush) | ||
| 43 | * @return Number of bytes written | ||
| 44 | */ | ||
| 45 | size_t Archive_RomFS::Write(const u64 offset, const u32 length, const u32 flush, u8* buffer) { | ||
| 46 | ERROR_LOG(FILESYS, "Attempted to write to ROMFS."); | ||
| 47 | return 0; | ||
| 48 | } | ||
| 49 | |||
| 50 | /** | ||
| 38 | * Get the size of the archive in bytes | 51 | * Get the size of the archive in bytes |
| 39 | * @return Size of the archive in bytes | 52 | * @return Size of the archive in bytes |
| 40 | */ | 53 | */ |
| 41 | size_t Archive_RomFS::GetSize() const { | 54 | size_t Archive_RomFS::GetSize() const { |
| 42 | ERROR_LOG(FILESYS, "(UNIMPLEMENTED)"); | 55 | return sizeof(u8) * raw_data.size(); |
| 43 | return 0; | 56 | } |
| 57 | |||
| 58 | /** | ||
| 59 | * Set the size of the archive in bytes | ||
| 60 | */ | ||
| 61 | void Archive_RomFS::SetSize(const u64 size) { | ||
| 62 | ERROR_LOG(FILESYS, "Attempted to set the size of ROMFS"); | ||
| 44 | } | 63 | } |
| 45 | 64 | ||
| 46 | } // namespace FileSys | 65 | } // namespace FileSys |
diff --git a/src/core/file_sys/archive_romfs.h b/src/core/file_sys/archive_romfs.h index 8a31190a9..e9ed6f77a 100644 --- a/src/core/file_sys/archive_romfs.h +++ b/src/core/file_sys/archive_romfs.h | |||
| @@ -30,18 +30,33 @@ public: | |||
| 30 | 30 | ||
| 31 | /** | 31 | /** |
| 32 | * Read data from the archive | 32 | * Read data from the archive |
| 33 | * @param offset Offset in bytes to start reading archive from | 33 | * @param offset Offset in bytes to start reading data from |
| 34 | * @param length Length in bytes to read data from archive | 34 | * @param length Length in bytes of data to read from archive |
| 35 | * @param buffer Buffer to read data into | 35 | * @param buffer Buffer to read data into |
| 36 | * @return Number of bytes read | 36 | * @return Number of bytes read |
| 37 | */ | 37 | */ |
| 38 | size_t Read(const u64 offset, const u32 length, u8* buffer) const override; | 38 | size_t Read(const u64 offset, const u32 length, u8* buffer) const override; |
| 39 | 39 | ||
| 40 | /** | 40 | /** |
| 41 | * Write data to the archive | ||
| 42 | * @param offset Offset in bytes to start writing data to | ||
| 43 | * @param length Length in bytes of data to write to archive | ||
| 44 | * @param buffer Buffer to write data from | ||
| 45 | * @param flush The flush parameters (0 == do not flush) | ||
| 46 | * @return Number of bytes written | ||
| 47 | */ | ||
| 48 | size_t Write(const u64 offset, const u32 length, const u32 flush, u8* buffer) override; | ||
| 49 | |||
| 50 | /** | ||
| 41 | * Get the size of the archive in bytes | 51 | * Get the size of the archive in bytes |
| 42 | * @return Size of the archive in bytes | 52 | * @return Size of the archive in bytes |
| 43 | */ | 53 | */ |
| 44 | size_t GetSize() const override; | 54 | size_t GetSize() const override; |
| 55 | |||
| 56 | /** | ||
| 57 | * Set the size of the archive in bytes | ||
| 58 | */ | ||
| 59 | void SetSize(const u64 size) override; | ||
| 45 | 60 | ||
| 46 | private: | 61 | private: |
| 47 | std::vector<u8> raw_data; | 62 | std::vector<u8> raw_data; |