From 76d85a10f6cda93eba29dad5372e8160af7289c8 Mon Sep 17 00:00:00 2001 From: dec05eba Date: Wed, 27 Feb 2019 22:26:35 +0100 Subject: Use multiple threads to parse --- include/std/file.h | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 include/std/file.h (limited to 'include/std/file.h') diff --git a/include/std/file.h b/include/std/file.h new file mode 100644 index 0000000..ac2abec --- /dev/null +++ b/include/std/file.h @@ -0,0 +1,27 @@ +#ifndef AMALGAM_FILE_H +#define AMALGAM_FILE_H + +#include "misc.h" +#include "types.h" + +/* Return bool_true if you want to continue scanning, otherwise return bool_false */ +typedef bool (*scan_dir_callback_func)(const char *filepath, int filepath_length, void *userdata); + +typedef struct { + const char *file_data; + usize file_size; + int fd; +} MappedFile; + +typedef enum { + MAPPED_FILE_READ, + MAPPED_FILE_WRITE, + MAPPED_FILE_READ_WRITE +} MappedFileMode; + +/* Hidden files (files starting with a dot) are skipped */ +CHECK_RESULT int scan_dir_recursive(const char *dir_path, scan_dir_callback_func callback_func, void *userdata); +CHECK_RESULT int mapped_file_init(MappedFile *self, const char *filepath, MappedFileMode file_mode); +CHECK_RESULT int mapped_file_deinit(MappedFile *self); + +#endif \ No newline at end of file -- cgit v1.2.3