Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit3a6e2ff

Browse files
committed
Fix things so that fopen's, not only open's, pass FILE_SHARE_DELETE
and other special flags on Windows. May fix intermittent 'Permissiondenied' errors. Magnus Hagander
1 parentf6d7ef0 commit3a6e2ff

File tree

2 files changed

+35
-5
lines changed

2 files changed

+35
-5
lines changed

‎src/include/port.h

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
* Portions Copyright (c) 1996-2006, PostgreSQL Global Development Group
77
* Portions Copyright (c) 1994, Regents of the University of California
88
*
9-
* $PostgreSQL: pgsql/src/include/port.h,v 1.96 2006/08/18 15:47:08 momjian Exp $
9+
* $PostgreSQL: pgsql/src/include/port.h,v 1.97 2006/08/30 18:06:27 tgl Exp $
1010
*
1111
*-------------------------------------------------------------------------
1212
*/
@@ -264,12 +264,15 @@ extern bool rmtree(char *path, bool rmtopdir);
264264

265265
#if defined(WIN32)&& !defined(__CYGWIN__)
266266

267-
/* open() replacement to allow delete of held files and passing
268-
* of special options. */
267+
/* open() and fopen() replacements to allow deletion of open files and
268+
* passing of other special options.
269+
*/
269270
externintpgwin32_open(constchar*,int,...);
271+
externFILE*pgwin32_fopen(constchar*,constchar*);
270272

271273
#ifndefFRONTEND
272274
#defineopen(a,b,c)pgwin32_open(a,b,c)
275+
#definefopen(a,b) pgwin32_fopen(a,b)
273276
#endif
274277

275278
#definepopen(a,b) _popen(a,b)

‎src/port/open.c

Lines changed: 29 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
*
77
* Portions Copyright (c) 1996-2006, PostgreSQL Global Development Group
88
*
9-
* $PostgreSQL: pgsql/src/port/open.c,v 1.13 2006/06/25 00:18:24 momjian Exp $
9+
* $PostgreSQL: pgsql/src/port/open.c,v 1.14 2006/08/3018:06:27 tgl Exp $
1010
*
1111
*-------------------------------------------------------------------------
1212
*/
@@ -19,7 +19,6 @@
1919
#include<fcntl.h>
2020
#include<assert.h>
2121

22-
intpgwin32_open(constchar*fileName,intfileFlags,...);
2322

2423
staticint
2524
openFlagsToCreateFileFlags(intopenFlags)
@@ -112,4 +111,32 @@ pgwin32_open(const char *fileName, int fileFlags,...)
112111
returnfd;
113112
}
114113

114+
FILE*
115+
pgwin32_fopen(constchar*fileName,constchar*mode)
116+
{
117+
intopenmode=0;
118+
intfd;
119+
120+
if (strstr(mode,"r+"))
121+
openmode |=O_RDWR;
122+
elseif (strchr(mode,'r'))
123+
openmode |=O_RDONLY;
124+
if (strstr(mode,"w+"))
125+
openmode |=O_RDWR |O_CREAT |O_TRUNC;
126+
elseif (strchr(mode,'w'))
127+
openmode |=O_WRONLY |O_CREAT |O_TRUNC;
128+
if (strchr(mode,'a'))
129+
openmode |=O_WRONLY |O_APPEND;
130+
131+
if (strchr(mode,'b'))
132+
openmode |=O_BINARY;
133+
if (strchr(mode,'t'))
134+
openmode |=O_TEXT;
135+
136+
fd=pgwin32_open(fileName,openmode);
137+
if (fd==-1)
138+
returnNULL;
139+
return_fdopen(fd,mode);
140+
}
141+
115142
#endif

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp