Index: src/include/port.h =================================================================== RCS file: /projects/cvsroot/pgsql/src/include/port.h,v retrieving revision 1.96 diff -c -r1.96 port.h *** src/include/port.h 18 Aug 2006 15:47:08 -0000 1.96 --- src/include/port.h 30 Aug 2006 17:37:44 -0000 *************** *** 267,275 **** --- 267,277 ---- /* open() replacement to allow delete of held files and passing * of special options. */ extern int pgwin32_open(const char *, int,...); + extern FILE *pgwin32_fopen(const char *, const char *); #ifndef FRONTEND #define open(a,b,c) pgwin32_open(a,b,c) + #define fopen(a,b) pgwin32_fopen(a,b) #endif #define popen(a,b) _popen(a,b) Index: src/port/open.c =================================================================== RCS file: /projects/cvsroot/pgsql/src/port/open.c,v retrieving revision 1.13 diff -c -r1.13 open.c *** src/port/open.c 25 Jun 2006 00:18:24 -0000 1.13 --- src/port/open.c 30 Aug 2006 17:37:50 -0000 *************** *** 20,25 **** --- 20,26 ---- #include int pgwin32_open(const char *fileName, int fileFlags,...); + FILE *pgwin32_fopen(const char *fileName, const char *mode); static int openFlagsToCreateFileFlags(int openFlags) *************** *** 112,115 **** --- 113,143 ---- return fd; } + FILE * + pgwin32_fopen(const char *fileName, const char *mode) + { + int openmode = 0; + int fd; + + if (strchr(mode, 'a')) + openmode |= O_WRONLY | O_APPEND; + if (strchr(mode, 'r')) + openmode |= O_RDONLY; + if (strstr(mode, "r+")) + openmode |= O_RDWR; + if (strchr(mode, 'w')) + openmode |= O_WRONLY | O_CREAT | O_TRUNC; + if (strstr(mode, "w+")) + openmode |= O_RDWR | O_CREAT | O_TRUNC; + 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