mirror of https://github.com/mgba-emu/mgba.git
VFS: Sync on unmap
This commit is contained in:
parent
7cc0c6cc82
commit
26427cf437
|
@ -137,6 +137,7 @@ static void* _vfdMap(struct VFile* vf, size_t size, int flags) {
|
||||||
|
|
||||||
static void _vfdUnmap(struct VFile* vf, void* memory, size_t size) {
|
static void _vfdUnmap(struct VFile* vf, void* memory, size_t size) {
|
||||||
UNUSED(vf);
|
UNUSED(vf);
|
||||||
|
msync(memory, size, MS_SYNC);
|
||||||
munmap(memory, size);
|
munmap(memory, size);
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
|
@ -167,6 +168,7 @@ static void* _vfdMap(struct VFile* vf, size_t size, int flags) {
|
||||||
static void _vfdUnmap(struct VFile* vf, void* memory, size_t size) {
|
static void _vfdUnmap(struct VFile* vf, void* memory, size_t size) {
|
||||||
UNUSED(size);
|
UNUSED(size);
|
||||||
struct VFileFD* vfd = (struct VFileFD*) vf;
|
struct VFileFD* vfd = (struct VFileFD*) vf;
|
||||||
|
FlushViewOfFile(buffer, size);
|
||||||
size_t i;
|
size_t i;
|
||||||
for (i = 0; i < HandleMappingListSize(&vfd->handles); ++i) {
|
for (i = 0; i < HandleMappingListSize(&vfd->handles); ++i) {
|
||||||
if (HandleMappingListGetPointer(&vfd->handles, i)->mapping == memory) {
|
if (HandleMappingListGetPointer(&vfd->handles, i)->mapping == memory) {
|
||||||
|
@ -214,6 +216,9 @@ static bool _vfdSync(struct VFile* vf, const void* buffer, size_t size) {
|
||||||
GetSystemTime(&st);
|
GetSystemTime(&st);
|
||||||
SystemTimeToFileTime(&st, &ft);
|
SystemTimeToFileTime(&st, &ft);
|
||||||
SetFileTime(h, NULL, &ft, &ft);
|
SetFileTime(h, NULL, &ft, &ft);
|
||||||
|
if (buffer && size) {
|
||||||
|
FlushViewOfFile(buffer, size);
|
||||||
|
}
|
||||||
return FlushFileBuffers(h);
|
return FlushFileBuffers(h);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue