Add errors
and prepare for file menu more and fix that you can't go left right when going up down
This commit is contained in:
25
source/fs/fstypes.h
Normal file
25
source/fs/fstypes.h
Normal file
@@ -0,0 +1,25 @@
|
||||
#pragma once
|
||||
#include <utils/types.h>
|
||||
|
||||
typedef struct {
|
||||
char *name;
|
||||
union {
|
||||
struct {
|
||||
u8 readOnly:1;
|
||||
u8 hidden:1;
|
||||
u8 system:1;
|
||||
u8 volume:1;
|
||||
u8 isDir:1;
|
||||
u8 archive:1;
|
||||
};
|
||||
u8 optionUnion;
|
||||
};
|
||||
union {
|
||||
struct {
|
||||
u16 size:12;
|
||||
u16 showSize:1;
|
||||
u16 sizeDef:3;
|
||||
};
|
||||
u16 sizeUnion;
|
||||
};
|
||||
} FSEntry_t;
|
||||
@@ -4,6 +4,7 @@
|
||||
#include "../utils/utils.h"
|
||||
#include <utils/sprintf.h>
|
||||
#include <libs/fatfs/ff.h>
|
||||
#include "readers/folderReader.h"
|
||||
|
||||
char *CombinePaths(const char *current, const char *add){
|
||||
char *ret;
|
||||
@@ -35,4 +36,10 @@ u64 GetFileSize(char *path){
|
||||
FILINFO fno;
|
||||
f_stat(path, &fno);
|
||||
return fno.fsize;
|
||||
}
|
||||
|
||||
char *GetFileAttribs(FSEntry_t entry){
|
||||
char *ret = CpyStr("RHSVDA");
|
||||
MaskIn(ret, entry.optionUnion, '-');
|
||||
return ret;
|
||||
}
|
||||
@@ -1,6 +1,8 @@
|
||||
#pragma once
|
||||
#include <utils/types.h>
|
||||
#include "fstypes.h"
|
||||
|
||||
u64 GetFileSize(char *path);
|
||||
char *EscapeFolder(char *current);
|
||||
char *CombinePaths(const char *current, const char *add);
|
||||
char *CombinePaths(const char *current, const char *add);
|
||||
char *GetFileAttribs(FSEntry_t entry);
|
||||
@@ -6,6 +6,7 @@
|
||||
#include "../../gfx/gfx.h"
|
||||
#include "../../gfx/gfxutils.h"
|
||||
#include "../../utils/utils.h"
|
||||
#include "filemenu.h"
|
||||
#include <string.h>
|
||||
#include <mem/heap.h>
|
||||
|
||||
@@ -55,6 +56,10 @@ void FileExplorer(char *path){
|
||||
|
||||
gfx_con_setpos(144, 16);
|
||||
gfx_boxGrey(0, 16, 160, 31, 0x1B);
|
||||
|
||||
if (res >= fileVec.count + ARR_LEN(topEntries))
|
||||
res = 0;
|
||||
|
||||
res = newMenu(&entries, res, 60, 42, ENABLEB | ENABLEPAGECOUNT, (int)fileVec.count);
|
||||
|
||||
if (res < ARR_LEN(topEntries)) {
|
||||
@@ -66,14 +71,19 @@ void FileExplorer(char *path){
|
||||
char *copy = CpyStr(storedPath);
|
||||
storedPath = EscapeFolder(copy);
|
||||
free(copy);
|
||||
res = 0;
|
||||
}
|
||||
else if (fsEntries[res - ARR_LEN(topEntries)].isDir) {
|
||||
char *copy = CpyStr(storedPath);
|
||||
storedPath = CombinePaths(copy, fsEntries[res - ARR_LEN(topEntries)].name);
|
||||
free(copy);
|
||||
res = 0;
|
||||
}
|
||||
else {
|
||||
FileMenu(fsEntries[res - ARR_LEN(topEntries)]);
|
||||
}
|
||||
|
||||
res = 0;
|
||||
|
||||
clearFileVector(&fileVec);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
#include "filemenu.h"
|
||||
#include "../../err.h"
|
||||
#include "../../gfx/menu.h"
|
||||
|
||||
MenuEntry_t FileMenuEntries[] = {
|
||||
// Still have to think up the options
|
||||
};
|
||||
|
||||
void FileMenu(FSEntry_t entry){
|
||||
DrawError(newErrCode(TE_ERR_UNIMPLEMENTED));
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
#pragma once
|
||||
#include "../fstypes.h"
|
||||
|
||||
void FileMenu(FSEntry_t entry);
|
||||
@@ -14,7 +14,8 @@ Vector_t /* of type FSEntry_t */ ReadFolder(char *path){
|
||||
}
|
||||
|
||||
while (!f_readdir(&dir, &fno) && fno.fname[0]) {
|
||||
FSEntry_t newEntry = {.isDir = (fno.fattrib & AM_DIR) ? 1 : 0, .name = CpyStr(fno.fname)};
|
||||
FSEntry_t newEntry = {.optionUnion = fno.fattrib, .name = CpyStr(fno.fname)};
|
||||
|
||||
if (!newEntry.isDir){
|
||||
u64 total = fno.fsize;
|
||||
u8 type = 0;
|
||||
@@ -33,5 +34,7 @@ Vector_t /* of type FSEntry_t */ ReadFolder(char *path){
|
||||
vecAddElem(&out, newEntry);
|
||||
}
|
||||
|
||||
f_closedir(&dir);
|
||||
|
||||
return out;
|
||||
}
|
||||
|
||||
@@ -1,23 +1,6 @@
|
||||
#pragma once
|
||||
#include <utils/types.h>
|
||||
#include "../../utils/vector.h"
|
||||
|
||||
typedef struct {
|
||||
char *name;
|
||||
union {
|
||||
struct {
|
||||
u8 isDir:1;
|
||||
};
|
||||
u8 optionUnion;
|
||||
};
|
||||
union {
|
||||
struct {
|
||||
u16 size:12;
|
||||
u16 showSize:1;
|
||||
u16 sizeDef:3;
|
||||
};
|
||||
u16 sizeUnion;
|
||||
};
|
||||
} FSEntry_t;
|
||||
#include "../fstypes.h"
|
||||
|
||||
Vector_t /* of type FSEntry_t */ ReadFolder(char *path);
|
||||
Reference in New Issue
Block a user