diff options
author | Jay Sorg <jay.sorg@gmail.com> | 2012-10-13 22:48:05 -0700 |
---|---|---|
committer | Jay Sorg <jay.sorg@gmail.com> | 2012-10-13 22:48:05 -0700 |
commit | e07dd5afb5a47b8a707f205727e0e4861b409f0a (patch) | |
tree | c6ab0737a730548f795e5b8bdbbd41a872212729 /common/os_calls.c | |
parent | c1dfea16131e1c3533f5b64a1f99254fe81d7a1f (diff) | |
download | xrdp-proprietary-e07dd5afb5a47b8a707f205727e0e4861b409f0a.tar.gz xrdp-proprietary-e07dd5afb5a47b8a707f205727e0e4861b409f0a.zip |
added a file open funtion
Diffstat (limited to 'common/os_calls.c')
-rw-r--r-- | common/os_calls.c | 38 |
1 files changed, 38 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) |