diff options
author | 2014-09-27 19:16:51 +0000 | |
---|---|---|
committer | 2014-10-06 19:58:37 +0200 | |
commit | 23c2fbfc7a900ae3c9f8791a87c5ad672f5778fe (patch) | |
tree | f5535cf4b4bde9054f0e1098eb1fd817b5ff1599 /src/core/file_sys | |
parent | d34673990b5176c7ab71c239694737a9ac8df14e (diff) |
FileSys/Kernel: Implement SetSize service call for File objects.
Diffstat (limited to 'src/core/file_sys')
-rw-r--r-- | src/core/file_sys/file.h | 7 | ||||
-rw-r--r-- | src/core/file_sys/file_romfs.cpp | 9 | ||||
-rw-r--r-- | src/core/file_sys/file_romfs.h | 7 | ||||
-rw-r--r-- | src/core/file_sys/file_sdmc.cpp | 11 | ||||
-rw-r--r-- | src/core/file_sys/file_sdmc.h | 7 |
5 files changed, 41 insertions, 0 deletions
diff --git a/src/core/file_sys/file.h b/src/core/file_sys/file.h index 3749e4fc..443e6531 100644 --- a/src/core/file_sys/file.h +++ b/src/core/file_sys/file.h @@ -44,6 +44,13 @@ public: virtual size_t GetSize() const = 0; /** + * Set the size of the file in bytes + * @param size New size of the file + * @return true if successful + */ + virtual bool SetSize(const u64 size) const = 0; + + /** * Close the file * @return true if the file closed correctly */ diff --git a/src/core/file_sys/file_romfs.cpp b/src/core/file_sys/file_romfs.cpp index 0709e98f..3ef616e0 100644 --- a/src/core/file_sys/file_romfs.cpp +++ b/src/core/file_sys/file_romfs.cpp @@ -49,6 +49,15 @@ size_t File_RomFS::GetSize() const { } /** + * Set the size of the file in bytes + * @param size New size of the file + * @return true if successful + */ +bool File_RomFS::SetSize(const u64 size) const { + return false; +} + +/** * Close the file * @return true if the file closed correctly */ diff --git a/src/core/file_sys/file_romfs.h b/src/core/file_sys/file_romfs.h index 28b4f115..06973eb9 100644 --- a/src/core/file_sys/file_romfs.h +++ b/src/core/file_sys/file_romfs.h @@ -45,6 +45,13 @@ public: size_t GetSize() const override; /** + * Set the size of the file in bytes + * @param size New size of the file + * @return true if successful + */ + bool SetSize(const u64 size) const override; + + /** * Close the file * @return true if the file closed correctly */ diff --git a/src/core/file_sys/file_sdmc.cpp b/src/core/file_sys/file_sdmc.cpp index 76e7f5d3..3ef2b0c0 100644 --- a/src/core/file_sys/file_sdmc.cpp +++ b/src/core/file_sys/file_sdmc.cpp @@ -76,6 +76,17 @@ size_t File_SDMC::GetSize() const { } /** + * Set the size of the file in bytes + * @param size New size of the file + * @return true if successful + */ +bool File_SDMC::SetSize(const u64 size) const { + file->Resize(size); + file->Flush(); + return true; +} + +/** * Close the file * @return true if the file closed correctly */ diff --git a/src/core/file_sys/file_sdmc.h b/src/core/file_sys/file_sdmc.h index d2302049..6b3a1f3a 100644 --- a/src/core/file_sys/file_sdmc.h +++ b/src/core/file_sys/file_sdmc.h @@ -48,6 +48,13 @@ public: size_t GetSize() const override; /** + * Set the size of the file in bytes + * @param size New size of the file + * @return true if successful + */ + bool SetSize(const u64 size) const override; + + /** * Close the file * @return true if the file closed correctly */ |