diff lwar/extract.c @ 427:45df37e81741

Add option to ignore paths when extracting or adding files with lwar Add option to lwar to strip path names from filenames when objects are added to an archive. Also strip path names from objects when extracting them, if present.
author David Flamand <dlflamand@gmail.com>
date Tue, 15 Nov 2016 21:43:33 -0700
parents 6f4c4d59666f
children
line wrap: on
line diff
--- a/lwar/extract.c	Thu Nov 03 21:44:32 2016 -0600
+++ b/lwar/extract.c	Tue Nov 15 21:43:33 2016 -0700
@@ -30,6 +30,7 @@
 {
 	FILE *f;
 	char buf[8];
+	char *filename;
 	long l;
 	int c;
 	char fnbuf[1024];
@@ -78,6 +79,7 @@
 			}
 		}
 		fnbuf[i] = 0;
+		filename = get_file_name(fnbuf);
 		
 		// get length of archive member
 		l = 0;
@@ -92,16 +94,16 @@
 		
 		for (i = 0; i < nfiles; i++)
 		{
-			if (!strcmp(files[i], fnbuf))
+			if (!strcmp(get_file_name(files[i]), filename))
 				break;
 		}
 		if (i < nfiles || nfiles == 0)
 		{
 			// extract the file
-			nf = fopen(fnbuf, "wb");
+			nf = fopen(filename, "wb");
 			if (!nf)
 			{
-				fprintf(stderr, "Cannot extract '%s': %s\n", fnbuf, strerror(errno));
+				fprintf(stderr, "Cannot extract '%s': %s\n", filename, strerror(errno));
 				exit(1);
 			}
 			while (l)