summaryrefslogtreecommitdiff
path: root/archival/tar.c
diff options
context:
space:
mode:
authorEric Andersen <andersen@codepoet.org>2001-06-21 19:30:10 +0000
committerEric Andersen <andersen@codepoet.org>2001-06-21 19:30:10 +0000
commit091781e20eb055ac286b5a617d53a50c7d6c451e (patch)
tree2be329d957ce48547b950cc1c56d14d32096b055 /archival/tar.c
parent8a646dd2933bc37e67e1b09fd3461816e38fc677 (diff)
downloadbusybox-w32-091781e20eb055ac286b5a617d53a50c7d6c451e.tar.gz
busybox-w32-091781e20eb055ac286b5a617d53a50c7d6c451e.tar.bz2
busybox-w32-091781e20eb055ac286b5a617d53a50c7d6c451e.zip
Support tar -C, per bug #1176
-Erik
Diffstat (limited to 'archival/tar.c')
-rw-r--r--archival/tar.c14
1 files changed, 12 insertions, 2 deletions
diff --git a/archival/tar.c b/archival/tar.c
index 8dec4349d..55fb12c2c 100644
--- a/archival/tar.c
+++ b/archival/tar.c
@@ -151,6 +151,7 @@ extern int tar_main(int argc, char **argv)
151 char** excludeList=NULL; 151 char** excludeList=NULL;
152 char** extractList=NULL; 152 char** extractList=NULL;
153 const char *tarName="-"; 153 const char *tarName="-";
154 const char *cwd=NULL;
154#if defined BB_FEATURE_TAR_EXCLUDE 155#if defined BB_FEATURE_TAR_EXCLUDE
155 int excludeListSize=0; 156 int excludeListSize=0;
156 FILE *fileList; 157 FILE *fileList;
@@ -181,9 +182,9 @@ extern int tar_main(int argc, char **argv)
181 182
182 while ( 183 while (
183#ifndef BB_FEATURE_TAR_EXCLUDE 184#ifndef BB_FEATURE_TAR_EXCLUDE
184 (opt = getopt(argc, argv, "cxtzvOf:p")) 185 (opt = getopt(argc, argv, "cxtzvOf:pC:"))
185#else 186#else
186 (opt = getopt_long(argc, argv, "cxtzvOf:X:p", longopts, NULL)) 187 (opt = getopt_long(argc, argv, "cxtzvOf:X:pC:", longopts, NULL))
187#endif 188#endif
188 > 0) { 189 > 0) {
189 switch (opt) { 190 switch (opt) {
@@ -240,6 +241,13 @@ extern int tar_main(int argc, char **argv)
240#endif 241#endif
241 case 'p': 242 case 'p':
242 break; 243 break;
244 case 'C':
245 cwd = xgetcwd((char *)cwd);
246 if (chdir(optarg)) {
247 printf("cd: %s: %s\n", optarg, strerror(errno));
248 return EXIT_FAILURE;
249 }
250 break;
243 default: 251 default:
244 show_usage(); 252 show_usage();
245 } 253 }
@@ -292,6 +300,8 @@ extern int tar_main(int argc, char **argv)
292#endif 300#endif
293 } 301 }
294 302
303 if (cwd)
304 chdir(cwd);
295 if (status == TRUE) 305 if (status == TRUE)
296 return EXIT_SUCCESS; 306 return EXIT_SUCCESS;
297 else 307 else