mirror of https://github.com/mgba-emu/mgba.git
GUI: Put an "up" entry in file browser
This commit is contained in:
parent
d67844e95f
commit
3f78362a3e
|
@ -15,7 +15,7 @@ DEFINE_VECTOR(FileList, char*);
|
|||
static void _cleanFiles(struct FileList* currentFiles) {
|
||||
size_t size = FileListSize(currentFiles);
|
||||
size_t i;
|
||||
for (i = 0; i < size; ++i) {
|
||||
for (i = 1; i < size; ++i) {
|
||||
free(*FileListGetPointer(currentFiles, i));
|
||||
}
|
||||
FileListClear(currentFiles);
|
||||
|
@ -44,6 +44,7 @@ static bool _refreshDirectory(const char* currentPath, struct FileList* currentF
|
|||
if (!dir) {
|
||||
return false;
|
||||
}
|
||||
*FileListAppend(currentFiles) = "(Up)";
|
||||
struct VDirEntry* de;
|
||||
while ((de = dir->listNext(dir))) {
|
||||
const char* name = de->name(de);
|
||||
|
@ -111,17 +112,22 @@ bool selectFile(const struct GUIParams* params, const char* basePath, char* outP
|
|||
FileListDeinit(¤tFiles);
|
||||
return false;
|
||||
}
|
||||
if (newInput & (1 << GUI_INPUT_SELECT) && FileListSize(¤tFiles)) {
|
||||
size_t len = strlen(currentPath);
|
||||
const char* sep = PATH_SEP;
|
||||
if (currentPath[len - 1] == *sep) {
|
||||
sep = "";
|
||||
if (newInput & (1 << GUI_INPUT_SELECT)) {
|
||||
if (fileIndex == 0) {
|
||||
_upDirectory(currentPath);
|
||||
_refreshDirectory(currentPath, ¤tFiles, filter);
|
||||
} else {
|
||||
size_t len = strlen(currentPath);
|
||||
const char* sep = PATH_SEP;
|
||||
if (currentPath[len - 1] == *sep) {
|
||||
sep = "";
|
||||
}
|
||||
snprintf(outPath, outLen, "%s%s%s", currentPath, sep, *FileListGetPointer(¤tFiles, fileIndex));
|
||||
if (!_refreshDirectory(outPath, ¤tFiles, filter)) {
|
||||
return true;
|
||||
}
|
||||
strncpy(currentPath, outPath, outLen);
|
||||
}
|
||||
snprintf(outPath, outLen, "%s%s%s", currentPath, sep, *FileListGetPointer(¤tFiles, fileIndex));
|
||||
if (!_refreshDirectory(outPath, ¤tFiles, filter)) {
|
||||
return true;
|
||||
}
|
||||
strncpy(currentPath, outPath, outLen);
|
||||
fileIndex = 0;
|
||||
}
|
||||
if (newInput & (1 << GUI_INPUT_BACK)) {
|
||||
|
|
Loading…
Reference in New Issue