d0k3 bf19767a82 Enabled a write permission system
Plus tons of design and under the hood changes
2016-03-01 02:00:48 +01:00

61 lines
1.4 KiB
C

#pragma once
#include "common.h"
typedef enum {
T_FAT_ROOT,
T_FAT_DIR,
T_FAT_FILE
} EntryType;
#define MAX_ENTRIES 1024
typedef struct {
char* name; // should point to the correct portion of the path
char path[256];
u64 size;
EntryType type;
u8 marked;
} DirEntry;
typedef struct {
u32 n_entries;
DirEntry entry[MAX_ENTRIES];
} DirStruct;
bool InitFS();
void DeinitFS();
/** Check if writing to this path is allowed **/
bool CheckWritePermissions(const char* path);
/** Set new write permissions */
bool SetWritePermissions(u32 level);
/** Get write permissions */
u32 GetWritePermissions();
/** Create / overwrite file and write the provided data to it **/
bool FileCreate(const char* path, u8* data, u32 size);
/** 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);
/** Create a screenshot of the current framebuffer **/
void CreateScreenshot();
/** Get directory content under a given path **/
void GetDirContents(DirStruct* contents, const char* path);
/** Gets remaining space in filesystem in bytes */
uint64_t GetFreeSpace(const char* path);
/** Gets total spacein filesystem in bytes */
uint64_t GetTotalSpace(const char* path);
/** Helper function for copying DirEntry structs */
void DirEntryCpy(DirEntry* dest, const DirEntry* orig);