Skip to content
Snippets Groups Projects
Commit 0208369f authored by Phil Pemberton's avatar Phil Pemberton
Browse files

Set binary mode on stdin and stdout too

On Windows, stdin and stdout are opened in text mode. We need to reopen them in binary mode in case users are piping compressed data around.
parent afdf43d1
No related branches found
No related tags found
No related merge requests found
......@@ -455,6 +455,15 @@ int main(int argc, char **argv) {
cfg.out = handle_open(cfg.out_fname, IO_WRITE, cfg.buffer_size);
if (cfg.out == NULL) { die("Failed to open output file for write"); }
#if _WIN32
/*
* On Windows, stdin and stdout default to text mode. Switch them to
* binary mode before sending data through them.
*/
_setmode(STDOUT_FILENO, O_BINARY);
_setmode(STDIN_FILENO, O_BINARY);
#endif
if (cfg.cmd == OP_ENC) {
return encode(&cfg);
} else if (cfg.cmd == OP_DEC) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment