3DS: Cleanup
Jeffrey Pfau jeffrey@endrift.com
Sun, 23 Aug 2015 20:28:33 -0700
3 files changed,
14 insertions(+),
9 deletions(-)
M
src/platform/3ds/3ds-vfs.c
→
src/platform/3ds/3ds-vfs.c
@@ -185,6 +185,7 @@ vd3d->d.listNext = _vd3dListNext; //// Crashes here for no good reason
vd3d->d.openFile = _vd3dOpenFile; vd3d->vde.d.name = _vd3deName; + vd3d->vde.utf8Name = 0; return &vd3d->d; }@@ -210,8 +211,13 @@
static struct VDirEntry* _vd3dListNext(struct VDir* vd) { struct VDir3DS* vd3d = (struct VDir3DS*) vd; u32 n = 0; - Result res = FSDIR_Read(vd3d->handle, &n, 1, &vd3d->vde.ent); - if (res & 0xFFFC03FF || !n) { + memset(&vd3d->vde.ent, 0, sizeof(vd3d->vde.ent)); + if (vd3d->vde.utf8Name) { + free(vd3d->vde.utf8Name); + vd3d->vde.utf8Name = 0; + }; + FSDIR_Read(vd3d->handle, &n, 1, &vd3d->vde.ent); + if (!n) { return 0; } return &vd3d->vde.d;@@ -233,9 +239,8 @@ }
static const char* _vd3deName(struct VDirEntry* vde) { struct VDirEntry3DS* vd3de = (struct VDirEntry3DS*) vde; - if (vd3de->utf8Name) { - free(vd3de->utf8Name); + if (!vd3de->utf8Name) { + vd3de->utf8Name = utf16to8(vd3de->ent.name, sizeof(vd3de->ent.name) / 2); } - vd3de->utf8Name = utf16to8(vd3de->ent.name, sizeof(vd3de->ent.name) / 2); return vd3de->utf8Name; }
M
src/platform/3ds/main.c
→
src/platform/3ds/main.c
@@ -104,7 +104,7 @@ 320, 240,
font, _drawStart, _drawEnd, _pollInput }; _drawStart(); - GUIFontPrintf(font, 20, 20, GUI_TEXT_LEFT, 0xFFFFFFFF, "Loading..."); + GUIFontPrintf(font, 0, GUIFontHeight(font), GUI_TEXT_LEFT, 0xFFFFFFFF, "Loading..."); _drawEnd(); char path[256] = "/rom.gba"; if (!selectFile(¶ms, "/", path, sizeof(path), "gba") || !GBAContextLoadROM(&context, path, true)) {
M
src/util/gui/file-select.c
→
src/util/gui/file-select.c
@@ -12,7 +12,7 @@
DECLARE_VECTOR(FileList, char*); DEFINE_VECTOR(FileList, char*); -void _cleanFiles(struct FileList* currentFiles) { +static void _cleanFiles(struct FileList* currentFiles) { size_t size = FileListSize(currentFiles); size_t i; for (i = 0; i < size; ++i) {@@ -21,7 +21,7 @@ }
FileListClear(currentFiles); } -void _upDirectory(char* currentPath) { +static void _upDirectory(char* currentPath) { char* end = strrchr(currentPath, '/'); if (!end) { return;@@ -33,7 +33,7 @@ }
// TODO: What if there was a trailing slash? } -bool _refreshDirectory(const char* currentPath, struct FileList* currentFiles) { +static bool _refreshDirectory(const char* currentPath, struct FileList* currentFiles) { _cleanFiles(currentFiles); struct VDir* dir = VDirOpen(currentPath);