all repos — mgba @ 69db3f41a3acc87467ac698718d649327e70e74b

mGBA Game Boy Advance Emulator

3DS: Fix opening files in directory names with trailing slashes
Vicki Pfau vi@endrift.com
Sun, 07 Jan 2018 17:01:56 -0800
commit

69db3f41a3acc87467ac698718d649327e70e74b

parent

a796c167e432c7106d5d892dc4917a4a38240a7f

2 files changed, 16 insertions(+), 3 deletions(-)

jump to
M CHANGESCHANGES

@@ -35,6 +35,7 @@ - GBA Cheats: Fix slide codes not initializing properly

- Qt: Fix locale being set to English on settings save (fixes mgba.io/i/906) - LR35902: Fix watchpoints not reporting new value - GBA Audio: Increase PSG volume (fixes mgba.io/i/932) + - 3DS: Fix opening files in directory names with trailing slashes Misc: - GBA Timer: Use global cycles for timers - GBA: Extend oddly-sized ROMs to full address space (fixes mgba.io/i/722)
M src/platform/3ds/3ds-vfs.csrc/platform/3ds/3ds-vfs.c

@@ -241,7 +241,11 @@ return 0;

} const char* dir = vd3d->path; char* combined = malloc(sizeof(char) * (strlen(path) + strlen(dir) + 2)); - sprintf(combined, "%s/%s", dir, path); + if (dir[strlen(dir) - 1] == '/') { + sprintf(combined, "%s%s", dir, path); + } else { + sprintf(combined, "%s/%s", dir, path); + } struct VFile* file = VFileOpen(combined, mode); free(combined);

@@ -255,7 +259,11 @@ return 0;

} const char* dir = vd3d->path; char* combined = malloc(sizeof(char) * (strlen(path) + strlen(dir) + 2)); - sprintf(combined, "%s/%s", dir, path); + if (dir[strlen(dir) - 1] == '/') { + sprintf(combined, "%s%s", dir, path); + } else { + sprintf(combined, "%s/%s", dir, path); + } struct VDir* vd2 = VDirOpen(combined); if (!vd2) {

@@ -272,7 +280,11 @@ return 0;

} const char* dir = vd3d->path; char* combined = malloc(sizeof(char) * (strlen(path) + strlen(dir) + 2)); - sprintf(combined, "%s/%s", dir, path); + if (dir[strlen(dir) - 1] == '/') { + sprintf(combined, "%s%s", dir, path); + } else { + sprintf(combined, "%s/%s", dir, path); + } uint16_t utf16Path[PATH_MAX + 1]; ssize_t units = utf8_to_utf16(utf16Path, (const uint8_t*) combined, PATH_MAX);