2022-06-06 10:49:19 +00:00
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#if defined(_WIN32)
|
|
|
|
#define _os_win
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#if defined(__linux__) && !defined(__ANDROID__)
|
|
|
|
#define _os_linux
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#if !(defined(_os_win) \
|
|
|
|
|| defined(_os_linux))
|
|
|
|
#error "Unsupported OS"
|
|
|
|
#endif
|
2022-06-07 02:57:57 +00:00
|
|
|
|
|
|
|
// OS-dependent IO Functions
|
2022-06-08 03:31:06 +00:00
|
|
|
|
|
|
|
// TODO: see if we need this or will it be easier for linux to just pass
|
|
|
|
// the mode string.
|
|
|
|
typedef struct _OS_ModeFlags {
|
|
|
|
int base_mode;
|
|
|
|
int binary;
|
|
|
|
int update;
|
|
|
|
int exclusive;
|
|
|
|
} _OS_ModeFlags;
|
|
|
|
|
2022-06-07 02:57:57 +00:00
|
|
|
typedef struct FILE FILE;
|
2022-06-08 03:31:06 +00:00
|
|
|
int _os_del_file(char const *filename);
|
|
|
|
int _os_mov_file(char const *old, char const *new);
|
|
|
|
char *_os_tmpname(char *buffer);
|
|
|
|
FILE *_os_fopen(char const *restrict name, _OS_ModeFlags flags);
|
|
|
|
int _os_fclose(FILE *file);
|
|
|
|
void _os_file_write(void* ctx, size_t n, const char str[]);
|
|
|
|
|
|
|
|
void _os_init_eh();
|
|
|
|
|
|
|
|
_Noreturn void _os_exit(int code);
|