diff options
-rw-r--r-- | common/os_calls.c | 38 | ||||
-rw-r--r-- | common/os_calls.h | 3 |
2 files changed, 41 insertions, 0 deletions
diff --git a/common/os_calls.c b/common/os_calls.c index 20c84f3e..602d6c0f 100644 --- a/common/os_calls.c +++ b/common/os_calls.c @@ -1371,6 +1371,44 @@ g_file_open(const char *file_name) } /*****************************************************************************/ +/* returns -1 on error, else return handle or file descriptor */ +int APP_CC +g_file_open_ex(const char *file_name, int aread, int awrite, + int acreate, int atrunc) +{ +#if defined(_WIN32) + return -1; +#else + int rv; + int flags; + + flags = 0; + if (aread && awrite) + { + flags |= O_RDWR; + } + else if (aread) + { + flags |= O_RDONLY; + } + else if (awrite) + { + flags |= O_WRONLY; + } + if (acreate) + { + flags |= O_CREAT; + } + if (atrunc) + { + flags |= O_TRUNC; + } + rv = open(file_name, flags, S_IRUSR | S_IWUSR); + return rv; +#endif +} + +/*****************************************************************************/ /* returns error, always 0 */ int APP_CC g_file_close(int fd) diff --git a/common/os_calls.h b/common/os_calls.h index c734c9fe..4bbd09de 100644 --- a/common/os_calls.h +++ b/common/os_calls.h @@ -133,6 +133,9 @@ g_memcmp(const void* s1, const void* s2, int len); int APP_CC g_file_open(const char* file_name); int APP_CC +g_file_open_ex(const char *file_name, int aread, int awrite, + int acreate, int atrunc); +int APP_CC g_file_close(int fd); int APP_CC g_file_read(int fd, char* ptr, int len); |