Mercurial > hg > index.cgi
comparison 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 |
comparison
equal
deleted
inserted
replaced
426:b4825b42c151 | 427:45df37e81741 |
---|---|
22 | 22 |
23 */ | 23 */ |
24 | 24 |
25 #include <stdio.h> | 25 #include <stdio.h> |
26 #include <stdlib.h> | 26 #include <stdlib.h> |
27 #include <string.h> | |
27 #include <sys/stat.h> | 28 #include <sys/stat.h> |
28 #include <sys/types.h> | 29 #include <sys/types.h> |
29 | 30 |
30 #include <lw_alloc.h> | 31 #include <lw_alloc.h> |
31 | 32 |
40 int debug_level = 0; | 41 int debug_level = 0; |
41 int operation = 0; | 42 int operation = 0; |
42 int nfiles = 0; | 43 int nfiles = 0; |
43 char *archive_file = NULL; | 44 char *archive_file = NULL; |
44 int mergeflag = 0; | 45 int mergeflag = 0; |
46 int filename_flag = 0; | |
45 | 47 |
46 char **files = NULL; | 48 char **files = NULL; |
47 | 49 |
48 void add_file_name(char *fn) | 50 void add_file_name(char *fn) |
49 { | 51 { |
50 files = lw_realloc(files, sizeof(char *) * (nfiles + 1)); | 52 files = lw_realloc(files, sizeof(char *) * (nfiles + 1)); |
51 files[nfiles] = fn; | 53 files[nfiles] = fn; |
52 nfiles++; | 54 nfiles++; |
53 } | 55 } |
56 | |
57 char *get_file_name(char *fn) | |
58 { | |
59 char *filename; | |
60 if (filename_flag != 0) | |
61 { | |
62 #ifdef _MSC_VER | |
63 filename = strrchr(fn, '\\'); | |
64 #else | |
65 filename = strrchr(fn, '/'); | |
66 #endif | |
67 if (filename != NULL) | |
68 return filename + 1; | |
69 } | |
70 return fn; | |
71 } |