#ifndef __File__H
#define __File__H

#include "WimpLib:std.h"
#include <stdint.h>
#include <stdio.h>

#include <stdbool.h>
#include "kernel.h"
#include "WimpLib:Coords.h"

#ifdef __cplusplus
extern "C" {
#endif

#define MAXPATH 1024
#define FILE_FILESYSTEM_CHAR ':'
#define FILE_UPFOLDER_CHAR   '^'
#define FILE_FOLDER_CHAR     '.'
#define FILE_EXTENSION_CHAR  '/'

typedef struct
{
	file_type type;
	uint32_t  loadaddr;
	uint32_t  execaddr;
	uint32_t  size;
	uint32_t  attributes;
	uint32_t  filetype;
} File_Info;

const char* throw_File_FromRes(const char* leafname);
const char* File_GetLeafName(const char* filename);
File_Info File_GetInfo(const char* filename);
file_type File_GetFileType(const char* filename);
uint32_t File_TypeFromString(const char* str);
const _kernel_oserror* File_SetFileType(const char* filename, uint32_t type);
const _kernel_oserror* File_Copy(const char* oldfilename, const char* newfilename);
const _kernel_oserror* File_Delete(const char* filename);
const _kernel_oserror* File_EnsurePath(const char* filename);
const _kernel_oserror* Path_Ensure(const char* pathname);
int Dir_ReadEntry(const char* dirname, int entry, char* buffer);
bool File_FindSection(FILE* file, const char* section, bool bRestart);
void File_FindEndOfSection(FILE* file);
char* throw_File_CanonicalPath(const char* pname);

#ifdef __cplusplus
}
#endif

#endif
