Mercurial > hg > index.cgi
changeset 265:6f4c4d59666f
Make lwar use the "b" flag when opening files.
Due to the dumbness on Windows systems related to text vs. binary file
distinctions, one needs to add 'b' to fopen() calls when dealing with binary
files.
author | William Astle <lost@l-w.ca> |
---|---|
date | Sun, 10 Feb 2013 19:22:24 -0700 |
parents | 346966cffeef |
children | 35c051bffbff |
files | lwar/add.c lwar/extract.c lwar/list.c lwar/replace.c |
diffstat | 4 files changed, 10 insertions(+), 10 deletions(-) [+] |
line wrap: on
line diff
--- a/lwar/add.c Wed Feb 06 21:43:10 2013 -0700 +++ b/lwar/add.c Sun Feb 10 19:22:24 2013 -0700 @@ -38,12 +38,12 @@ FILE *f2; int i; - f = fopen(archive_file, "r+"); + f = fopen(archive_file, "rb+"); if (!f) { if (errno == ENOENT) { - f = fopen(archive_file, "w"); + f = fopen(archive_file, "wb"); if (f) { fputs("LWAR1V", f); @@ -106,7 +106,7 @@ doadd: for (i = 0; i < nfiles; i++) { - f2 = fopen(files[i], "r"); + f2 = fopen(files[i], "rb"); if (!f2) { fprintf(stderr, "Cannot open file %s:", files[i]);
--- a/lwar/extract.c Wed Feb 06 21:43:10 2013 -0700 +++ b/lwar/extract.c Sun Feb 10 19:22:24 2013 -0700 @@ -36,7 +36,7 @@ int i; FILE *nf; - f = fopen(archive_file, "r"); + f = fopen(archive_file, "rb"); if (!f) { perror("Opening archive file"); @@ -98,7 +98,7 @@ if (i < nfiles || nfiles == 0) { // extract the file - nf = fopen(fnbuf, "w"); + nf = fopen(fnbuf, "wb"); if (!nf) { fprintf(stderr, "Cannot extract '%s': %s\n", fnbuf, strerror(errno));
--- a/lwar/list.c Wed Feb 06 21:43:10 2013 -0700 +++ b/lwar/list.c Sun Feb 10 19:22:24 2013 -0700 @@ -36,7 +36,7 @@ long l; int c; - f = fopen(archive_file, "r"); + f = fopen(archive_file, "rb"); if (!f) { perror("Opening archive file");
--- a/lwar/replace.c Wed Feb 06 21:43:10 2013 -0700 +++ b/lwar/replace.c Sun Feb 10 19:22:24 2013 -0700 @@ -41,12 +41,12 @@ sprintf(fnbuf, "%s.tmp", archive_file); - f = fopen(archive_file, "r+"); + f = fopen(archive_file, "rb+"); if (!f) { if (errno == ENOENT) { - nf = fopen(fnbuf, "w"); + nf = fopen(fnbuf, "wb"); if (nf) { fputs("LWAR1V", nf); @@ -63,7 +63,7 @@ exit(1); } - nf = fopen(fnbuf, "w"); + nf = fopen(fnbuf, "wb"); if (!nf) { perror("Cannot create temp archive file"); @@ -146,7 +146,7 @@ doadd: for (i = 0; i < nfiles; i++) { - f2 = fopen(files[i], "r"); + f2 = fopen(files[i], "rb"); if (!f2) { fprintf(stderr, "Cannot open file %s:", files[i]);