ref: df5e906b63df59fa00c84cb7ee25e240ffd32bcd
parent: decd4a95579082c578862c4e36948b194a399b41
author: SmilingWolf <[email protected]>
date: Tue Sep 25 08:38:16 EDT 2018
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
--- a/tools/input/ivf.c
+++ b/tools/input/ivf.c
@@ -49,7 +49,7 @@
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) {
--- a/tools/output/md5.c
+++ b/tools/output/md5.c
@@ -76,7 +76,7 @@
{
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;
}
--- a/tools/output/y4m2.c
+++ b/tools/output/y4m2.c
@@ -44,7 +44,7 @@
{
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;
}
--- a/tools/output/yuv.c
+++ b/tools/output/yuv.c
@@ -45,7 +45,7 @@
{
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;
}