mirror of https://github.com/mgba-emu/mgba.git
3DS: Cleanup
This commit is contained in:
parent
d8f77aa62e
commit
81dffd6a12
|
@ -185,6 +185,7 @@ struct VDir* VDirOpen(const char* path) {
|
||||||
vd3d->d.openFile = _vd3dOpenFile;
|
vd3d->d.openFile = _vd3dOpenFile;
|
||||||
|
|
||||||
vd3d->vde.d.name = _vd3deName;
|
vd3d->vde.d.name = _vd3deName;
|
||||||
|
vd3d->vde.utf8Name = 0;
|
||||||
|
|
||||||
return &vd3d->d;
|
return &vd3d->d;
|
||||||
}
|
}
|
||||||
|
@ -210,8 +211,13 @@ static void _vd3dRewind(struct VDir* vd) {
|
||||||
static struct VDirEntry* _vd3dListNext(struct VDir* vd) {
|
static struct VDirEntry* _vd3dListNext(struct VDir* vd) {
|
||||||
struct VDir3DS* vd3d = (struct VDir3DS*) vd;
|
struct VDir3DS* vd3d = (struct VDir3DS*) vd;
|
||||||
u32 n = 0;
|
u32 n = 0;
|
||||||
Result res = FSDIR_Read(vd3d->handle, &n, 1, &vd3d->vde.ent);
|
memset(&vd3d->vde.ent, 0, sizeof(vd3d->vde.ent));
|
||||||
if (res & 0xFFFC03FF || !n) {
|
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 0;
|
||||||
}
|
}
|
||||||
return &vd3d->vde.d;
|
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) {
|
static const char* _vd3deName(struct VDirEntry* vde) {
|
||||||
struct VDirEntry3DS* vd3de = (struct VDirEntry3DS*) vde;
|
struct VDirEntry3DS* vd3de = (struct VDirEntry3DS*) vde;
|
||||||
if (vd3de->utf8Name) {
|
if (!vd3de->utf8Name) {
|
||||||
free(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;
|
return vd3de->utf8Name;
|
||||||
}
|
}
|
||||||
|
|
|
@ -104,7 +104,7 @@ int main() {
|
||||||
font, _drawStart, _drawEnd, _pollInput
|
font, _drawStart, _drawEnd, _pollInput
|
||||||
};
|
};
|
||||||
_drawStart();
|
_drawStart();
|
||||||
GUIFontPrintf(font, 20, 20, GUI_TEXT_LEFT, 0xFFFFFFFF, "Loading...");
|
GUIFontPrintf(font, 0, GUIFontHeight(font), GUI_TEXT_LEFT, 0xFFFFFFFF, "Loading...");
|
||||||
_drawEnd();
|
_drawEnd();
|
||||||
char path[256] = "/rom.gba";
|
char path[256] = "/rom.gba";
|
||||||
if (!selectFile(¶ms, "/", path, sizeof(path), "gba") || !GBAContextLoadROM(&context, path, true)) {
|
if (!selectFile(¶ms, "/", path, sizeof(path), "gba") || !GBAContextLoadROM(&context, path, true)) {
|
||||||
|
|
|
@ -12,7 +12,7 @@
|
||||||
DECLARE_VECTOR(FileList, char*);
|
DECLARE_VECTOR(FileList, char*);
|
||||||
DEFINE_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 size = FileListSize(currentFiles);
|
||||||
size_t i;
|
size_t i;
|
||||||
for (i = 0; i < size; ++i) {
|
for (i = 0; i < size; ++i) {
|
||||||
|
@ -21,7 +21,7 @@ void _cleanFiles(struct FileList* currentFiles) {
|
||||||
FileListClear(currentFiles);
|
FileListClear(currentFiles);
|
||||||
}
|
}
|
||||||
|
|
||||||
void _upDirectory(char* currentPath) {
|
static void _upDirectory(char* currentPath) {
|
||||||
char* end = strrchr(currentPath, '/');
|
char* end = strrchr(currentPath, '/');
|
||||||
if (!end) {
|
if (!end) {
|
||||||
return;
|
return;
|
||||||
|
@ -33,7 +33,7 @@ void _upDirectory(char* currentPath) {
|
||||||
// TODO: What if there was a trailing slash?
|
// 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);
|
_cleanFiles(currentFiles);
|
||||||
|
|
||||||
struct VDir* dir = VDirOpen(currentPath);
|
struct VDir* dir = VDirOpen(currentPath);
|
||||||
|
|
Loading…
Reference in New Issue