@@ -421,7 +421,7 @@ backup_data_file(backup_files_args* arguments,
421421 INIT_CRC32C (file -> crc );
422422
423423 /* open backup mode file for read */
424- in = fopen (file -> path , "r" );
424+ in = fopen (file -> path , PG_BINARY_R );
425425 if (in == NULL )
426426 {
427427 FIN_CRC32C (file -> crc );
@@ -455,7 +455,7 @@ backup_data_file(backup_files_args* arguments,
455455
456456 /* open backup file for write */
457457 join_path_components (to_path , to_root , file -> path + strlen (from_root ) + 1 );
458- out = fopen (to_path , "w" );
458+ out = fopen (to_path , PG_BINARY_W );
459459 if (out == NULL )
460460 {
461461 int errno_tmp = errno ;
@@ -547,7 +547,7 @@ restore_data_file(const char *from_root,
547547 BlockNumber blknum ;
548548
549549 /* open backup mode file for read */
550- in = fopen (file -> path , "r" );
550+ in = fopen (file -> path , PG_BINARY_R );
551551 if (in == NULL )
552552 {
553553 elog (ERROR , "cannot open backup file \"%s\": %s" , file -> path ,
@@ -562,7 +562,7 @@ restore_data_file(const char *from_root,
562562 join_path_components (to_path , to_root , file -> path + strlen (from_root ) + 1 );
563563 out = fopen (to_path , "r+" );
564564 if (out == NULL && errno == ENOENT )
565- out = fopen (to_path , "w" );
565+ out = fopen (to_path , PG_BINARY_W );
566566 if (out == NULL )
567567 {
568568 int errno_tmp = errno ;
@@ -694,7 +694,7 @@ copy_file(const char *from_root, const char *to_root, pgFile *file)
694694 file -> write_size = 0 ;
695695
696696 /* open backup mode file for read */
697- in = fopen (file -> path , "r" );
697+ in = fopen (file -> path , PG_BINARY_R );
698698 if (in == NULL )
699699 {
700700 FIN_CRC32C (crc );
@@ -710,7 +710,7 @@ copy_file(const char *from_root, const char *to_root, pgFile *file)
710710
711711 /* open backup file for write */
712712 join_path_components (to_path , to_root , file -> path + strlen (from_root ) + 1 );
713- out = fopen (to_path , "w" );
713+ out = fopen (to_path , PG_BINARY_W );
714714 if (out == NULL )
715715 {
716716 int errno_tmp = errno ;
@@ -1189,7 +1189,7 @@ calc_file_checksum(pgFile *file)
11891189 file -> write_size = 0 ;
11901190
11911191 /* open backup mode file for read */
1192- in = fopen (file -> path , "r" );
1192+ in = fopen (file -> path , PG_BINARY_R );
11931193 if (in == NULL )
11941194 {
11951195 FIN_CRC32C (crc );
0 commit comments