2020 *
2121 *
2222 * IDENTIFICATION
23- * $Header: /cvsroot/pgsql/src/bin/pg_dump/pg_backup_files.c,v 1.8 2001/03/22 04:00:13 momjian Exp $
23+ * $Header: /cvsroot/pgsql/src/bin/pg_dump/pg_backup_files.c,v 1.9 2001/03/23 01:27:12 pjw Exp $
2424 *
2525 * Modifications - 28-Jun-2000 - pjw@rhyme.com.au
2626 *
@@ -158,7 +158,9 @@ InitArchiveFmt_Files(ArchiveHandle *AH)
158158
159159 ReadHead (AH );
160160 ReadToc (AH );
161- fclose (AH -> FH ); /* Nothing else in the file... */
161+ /* Nothing else in the file... */
162+ if (fclose (AH -> FH ) != 0 )
163+ die_horribly (AH , "%s: Could not close TOC file (fclose failed).\n" , progname );
162164 }
163165
164166}
@@ -268,7 +270,9 @@ _EndData(ArchiveHandle *AH, TocEntry *te)
268270 lclTocEntry * tctx = (lclTocEntry * ) te -> formatData ;
269271
270272 /* Close the file */
271- GZCLOSE (tctx -> FH );
273+ if (GZCLOSE (tctx -> FH ) != 0 )
274+ die_horribly (AH , "%s: could not close data file\n" , progname );
275+
272276 tctx -> FH = NULL ;
273277}
274278
@@ -299,7 +303,9 @@ _PrintFileData(ArchiveHandle *AH, char *filename, RestoreOptions *ropt)
299303 ahwrite (buf , 1 , cnt , AH );
300304 }
301305
302- GZCLOSE (AH -> FH );
306+ if (GZCLOSE (AH -> FH ) != 0 )
307+ die_horribly (AH , "%s: could not close data file after reading\n" , progname );
308+
303309}
304310
305311
@@ -374,7 +380,8 @@ _LoadBlobs(ArchiveHandle *AH, RestoreOptions *ropt)
374380 _getBlobTocEntry (AH , & oid , fname );
375381 }
376382
377- fclose (ctx -> blobToc );
383+ if (fclose (ctx -> blobToc ) != 0 )
384+ die_horribly (AH , "%s: could not close BLOB TOC file\n" , progname );
378385
379386 EndRestoreBlobs (AH );
380387}
@@ -437,7 +444,8 @@ _CloseArchive(ArchiveHandle *AH)
437444 {
438445 WriteHead (AH );
439446 WriteToc (AH );
440- fclose (AH -> FH );
447+ if (fclose (AH -> FH ) != 0 )
448+ die_horribly (AH , "%s: could not close TOC file\n" , progname );
441449 WriteDataChunks (AH );
442450 }
443451
@@ -524,7 +532,8 @@ _EndBlob(ArchiveHandle *AH, TocEntry *te, int oid)
524532{
525533 lclTocEntry * tctx = (lclTocEntry * ) te -> formatData ;
526534
527- GZCLOSE (tctx -> FH );
535+ if (GZCLOSE (tctx -> FH ) != 0 )
536+ die_horribly (AH , "%s: could not close BLOB file\n" , progname );
528537}
529538
530539/*
@@ -541,6 +550,8 @@ _EndBlobs(ArchiveHandle *AH, TocEntry *te)
541550 /* Write out a fake zero OID to mark end-of-blobs. */
542551 /* WriteInt(AH, 0); */
543552
544- fclose (ctx -> blobToc );
553+ if (fclose (ctx -> blobToc ) != 0 )
554+ die_horribly (AH , "%s: could not close BLOB TOC file\n" , progname );
545555
546556}
557+
0 commit comments