diff options
author | SmilingWolf <lupo996@gmail.com> | 2018-09-25 13:38:16 +0300 |
---|---|---|
committer | Jean-Baptiste Kempf <jb@videolan.org> | 2018-09-27 19:28:58 +0300 |
commit | df5e906b63df59fa00c84cb7ee25e240ffd32bcd (patch) | |
tree | 02de8fe211a8e78195ffb3b518066c94025a68be /tools | |
parent | decd4a95579082c578862c4e36948b194a399b41 (diff) |
Update fopen calls for Windows compatibility
Open files in binary mode, or on Windows fread/fwrite will treat the files as text and mangle the read/written data
Diffstat (limited to 'tools')
-rw-r--r-- | tools/input/ivf.c | 2 | ||||
-rw-r--r-- | tools/output/md5.c | 2 | ||||
-rw-r--r-- | tools/output/y4m2.c | 2 | ||||
-rw-r--r-- | tools/output/yuv.c | 2 |
4 files changed, 4 insertions, 4 deletions
diff --git a/tools/input/ivf.c b/tools/input/ivf.c index 2e47d32..a8f7810 100644 --- a/tools/input/ivf.c +++ b/tools/input/ivf.c @@ -49,7 +49,7 @@ static int ivf_open(IvfInputContext *const c, const char *const file, uint8_t hdr[32]; memset(c, 0, sizeof(*c)); - if (!(c->f = fopen(file, "r"))) { + if (!(c->f = fopen(file, "rb"))) { fprintf(stderr, "Failed to open %s: %s\n", file, strerror(errno)); return -1; } else if ((res = fread(hdr, 32, 1, c->f)) != 1) { diff --git a/tools/output/md5.c b/tools/output/md5.c index 0fe0c3e..a6d92d6 100644 --- a/tools/output/md5.c +++ b/tools/output/md5.c @@ -76,7 +76,7 @@ static int md5_open(MD5Context *const md5, const char *const file, { if (!strcmp(file, "-")) { md5->f = stdout; - } else if (!(md5->f = fopen(file, "w"))) { + } else if (!(md5->f = fopen(file, "wb"))) { fprintf(stderr, "Failed to open %s: %s\n", file, strerror(errno)); return -1; } diff --git a/tools/output/y4m2.c b/tools/output/y4m2.c index 5c9ed93..94e8b66 100644 --- a/tools/output/y4m2.c +++ b/tools/output/y4m2.c @@ -44,7 +44,7 @@ static int y4m2_open(Y4m2OutputContext *const c, const char *const file, { if (!strcmp(file, "-")) { c->f = stdout; - } else if (!(c->f = fopen(file, "w"))) { + } else if (!(c->f = fopen(file, "wb"))) { fprintf(stderr, "Failed to open %s: %s\n", file, strerror(errno)); return -1; } diff --git a/tools/output/yuv.c b/tools/output/yuv.c index 07d9518..406f284 100644 --- a/tools/output/yuv.c +++ b/tools/output/yuv.c @@ -45,7 +45,7 @@ static int yuv_open(YuvOutputContext *const c, const char *const file, { if (!strcmp(file, "-")) { c->f = stdout; - } else if (!(c->f = fopen(file, "w"))) { + } else if (!(c->f = fopen(file, "wb"))) { fprintf(stderr, "Failed to open %s: %s\n", file, strerror(errno)); return -1; } |