Skip to content

Commit e7665c1

Browse files
committed
Arthur Zakirov: fopen() in binary mode
1 parent 7e8cffb commit e7665c1

File tree

2 files changed

+5
-4
lines changed

2 files changed

+5
-4
lines changed

src/data.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -865,7 +865,7 @@ push_wal_file(const char *from_path, const char *to_path, bool is_compress,
865865
#endif
866866

867867
/* open file for read */
868-
in = fopen(from_path, "r");
868+
in = fopen(from_path, "rb");
869869
if (in == NULL)
870870
elog(ERROR, "Cannot open source WAL file \"%s\": %s", from_path,
871871
strerror(errno));
@@ -896,7 +896,7 @@ push_wal_file(const char *from_path, const char *to_path, bool is_compress,
896896

897897
snprintf(to_path_temp, sizeof(to_path_temp), "%s.partial", to_path);
898898

899-
out = fopen(to_path_temp, "w");
899+
out = fopen(to_path_temp, "wb");
900900
if (out == NULL)
901901
elog(ERROR, "Cannot open destination WAL file \"%s\": %s",
902902
to_path_temp, strerror(errno));
@@ -1018,7 +1018,7 @@ get_wal_file(const char *from_path, const char *to_path)
10181018
#endif
10191019

10201020
/* open file for read */
1021-
in = fopen(from_path, "r");
1021+
in = fopen(from_path, "rb");
10221022
if (in == NULL)
10231023
{
10241024
#ifdef HAVE_LIBZ
@@ -1055,7 +1055,7 @@ get_wal_file(const char *from_path, const char *to_path)
10551055
/* open backup file for write */
10561056
snprintf(to_path_temp, sizeof(to_path_temp), "%s.partial", to_path);
10571057

1058-
out = fopen(to_path_temp, "w");
1058+
out = fopen(to_path_temp, "wb");
10591059
if (out == NULL)
10601060
elog(ERROR, "Cannot open destination WAL file \"%s\": %s",
10611061
to_path_temp, strerror(errno));

src/pg_probackup.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -514,6 +514,7 @@ extern bool is_pg_running(void);
514514
#define read _read
515515
#define close _close
516516
#define write _write
517+
#define mkdir(dir,mode) _mkdir(dir)
517518
#endif
518519
#endif
519520

0 commit comments

Comments
 (0)