Simplified directory object types

This commit is contained in:
d0k3 2016-03-21 16:58:35 +01:00
parent d084f9fa48
commit ba61f77ee0
3 changed files with 16 additions and 16 deletions

View File

@ -354,7 +354,7 @@ void SortDirStruct(DirStruct* contents) {
for (u32 s = 0; s < contents->n_entries; s++) {
DirEntry* cmp0 = &(contents->entry[s]);
DirEntry* min0 = cmp0;
if (cmp0->type == T_VRT_DOTDOT) continue;
if (cmp0->type == T_DOTDOT) continue;
for (u32 c = s + 1; c < contents->n_entries; c++) {
DirEntry* cmp1 = &(contents->entry[c]);
if (min0->type != cmp1->type) {
@ -389,7 +389,7 @@ bool GetRootDirContentsWorker(DirStruct* contents) {
snprintf(contents->entry[n_entries].path + 4, 32, "[%lu:] %s", pdrv, drvname[pdrv]);
contents->entry[n_entries].name = contents->entry[n_entries].path + 4;
contents->entry[n_entries].size = GetTotalSpace(contents->entry[n_entries].path);
contents->entry[n_entries].type = T_VRT_ROOT;
contents->entry[n_entries].type = T_ROOT;
contents->entry[n_entries].marked = 0;
n_entries++;
}
@ -423,10 +423,10 @@ bool GetDirContentsWorker(DirStruct* contents, char* fpath, int fsize, bool recu
strncpy(entry->path, fpath, 256);
entry->name = entry->path + (fname - fpath);
if (fno.fattrib & AM_DIR) {
entry->type = T_FAT_DIR;
entry->type = T_DIR;
entry->size = 0;
} else {
entry->type = T_FAT_FILE;
entry->type = T_FILE;
entry->size = fno.fsize;
}
entry->marked = 0;
@ -456,7 +456,7 @@ void GetDirContents(DirStruct* contents, const char* path) {
contents->entry->name = contents->entry->path + 8;
strncpy(contents->entry->path, "*?*?*", 8);
strncpy(contents->entry->name, "..", 4);
contents->entry->type = T_VRT_DOTDOT;
contents->entry->type = T_DOTDOT;
contents->entry->size = 0;
contents->n_entries = 1;
if (!GetDirContentsWorker(contents, fpath, 256, false))

View File

@ -3,10 +3,10 @@
#include "common.h"
typedef enum {
T_VRT_ROOT,
T_FAT_DIR,
T_FAT_FILE,
T_VRT_DOTDOT
T_ROOT,
T_DIR,
T_FILE,
T_DOTDOT
} EntryType;
#define MAX_ENTRIES 1024

View File

@ -4,7 +4,7 @@
#include "fs.h"
#include "nand.h"
#define VERSION "0.1.5"
#define VERSION "0.1.8"
#define COLOR_TOP_BAR ((GetWritePermissions() == 0) ? COLOR_WHITE : (GetWritePermissions() == 1) ? COLOR_BRIGHTGREEN : (GetWritePermissions() == 2) ? COLOR_BRIGHTYELLOW : COLOR_RED)
#define COLOR_SIDE_BAR COLOR_DARKGREY
@ -12,7 +12,7 @@
#define COLOR_FILE COLOR_TINTEDGREEN
#define COLOR_DIR COLOR_TINTEDBLUE
#define COLOR_ROOT COLOR_GREY
#define COLOR_ENTRY(e) (((e)->marked) ? COLOR_MARKED : ((e)->type == T_FAT_DIR) ? COLOR_DIR : ((e)->type == T_FAT_FILE) ? COLOR_FILE : ((e)->type == T_VRT_ROOT) ? COLOR_ROOT : COLOR_GREY)
#define COLOR_ENTRY(e) (((e)->marked) ? COLOR_MARKED : ((e)->type == T_DIR) ? COLOR_DIR : ((e)->type == T_FILE) ? COLOR_FILE : ((e)->type == T_ROOT) ? COLOR_ROOT : COLOR_GREY)
void DrawUserInterface(const char* curr_path, DirEntry* curr_entry, DirStruct* clipboard) {
@ -54,9 +54,9 @@ void DrawUserInterface(const char* curr_path, DirEntry* curr_entry, DirStruct* c
ResizeString(tempstr, curr_entry->name, 20, 8, false);
u32 color_current = COLOR_ENTRY(curr_entry);
DrawStringF(true, 4, info_start + 12, color_current, COLOR_STD_BG, "%s", tempstr);
if (curr_entry->type == T_FAT_DIR) {
if (curr_entry->type == T_DIR) {
ResizeString(tempstr, "(dir)", 20, 8, false);
} else if (curr_entry->type == T_VRT_DOTDOT) {
} else if (curr_entry->type == T_DOTDOT) {
snprintf(tempstr, 21, "%20s", "");
} else {
FormatBytes(bytestr0, curr_entry->size);
@ -162,12 +162,12 @@ u32 GodMode() {
}
// commands which are valid anywhere
if ((pad_state & BUTTON_A) && (current_dir->entry[cursor].type != T_FAT_FILE)) { // one level up
if (current_dir->entry[cursor].type == T_VRT_DOTDOT) {
if ((pad_state & BUTTON_A) && (current_dir->entry[cursor].type != T_FILE)) { // one level up
if (current_dir->entry[cursor].type == T_DOTDOT) {
char* last_slash = strrchr(current_path, '/');
if (last_slash) *last_slash = '\0';
else *current_path = '\0';
} else { // type == T_FAT_DIR || type == T_VRT_ROOT
} else { // type == T_DIR || type == T_ROOT
strncpy(current_path, current_dir->entry[cursor].path, 256);
}
GetDirContents(current_dir, current_path);