all repos — mgba @ a8f29906140feba11bdd4cd88574aee275f6f096

mGBA Game Boy Advance Emulator

VFS: Make VFile.truncate work growing files on PSV (fixes #885)
Vicki Pfau vi@endrift.com
Sun, 24 Sep 2017 11:56:26 -0700
commit

a8f29906140feba11bdd4cd88574aee275f6f096

parent

5dfa036fa529b3a49eb2c0d391b6d23590363c6a

2 files changed, 15 insertions(+), 1 deletions(-)

jump to
M CHANGESCHANGES

@@ -56,6 +56,7 @@ - Util: Don't build crc32 if the function already exists

- GBA: Detect hardware for Pokémon FireRed ROM hacks - CMake: Fix CPack dependencies for libpng 1.6 - Qt: Allow overrides to be saved before a game is loaded + - VFS: Make VFile.truncate work growing files on PSV (fixes mgba.io/i/885) 0.6.0: (2017-07-16) Features:
M src/platform/psp2/sce-vfs.csrc/platform/psp2/sce-vfs.c

@@ -120,7 +120,20 @@ }

static void _vfsceTruncate(struct VFile* vf, size_t size) { struct VFileSce* vfsce = (struct VFileSce*) vf; - // TODO + SceOff cur = sceIoLseek(vfsce->fd, 0, SEEK_CUR); + SceOff end = sceIoLseek(vfsce->fd, 0, SEEK_END); + if (end < size) { + uint8_t buffer[2048] = {}; + size_t write = size - end; + while (write >= sizeof(buffer)) { + sceIoWrite(vfsce->fd, buffer, sizeof(buffer)); + write -= sizeof(buffer); + } + if (write) { + sceIoWrite(vfsce->fd, buffer, write); + } + } // TODO: Else + sceIoLseek(vfsce->fd, cur, SEEK_SET); } ssize_t _vfsceSize(struct VFile* vf) {