Implement functions to get stdin, stdout & stderr
All checks were successful
Release / release (push) Successful in 2s
All checks were successful
Release / release (push) Successful in 2s
This commit is contained in:
@@ -12,9 +12,6 @@ BEGIN_C_LINKAGE
|
||||
#endif // !WAPP_PLATFORM_CPP
|
||||
|
||||
typedef struct WFile WFile;
|
||||
wapp_extern WFile *WF_STDIN;
|
||||
wapp_extern WFile *WF_STDOUT;
|
||||
wapp_extern WFile *WF_STDERR;
|
||||
|
||||
typedef enum {
|
||||
WAPP_ACCESS_READ, // Equivalent to r
|
||||
@@ -37,6 +34,9 @@ typedef enum {
|
||||
FILE_SEEK_ORIGIN_COUNT,
|
||||
} FileSeekOrigin;
|
||||
|
||||
wapp_extern WFile *wapp_file_stdin(void);
|
||||
wapp_extern WFile *wapp_file_stdout(void);
|
||||
wapp_extern WFile *wapp_file_stderr(void);
|
||||
WFile *wapp_file_open(const Allocator *allocator, Str8RO *filepath, FileAccessMode mode);
|
||||
i64 wapp_file_get_current_position(WFile *file);
|
||||
i64 wapp_file_seek(WFile *file, i64 offset, FileSeekOrigin origin);
|
||||
|
||||
@@ -49,13 +49,20 @@ wapp_intern i32 file_seek_origins[FILE_SEEK_ORIGIN_COUNT] = {
|
||||
[WAPP_SEEK_END] = SEEK_END,
|
||||
};
|
||||
|
||||
wapp_intern WFile _STDIN = { .fd = STDIN_FILENO };
|
||||
wapp_intern WFile _STDOUT = { .fd = STDOUT_FILENO };
|
||||
wapp_intern WFile _STDERR = { .fd = STDERR_FILENO };
|
||||
WFile *wapp_file_stdin(void) {
|
||||
wapp_persist WFile _stdin = { .fd = STDIN_FILENO };
|
||||
return &_stdin;
|
||||
}
|
||||
|
||||
WFile *WF_STDIN = &_STDIN;
|
||||
WFile *WF_STDOUT = &_STDOUT;
|
||||
WFile *WF_STDERR = &_STDERR;
|
||||
WFile *wapp_file_stdout(void) {
|
||||
wapp_persist WFile _stdout = { .fd = STDOUT_FILENO };
|
||||
return &_stdout;
|
||||
}
|
||||
|
||||
WFile *wapp_file_stderr(void) {
|
||||
wapp_persist WFile _stderr = { .fd = STDERR_FILENO };
|
||||
return &_stderr;
|
||||
}
|
||||
|
||||
WFile *_file_open(const Allocator *allocator, Str8RO *filepath, FileAccessMode mode) {
|
||||
wapp_persist c8 tmp[WAPP_PATH_MAX] = {0};
|
||||
|
||||
@@ -54,6 +54,24 @@ wapp_intern DWORD file_seek_origins[FILE_SEEK_ORIGIN_COUNT] = {
|
||||
[WAPP_SEEK_END] = FILE_END,
|
||||
};
|
||||
|
||||
WFile *wapp_file_stdin(void) {
|
||||
wapp_persist WFile _stdin = { .fh = INVALID_HANDLE_VALUE };
|
||||
_stdin.fh = GetStdHandle(STD_INPUT_HANDLE);
|
||||
return &_stdin;
|
||||
}
|
||||
|
||||
WFile *wapp_file_stdout(void) {
|
||||
wapp_persist WFile _stdout = { .fh = INVALID_HANDLE_VALUE };
|
||||
_stdout.fh = GetStdHandle(STD_OUTPUT_HANDLE);
|
||||
return &_stdout;
|
||||
}
|
||||
|
||||
WFile *wapp_file_stderr(void) {
|
||||
wapp_persist WFile _stderr = { .fh = INVALID_HANDLE_VALUE };
|
||||
_stderr.fh = GetStdHandle(STD_ERROR_HANDLE);
|
||||
return &_stderr;
|
||||
}
|
||||
|
||||
WFile *_file_open(const Allocator *allocator, Str8RO *filepath, FileAccessMode mode) {
|
||||
wapp_persist c8 tmp[WAPP_PATH_MAX] = {0};
|
||||
memset(tmp, 0, WAPP_PATH_MAX);
|
||||
|
||||
Reference in New Issue
Block a user