3DS: Cleanup

This commit is contained in:
Jeffrey Pfau 2015-08-23 20:28:33 -07:00
parent d8f77aa62e
commit 81dffd6a12
3 changed files with 14 additions and 9 deletions

View File

@ -185,6 +185,7 @@ struct VDir* VDirOpen(const char* path) {
vd3d->d.openFile = _vd3dOpenFile;
vd3d->vde.d.name = _vd3deName;
vd3d->vde.utf8Name = 0;
return &vd3d->d;
}
@ -210,8 +211,13 @@ static void _vd3dRewind(struct VDir* vd) {
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 struct VFile* _vd3dOpenFile(struct VDir* vd, const char* path, int mode)
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;
}

View File

@ -104,7 +104,7 @@ int main() {
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(&params, "/", path, sizeof(path), "gba") || !GBAContextLoadROM(&context, path, true)) {

View File

@ -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 @@ void _cleanFiles(struct FileList* currentFiles) {
FileListClear(currentFiles);
}
void _upDirectory(char* currentPath) {
static void _upDirectory(char* currentPath) {
char* end = strrchr(currentPath, '/');
if (!end) {
return;
@ -33,7 +33,7 @@ void _upDirectory(char* currentPath) {
// 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);