filesystem rework

This commit is contained in:
2023-02-09 01:42:10 +06:00
parent 29a5b22286
commit 835bc5e834
10 changed files with 177 additions and 12 deletions

View File

@@ -8,11 +8,14 @@ extern "C" {
#include "../Array/Array.h"
#include "../String/string.h"
typedef char* FilePath;
Array_declare(FilePath);
typedef FILE File;
ktid_declare(File);
bool file_exists(char* path);
///@return Maybe<void>
Maybe file_delete(char* path, bool recursive);
PACK_ENUM(FileOpenMode,
// open a file for reading
FileOpenMode_Read=1,
@@ -24,14 +27,13 @@ PACK_ENUM(FileOpenMode,
FileOpenMode_ReadWrite=FileOpenMode_Read|FileOpenMode_Write,
// opens file for readng/writing additional data to the end / creates new file
FileOpenMode_ReadAppend=FileOpenMode_Read|FileOpenMode_Append
)
)
/// @brief opens file
/// @param path path to file
/// @param mode Read/Write/Append/ReadWrite/ReadAppend
/// @return Maybe<File*>
Maybe file_open(FilePath path, FileOpenMode mode);
Maybe file_open(char* path, FileOpenMode mode);
/// @brief closes file descriptor
/// @return Maybe<void>