#if !defined(LD_OS_FILESYSTEM_H_)
#define LD_OS_FILESYSTEM_H_

typedef U32 FS_AccessFlags;
enum {
	FS_ACCESS_READ  = (1 << 0),
	FS_ACCESS_WRITE = (1 << 1)
};

function OS_Handle FS_FileOpen(Str8 path, FS_AccessFlags access);
function void      FS_FileClose(OS_Handle file);

function void FS_FileRead(OS_Handle file, void *ptr, U64 size, U64 offset);
function void FS_FileWrite(OS_Handle file, void *ptr, U64 size, U64 offset);

function U64 FS_FileSize(OS_Handle file);

typedef U32 FS_EntryType;
enum {
	FS_ENTRY_TYPE_FILE = 0,
	FS_ENTRY_TYPE_DIR
};

typedef struct FS_Entry FS_Entry;
struct FS_Entry {
	FS_Entry *next;

	FS_EntryType type;

	Str8 path;
	Str8 basename;

	U64 time;
	U64 size;
};

typedef struct FS_List FS_List;
struct FS_List {
	FS_Entry *first;
	FS_Entry *last;

	U32 count;
};

function FS_List FS_PathList(M_Arena *arena, Str8 path);

function Str8 FS_ReadEntireFile(M_Arena *arena, Str8 path);

typedef U32 FS_SystemPathType;
enum {
	FS_SYSTEM_PATH_EXE = 0,
	FS_SYSTEM_PATH_WORKING,
	FS_SYSTEM_PATH_USER,
	FS_SYSTEM_PATH_TEMP
};

function Str8 FS_SystemPath(M_Arena *arena, FS_SystemPathType path);

#endif  // LD_OS_FILESYSTEM_H_
