Modified:
trunk/xar/ChangeLog
trunk/xar/src/xar.c
Log:
src/xar.c: When extracting, save directories until the end. This lets
timestamps get set correctly on directories and addresses issue #58
Modified: trunk/xar/ChangeLog
==============================================================================
--- trunk/xar/ChangeLog (original)
+++ trunk/xar/ChangeLog Tue Aug 19 08:12:45 2008
@@ -1,6 +1,7 @@
devel
2008-08-19 Rob Braun bbr...@synack.net
* lib/lzmaxar.c: if lzma compression is specified but not compiled in,
throw an error.
+ * src/xar.c: When extracting, save directories until the end. This lets
timestamps get set correctly on directories and addresses issue #58.
2008-08-17 Rob Braun bbr...@synack.net
* lib/archive.c: Make sure the binary header and toc checksum types
match. Contributed by Apple.
2008-08-15 Rob Braun bbr...@synack.net
Modified: trunk/xar/src/xar.c
==============================================================================
--- trunk/xar/src/xar.c (original)
+++ trunk/xar/src/xar.c Tue Aug 19 08:12:45 2008
@@ -303,6 +303,7 @@
struct lnode *extract_files = NULL;
struct lnode *extract_tail = NULL;
struct lnode *lnodei = NULL;
+ struct lnode *dirs = NULL;
for(argi = 0; args[argi]; argi++) {
struct lnode *tmp;
@@ -417,12 +418,30 @@
if( NoOverwrite && (lstat(path, &sb) == 0) ) {
printf("%s already exists, not overwriting\n", path);
} else {
- files_extracted++;
- print_file(x, f);
- xar_extract(x, f);
+ const char *prop = NULL;
+ int deferred = 0;
+ if( xar_prop_get(f, "type", &prop) == 0 ) {
+ if( strcmp(prop, "directory") == 0 ) {
+ struct lnode *tmpl = calloc(sizeof(struct lnode),1);
+ tmpl->str = (char *)f;
+ tmpl->next = dirs;
+ dirs = tmpl;
+ deferred = 1;
+ }
+ }
+ if( ! deferred ) {
+ files_extracted++;
+ print_file(x, f);
+ xar_extract(x, f);
+ }
}
}
free(path);
+ }
+ for(lnodei = dirs; lnodei; lnodei = lnodei->next) {
+ files_extracted++;
+ print_file(x,(xar_file_t)lnodei->str);
+ xar_extract(x, (xar_file_t)lnodei->str);
}
if( args[0] && (files_extracted == 0) ) {
fprintf(stderr, "No files matched extraction criteria.\n");