port os functions, add testing module
This commit is contained in:
97
src/os/os.h
97
src/os/os.h
@@ -9,42 +9,73 @@ struct os_date_t {
|
||||
u16 year;
|
||||
};
|
||||
|
||||
fn os_date_t os_local_time_now(void);
|
||||
fn os_date_t os_universal_time_now(void);
|
||||
fn f64 os_milliseconds_now(void);
|
||||
typedef struct os_iter_t os_iter_t;
|
||||
struct os_iter_t {
|
||||
s8_t abs;
|
||||
s8_t rel;
|
||||
s8_t name;
|
||||
b8 is_directory;
|
||||
b8 is_valid;
|
||||
|
||||
#if 0
|
||||
fn u64 os_microseconds_now();
|
||||
fn f64 os_seconds_now();
|
||||
fn u32 os_unix_time_now();
|
||||
s8_t path;
|
||||
ma_arena_t *arena;
|
||||
|
||||
fn os_date_t os_local_time_to_universal_time();
|
||||
fn os_date_t os_universal_time_to_local_time();
|
||||
union {
|
||||
struct w32_file_iter_t *w32;
|
||||
void *platform;
|
||||
};
|
||||
};
|
||||
|
||||
fn void os_sleep_milliseconds();
|
||||
typedef enum {
|
||||
os_mkdir_success,
|
||||
os_mkdir_file_exists,
|
||||
os_mkdir_path_not_found,
|
||||
os_mkdir_other_error,
|
||||
} os_mkdir_t;
|
||||
|
||||
typedef enum {
|
||||
os_write_success,
|
||||
os_write_path_not_found,
|
||||
os_write_other_error,
|
||||
} os_write_t;
|
||||
|
||||
fn os_date_t os_local_time(void);
|
||||
fn os_date_t os_universal_time(void);
|
||||
fn s8_t os_format_date(ma_arena_t *arena, os_date_t date);
|
||||
fn f64 os_seconds(void);
|
||||
fn f64 os_milliseconds(void);
|
||||
|
||||
fn b32 os_copy(s8_t from, s8_t to, b32 overwrite);
|
||||
fn b32 os_delete(s8_t path);
|
||||
fn os_mkdir_t os_mkdir(s8_t path);
|
||||
fn os_write_t os_write(s8_t path, s8_t content);
|
||||
|
||||
fn void os_advance(os_iter_t *it);
|
||||
fn os_iter_t *os_iter(ma_arena_t *arena, s8_t path);
|
||||
|
||||
fn i64 os_mod_time(s8_t file);
|
||||
fn s8_t os_abs(ma_arena_t *arena, s8_t rel);
|
||||
fn s8_t os_exe(ma_arena_t *arena);
|
||||
fn s8_t os_exe_dir(ma_arena_t *arena);
|
||||
fn b32 os_is_dir(s8_t path);
|
||||
fn b32 os_is_file(s8_t path);
|
||||
fn b32 os_is_abs(s8_t path);
|
||||
fn b32 os_exists(s8_t path);
|
||||
|
||||
fn s8_t os_cwd(ma_arena_t *arena);
|
||||
fn void os_set_cwd(s8_t new_cwd);
|
||||
|
||||
|
||||
fn s8_t os_list_files(arena, path, recursive);
|
||||
fn os_file_iter_t os_iterate_files();
|
||||
fn void os_advance()
|
||||
fn b32 os_is_valid();
|
||||
typedef i32 os_thread_fn_t(void *user_data);
|
||||
typedef struct os_thread_t os_thread_t;
|
||||
struct os_thread_t {
|
||||
b32 exited;
|
||||
i32 exit_code;
|
||||
union {
|
||||
struct w32_thread_t *w32;
|
||||
void *ptr;
|
||||
};
|
||||
};
|
||||
|
||||
fn s8_t os_read_file(ma_arena_t *arena, s8_t path);
|
||||
fn void os_write_file(s8_t path, s8_t content);
|
||||
fn void os_make_dir(s8_t path);
|
||||
fn os_result_t os_copy_file(s8_t from, s8_t to, b32 overwrite);
|
||||
fn os_result_t os_delete_file(s8_t path);
|
||||
fn i64 os_get_file_mod_time(s8_t path);
|
||||
|
||||
fn b32 os_path_exists(s8_t path);
|
||||
fn b32 os_path_is_dir(s8_t path);
|
||||
fn b32 os_path_is_file(s8_t path);
|
||||
fn b32 os_path_is_abs(s8_t path);
|
||||
fn b32 os_path_is_rel(s8_t path);
|
||||
fn s8_t os_path_to_abs(ma_arena_t *arena, s8_t path);
|
||||
|
||||
fn s8_t os_path_exe(ma_arena_t *arena);
|
||||
fn s8_t os_path_exe_dir(ma_arena_t *arena);
|
||||
fn s8_t os_path_cwd(ma_arena_t *arena);
|
||||
fn void os_path_set_cwd(s8_t path);
|
||||
#endif
|
||||
fn os_thread_t os_thread_create(ma_arena_t *arena, os_thread_fn_t *func, void *user_data);
|
||||
fn i32 os_thread_wait_for_exit(os_thread_t *thread);
|
||||
|
||||
Reference in New Issue
Block a user