# HG changeset patch # User William Astle # Date 1360549344 25200 # Node ID 6f4c4d59666ffcbc12b6eae3fb6256d993e2fa24 # Parent 346966cffeef960b5412155a7dc16f91c18cf655 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. diff -r 346966cffeef -r 6f4c4d59666f lwar/add.c --- 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]); diff -r 346966cffeef -r 6f4c4d59666f lwar/extract.c --- 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)); diff -r 346966cffeef -r 6f4c4d59666f lwar/list.c --- 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"); diff -r 346966cffeef -r 6f4c4d59666f lwar/replace.c --- 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]);