15
15
*
16
16
*
17
17
* IDENTIFICATION
18
- *$PostgreSQL: pgsql/src/bin/pg_dump/pg_backup_archiver.c,v 1.103 2005/01/25 22 :44:31 tgl Exp $
18
+ *$PostgreSQL: pgsql/src/bin/pg_dump/pg_backup_archiver.c,v 1.104 2005/01/26 19 :44:43 tgl Exp $
19
19
*
20
20
*-------------------------------------------------------------------------
21
21
*/
29
29
#include <ctype.h>
30
30
#include <unistd.h>
31
31
32
+ #ifdef WIN32
33
+ #include <io.h>
34
+ #endif
35
+
32
36
#include "pqexpbuffer.h"
33
37
#include "libpq/libpq-fs.h"
34
38
@@ -1709,6 +1713,21 @@ _allocAH(const char *FileSpec, const ArchiveFormat fmt,
1709
1713
AH -> gzOut = 0 ;
1710
1714
AH -> OF = stdout ;
1711
1715
1716
+ /*
1717
+ * On Windows, we need to use binary mode to read/write non-text archive
1718
+ * formats. Force stdin/stdout into binary mode in case that is what
1719
+ * we are using.
1720
+ */
1721
+ #ifdef WIN32
1722
+ if (fmt != archNull )
1723
+ {
1724
+ if (mode == archModeWrite )
1725
+ setmode (fileno (stdout ),O_BINARY );
1726
+ else
1727
+ setmode (fileno (stdin ),O_BINARY );
1728
+ }
1729
+ #endif
1730
+
1712
1731
#if 0
1713
1732
write_msg (modulename ,"archive format is %d\n" ,fmt );
1714
1733
#endif
@@ -1720,7 +1739,6 @@ _allocAH(const char *FileSpec, const ArchiveFormat fmt,
1720
1739
1721
1740
switch (AH -> format )
1722
1741
{
1723
-
1724
1742
case archCustom :
1725
1743
InitArchiveFmt_Custom (AH );
1726
1744
break ;