diff lwar/lwar.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 221b5f58d8ad
children
line wrap: on
line diff
--- a/lwar/lwar.c	Thu Nov 03 21:44:32 2016 -0600
+++ b/lwar/lwar.c	Tue Nov 15 21:43:33 2016 -0700
@@ -24,6 +24,7 @@
 
 #include <stdio.h>
 #include <stdlib.h>
+#include <string.h>
 #include <sys/stat.h>
 #include <sys/types.h>
 
@@ -42,6 +43,7 @@
 int nfiles = 0;
 char *archive_file = NULL;
 int mergeflag = 0;
+int filename_flag = 0;
 
 char **files = NULL;
 
@@ -51,3 +53,19 @@
 	files[nfiles] = fn;
 	nfiles++;
 }
+
+char *get_file_name(char *fn)
+{
+	char *filename;
+	if (filename_flag != 0)
+	{
+#ifdef _MSC_VER
+		filename = strrchr(fn, '\\');
+#else
+		filename = strrchr(fn, '/');
+#endif
+		if (filename != NULL)
+			return filename + 1;
+	}
+	return fn;
+}