2016-02-13 17:29:56 +01:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include "common.h"
|
|
|
|
|
2016-02-16 16:15:08 +01:00
|
|
|
typedef enum {
|
2016-03-02 19:36:20 +01:00
|
|
|
T_VRT_ROOT,
|
2016-02-29 15:47:45 +01:00
|
|
|
T_FAT_DIR,
|
2016-03-02 19:36:20 +01:00
|
|
|
T_FAT_FILE,
|
|
|
|
T_VRT_DOTDOT
|
2016-02-16 16:15:08 +01:00
|
|
|
} EntryType;
|
|
|
|
|
2016-02-25 16:57:01 +01:00
|
|
|
#define MAX_ENTRIES 1024
|
|
|
|
|
2016-02-16 16:15:08 +01:00
|
|
|
typedef struct {
|
|
|
|
char* name; // should point to the correct portion of the path
|
|
|
|
char path[256];
|
2016-02-27 19:58:41 +01:00
|
|
|
u64 size;
|
2016-02-25 16:57:01 +01:00
|
|
|
EntryType type;
|
2016-02-27 19:58:41 +01:00
|
|
|
u8 marked;
|
2016-02-16 16:15:08 +01:00
|
|
|
} DirEntry;
|
|
|
|
|
2016-02-25 16:57:01 +01:00
|
|
|
typedef struct {
|
|
|
|
u32 n_entries;
|
|
|
|
DirEntry entry[MAX_ENTRIES];
|
|
|
|
} DirStruct;
|
|
|
|
|
2016-02-13 17:29:56 +01:00
|
|
|
bool InitFS();
|
|
|
|
void DeinitFS();
|
|
|
|
|
2016-02-29 22:51:20 +01:00
|
|
|
/** Check if writing to this path is allowed **/
|
|
|
|
bool CheckWritePermissions(const char* path);
|
|
|
|
|
|
|
|
/** Set new write permissions */
|
|
|
|
bool SetWritePermissions(u32 level);
|
|
|
|
|
2016-03-01 02:00:48 +01:00
|
|
|
/** Get write permissions */
|
|
|
|
u32 GetWritePermissions();
|
|
|
|
|
2016-02-26 19:43:30 +01:00
|
|
|
/** Create / overwrite file and write the provided data to it **/
|
|
|
|
bool FileCreate(const char* path, u8* data, u32 size);
|
|
|
|
|
2016-02-29 02:09:31 +01:00
|
|
|
/** Recursively copy a file or directory **/
|
|
|
|
bool PathCopy(const char* destdir, const char* orig);
|
|
|
|
|
|
|
|
/** Recursively delete a file or directory **/
|
|
|
|
bool PathDelete(const char* path);
|
|
|
|
|
2016-02-26 19:43:30 +01:00
|
|
|
/** Create a screenshot of the current framebuffer **/
|
2016-02-29 15:47:45 +01:00
|
|
|
void CreateScreenshot();
|
2016-02-26 19:43:30 +01:00
|
|
|
|
2016-02-25 16:57:01 +01:00
|
|
|
/** Get directory content under a given path **/
|
2016-02-29 16:14:39 +01:00
|
|
|
void GetDirContents(DirStruct* contents, const char* path);
|
2016-02-13 17:29:56 +01:00
|
|
|
|
2016-02-27 19:58:41 +01:00
|
|
|
/** Gets remaining space in filesystem in bytes */
|
|
|
|
uint64_t GetFreeSpace(const char* path);
|
2016-02-13 17:29:56 +01:00
|
|
|
|
2016-02-27 19:58:41 +01:00
|
|
|
/** Gets total spacein filesystem in bytes */
|
|
|
|
uint64_t GetTotalSpace(const char* path);
|
2016-02-29 22:27:04 +01:00
|
|
|
|
|
|
|
/** Helper function for copying DirEntry structs */
|
|
|
|
void DirEntryCpy(DirEntry* dest, const DirEntry* orig);
|