2020-12-23 16:39:22 +00:00
|
|
|
#include <mem/heap.h>
|
|
|
|
#include <string.h>
|
|
|
|
#include "fsutils.h"
|
|
|
|
#include "../utils/utils.h"
|
|
|
|
#include <utils/sprintf.h>
|
|
|
|
#include <libs/fatfs/ff.h>
|
2020-12-24 23:20:30 +00:00
|
|
|
#include "readers/folderReader.h"
|
2020-12-23 16:39:22 +00:00
|
|
|
|
|
|
|
char *CombinePaths(const char *current, const char *add){
|
|
|
|
char *ret;
|
|
|
|
|
|
|
|
size_t size = strlen(current) + strlen(add) + 2;
|
|
|
|
ret = (char*) malloc (size);
|
|
|
|
|
|
|
|
sprintf(ret, (current[strlen(current) - 1] == '/') ? "%s%s" : "%s/%s", current, add);
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2020-12-26 00:05:33 +00:00
|
|
|
char *EscapeFolder(const char *current){
|
2020-12-23 16:39:22 +00:00
|
|
|
char *ret;
|
|
|
|
char *temp;
|
|
|
|
|
|
|
|
ret = CpyStr(current);
|
|
|
|
temp = strrchr(ret, '/');
|
|
|
|
|
|
|
|
if (*(temp - 1) == ':')
|
|
|
|
temp++;
|
|
|
|
|
|
|
|
*temp = '\0';
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
u64 GetFileSize(char *path){
|
|
|
|
FILINFO fno;
|
|
|
|
f_stat(path, &fno);
|
|
|
|
return fno.fsize;
|
2020-12-24 23:20:30 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
char *GetFileAttribs(FSEntry_t entry){
|
|
|
|
char *ret = CpyStr("RHSVDA");
|
|
|
|
MaskIn(ret, entry.optionUnion, '-');
|
|
|
|
return ret;
|
2020-12-28 01:29:58 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
bool FileExists(char* path){
|
|
|
|
FRESULT fr;
|
|
|
|
FILINFO fno;
|
|
|
|
|
|
|
|
fr = f_stat(path, &fno);
|
|
|
|
|
|
|
|
return !(fr & FR_NO_FILE);
|
|
|
|
}
|