diff options
Diffstat (limited to 'src/port/open.c')
-rw-r--r-- | src/port/open.c | 31 |
1 files changed, 29 insertions, 2 deletions
diff --git a/src/port/open.c b/src/port/open.c index 4df74d8b51b..268f2d31a24 100644 --- a/src/port/open.c +++ b/src/port/open.c @@ -6,7 +6,7 @@ * * Portions Copyright (c) 1996-2006, PostgreSQL Global Development Group * - * $PostgreSQL: pgsql/src/port/open.c,v 1.13 2006/06/25 00:18:24 momjian Exp $ + * $PostgreSQL: pgsql/src/port/open.c,v 1.14 2006/08/30 18:06:27 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -19,7 +19,6 @@ #include <fcntl.h> #include <assert.h> -int pgwin32_open(const char *fileName, int fileFlags,...); static int openFlagsToCreateFileFlags(int openFlags) @@ -112,4 +111,32 @@ pgwin32_open(const char *fileName, int fileFlags,...) return fd; } +FILE * +pgwin32_fopen(const char *fileName, const char *mode) +{ + int openmode = 0; + int fd; + + if (strstr(mode, "r+")) + openmode |= O_RDWR; + else if (strchr(mode, 'r')) + openmode |= O_RDONLY; + if (strstr(mode, "w+")) + openmode |= O_RDWR | O_CREAT | O_TRUNC; + else if (strchr(mode, 'w')) + openmode |= O_WRONLY | O_CREAT | O_TRUNC; + if (strchr(mode, 'a')) + openmode |= O_WRONLY | O_APPEND; + + if (strchr(mode, 'b')) + openmode |= O_BINARY; + if (strchr(mode, 't')) + openmode |= O_TEXT; + + fd = pgwin32_open(fileName, openmode); + if (fd == -1) + return NULL; + return _fdopen(fd, mode); +} + #endif |