PSP2: Implement VFileSce.sync
Jeffrey Pfau jeffrey@endrift.com
Tue, 07 Jul 2015 00:35:44 -0700
1 files changed,
14 insertions(+),
0 deletions(-)
jump to
M
src/platform/psp2/sce-vfs.c
→
src/platform/psp2/sce-vfs.c
@@ -23,6 +23,7 @@ static void* _vfsceMap(struct VFile* vf, size_t size, int flags);
static void _vfsceUnmap(struct VFile* vf, void* memory, size_t size); static void _vfsceTruncate(struct VFile* vf, size_t size); static ssize_t _vfsceSize(struct VFile* vf); +static bool _vfsceSync(struct VFile* vf, const void* memory, size_t size); struct VFile* VFileOpenSce(const char* path, int flags, SceMode mode) { struct VFileSce* vfsce = malloc(sizeof(struct VFileSce));@@ -45,6 +46,7 @@ vfsce->d.map = _vfsceMap;
vfsce->d.unmap = _vfsceUnmap; vfsce->d.truncate = _vfsceTruncate; vfsce->d.size = _vfsceSize; + vfsce->d.sync = _vfsceSync; return &vfsce->d; }@@ -97,3 +99,15 @@ SceOff end = sceIoLseek(vfsce->fd, 0, SEEK_END);
sceIoLseek(vfsce->fd, cur, SEEK_SET); return end; } + +bool _vfsceSync(struct VFile* vf, const void* buffer, size_t size) { + struct VFileSce* vfsce = (struct VFileSce*) vf; + if (buffer && size) { + SceOff cur = sceIoLseek(vfsce->fd, 0, SEEK_CUR); + sceIoLseek(vfsce->fd, 0, SEEK_SET); + sceIoWrite(vfsce->fd, buffer, size); + sceIoLseek(vfsce->fd, cur, SEEK_SET); + } + // TODO: Get the right device + return sceIoSync("cache0:", 0) >= 0; +}