Skip to content

Commit

Permalink
- Support hiding dot files on all devices.
Browse files Browse the repository at this point in the history
- Refactor FlippyDrive version checks.
- Add display name for apps and games directories.
  • Loading branch information
Extrems committed Dec 10, 2024
1 parent b79bdb2 commit 4f96f21
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 16 deletions.
7 changes: 3 additions & 4 deletions cube/swiss/source/devices/fat/deviceHandler-FAT.c
Original file line number Diff line number Diff line change
Expand Up @@ -131,10 +131,9 @@ s32 deviceHandler_FAT_readDir(file_handle* ffile, file_handle** dir, u32 type) {
}
memset(&(*dir)[i], 0, sizeof(file_handle));
if(concat_path((*dir)[i].name, ffile->name, entry.fname) < PATHNAME_MAX && entry.fsize <= UINT32_MAX) {
(*dir)[i].size = entry.fsize;
(*dir)[i].fileType = (entry.fattrib & AM_DIR) ? IS_DIR : IS_FILE;
(*dir)[i].fileAttrib = entry.fattrib;
(*dir)[i].fileAttrib |= (entry.fname[0] == '.') ? AM_HID : 0;
(*dir)[i].size = entry.fsize;
(*dir)[i].fileType = (entry.fattrib & AM_DIR) ? IS_DIR : IS_FILE;
(*dir)[i].fileAttrib = entry.fattrib;
++i;
}
}
Expand Down
5 changes: 4 additions & 1 deletion cube/swiss/source/devices/filemeta.c
Original file line number Diff line number Diff line change
Expand Up @@ -352,7 +352,10 @@ void populate_meta(file_handle *f) {
}
devices[DEVICE_CUR]->closeFile(bootFile);
free(bootFile);
}
} else if (!fnmatch("*/apps", f->name, FNM_PATHNAME | FNM_CASEFOLD))
f->meta->displayName = "Applications";
else if (!fnmatch("*/games", f->name, FNM_PATHNAME | FNM_CASEFOLD))
f->meta->displayName = "Games";
if (!fnmatch("*/apps/*", f->name, FNM_PATHNAME | FNM_CASEFOLD)) {
file_handle *bootFile = calloc(1, sizeof(file_handle));
concat_path(bootFile->name, f->name, "boot.dol");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ s32 deviceHandler_Flippy_readDir(file_handle* ffile, file_handle** dir, u32 type

// Read each entry of the directory
while( flippy_readdir(dp, &entry, &result) == FLIPPY_RESULT_OK && result == &entry ) {
if(!strcmp(entry.name, ".") || !strcmp(entry.name, "..")) {
if(!strcmp(entry.name, ".") || !strcmp(entry.name, "..") || !strcmp(entry.name, "?")) {
continue;
}
// Do we want this one?
Expand Down Expand Up @@ -331,12 +331,15 @@ bool deviceHandler_Flippy_test() {
}
case 0x20220426:
flippyversion *version = (flippyversion *)driveInfo.pad;
u32 flippy_version = FLIPPY_VERSION(version->major, version->minor, version->build);

__device_flippy.quirks = QUIRK_NO_DEINIT;

if (FLIPPY_VERSION(version->major, version->minor, version->build) < FLIPPY_VERSION(1,3,3))
if (flippy_version >= FLIPPY_VERSION(1,3,0) &&
flippy_version <= FLIPPY_VERSION(1,3,2))
__device_flippy.quirks |= QUIRK_FDI_BYTESWAP_SIZE;

if (FLIPPY_VERSION(version->major, version->minor, version->build) < FLIPPY_VERSION(1,3,1)) {
if (flippy_version < FLIPPY_VERSION(1,3,1)) {
__device_flippy.extraExtensions = NULL;
__device_flippy.quirks |= QUIRK_FDI_EXCLUSIVE_OPEN;
}
Expand Down
14 changes: 9 additions & 5 deletions cube/swiss/source/files.c
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,15 @@ int sortFiles(file_handle* dir, int numFiles, file_handle*** sortedDir)
*sortedDir = calloc(numFiles, sizeof(file_handle*));
if(*sortedDir) {
for(int j = 0; j < numFiles; j++) {
if((dir[j].fileAttrib & ATTRIB_HIDDEN) && !swissSettings.showHiddenFiles) {
continue;
}
if(dir[j].fileType == IS_FILE && !checkExtension(dir[j].name, devices[DEVICE_CUR]->extraExtensions)) {
continue;
switch(dir[j].fileType) {
case IS_SPECIAL:
break;
case IS_FILE:
if(!checkExtension(dir[j].name, devices[DEVICE_CUR]->extraExtensions))
continue;
default:
if(!swissSettings.showHiddenFiles && ((dir[j].fileAttrib & ATTRIB_HIDDEN) || *getRelativeName(dir[j].name) == '.'))
continue;
}
(*sortedDir)[i++] = &dir[j];
}
Expand Down
2 changes: 1 addition & 1 deletion cube/swiss/source/gui/FrameBufferMagic.c
Original file line number Diff line number Diff line change
Expand Up @@ -1356,7 +1356,7 @@ uiDrawObj_t* DrawFileBrowserButton(int x1, int y1, int x2, int y2, const char *m
}
}
}
eventData->alpha = (eventData->file->fileAttrib & ATTRIB_HIDDEN) ? 128 : 255;
eventData->alpha = (eventData->file->fileAttrib & ATTRIB_HIDDEN) || *getRelativeName(eventData->file->name) == '.' ? 128 : 255;
eventData->isAutoLoadEntry = !strcmp(swissSettings.autoload, file->name) || !fnmatch(swissSettings.autoload, file->name, FNM_PATHNAME | FNM_PREFIX_DIRS);

uiDrawObj_t *event = calloc(1, sizeof(uiDrawObj_t));
Expand Down
5 changes: 3 additions & 2 deletions cube/swiss/source/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -236,12 +236,13 @@ int main(int argc, char *argv[])
}
else if(device == &__device_flippy) {
flippyversion *version = (flippyversion*)driveInfo.pad;
if(FLIPPY_VERSION(version->major, version->minor, version->build) < FLIPPY_VERSION(FLIPPY_MINVER_MAJOR, FLIPPY_MINVER_MINOR, FLIPPY_MINVER_BUILD)) {
u32 flippy_version = FLIPPY_VERSION(version->major, version->minor, version->build);
if(flippy_version < FLIPPY_VERSION(FLIPPY_MINVER_MAJOR, FLIPPY_MINVER_MINOR, FLIPPY_MINVER_BUILD)) {
uiDrawObj_t *msgBox = DrawPublish(DrawMessageBox(D_WARN, "A firmware update is required.\nflippydrive.com/updates"));
wait_press_A();
DrawDispose(msgBox);
}
else if(FLIPPY_VERSION(version->major, version->minor, version->build) < FLIPPY_VERSION(1,3,2)) {
else if(flippy_version < FLIPPY_VERSION(1,3,2)) {
uiDrawObj_t *msgBox = DrawPublish(DrawMessageBox(D_INFO, "A firmware update is available.\nflippydrive.com/updates"));
wait_press_A();
DrawDispose(msgBox);
Expand Down

0 comments on commit 4f96f21

Please sign in to comment.