diff lwar/replace.c @ 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 221b5f58d8ad
line wrap: on
line diff
--- 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]);