|
16 | 16 | *
|
17 | 17 | *
|
18 | 18 | * IDENTIFICATION
|
19 |
| - *$PostgreSQL: pgsql/src/bin/pg_dump/pg_backup_tar.c,v 1.52 2006/06/07 22:24:44 momjian Exp $ |
| 19 | + *$PostgreSQL: pgsql/src/bin/pg_dump/pg_backup_tar.c,v 1.53 2006/06/27 01:16:58 momjian Exp $ |
20 | 20 | *
|
21 | 21 | *-------------------------------------------------------------------------
|
22 | 22 | */
|
@@ -359,7 +359,35 @@ tarOpen(ArchiveHandle *AH, const char *filename, char mode)
|
359 | 359 | {
|
360 | 360 | tm=calloc(1,sizeof(TAR_MEMBER));
|
361 | 361 |
|
| 362 | +#ifndefWIN32 |
362 | 363 | tm->tmpFH=tmpfile();
|
| 364 | +#else |
| 365 | +/* |
| 366 | + *On WIN32, tmpfile() generates a filename in the root directory, |
| 367 | + *which requires administrative permissions on certain systems. |
| 368 | + *Loop until we find a unique file name we can create. |
| 369 | + */ |
| 370 | +while (1) |
| 371 | +{ |
| 372 | +char*name; |
| 373 | +intfd; |
| 374 | + |
| 375 | +name=_tempnam(NULL,"pg_temp_"); |
| 376 | +if (name==NULL) |
| 377 | +break; |
| 378 | +fd=open(name,O_RDWR |O_CREAT |O_EXCL |O_BINARY | |
| 379 | +O_TEMPORARY,S_IREAD |S_IWRITE); |
| 380 | +free(name); |
| 381 | + |
| 382 | +if (fd!=-1)/* created a file */ |
| 383 | +{ |
| 384 | +tm->tmpFH=fdopen(fd,"w+b"); |
| 385 | +break; |
| 386 | +} |
| 387 | +elseif (errno!=EEXIST)/* failure other than file exists */ |
| 388 | +break; |
| 389 | +} |
| 390 | +#endif |
363 | 391 |
|
364 | 392 | if (tm->tmpFH==NULL)
|
365 | 393 | die_horribly(AH,modulename,"could not generate temporary file name: %s\n",strerror(errno));
|
|