From: michael DOT mauch AT gmx DOT de (Michael Mauch) Newsgroups: comp.os.msdos.djgpp Subject: Patch for djtar to make it extract single files Date: Tue, 24 Feb 1998 08:12:23 +0100 Organization: Gerhard-Mercator-Universitaet -GH- Duisburg Lines: 180 Message-ID: <6ctrsd$r7g$1@news-hrz.uni-duisburg.de> NNTP-Posting-Host: ppp83.uni-duisburg.de Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="--=_34f272d7138491830b2b6d09.MFSBCHJLHS" To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Precedence: bulk ----=_34f272d7138491830b2b6d09.MFSBCHJLHS Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Hi, I added a few lines to the djtar sources to make it extract single files from a large gzip'ed tar-file (.tgz). I append the diffs for djtar.c and the documentation utils.tex. May I distribute the new djtar.exe along with a free archive, if I tell people that the original author is DJ Delorie and where to get the original sources and if I include the diffs? djtar is a lot faster than "tar -dz", because it doesn't have to gunzip the whole 16MB tar file only to extract a 2KB archive member. Zipping every single archive member doesn't come near the compression ratio of the .tgz archive, because the archive members are very similar to each other and zip doesn't take advantage from this fact. Concatenating all files without compression (zip -0) and compressing the whole thing afterwards makes it as small as the .tgz file, but to unzip one archive member from this .zip.zip file I would need a temporary 16MB file as well. So djtar really is the best for this job. Regards... Michael ----=_34f272d7138491830b2b6d09.MFSBCHJLHS Content-Type: text/plain; charset=us-ascii; name=djtar.dif Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename=djtar.dif *** djtar.c Sun Sep 1 22:44:26 1996 --- new/djtar.c Mon Feb 23 20:05:52 1998 *************** *** 11,16 **** --- 11,17 ---- #include #include #include + #include #define NO_LFN (!_use_lfn(".")) *************** *** 102,107 **** --- 103,109 ---- FILE *change_file; int v_switch = 0; + int quiet = 0; int dot_switch = 1; int text_unix = 0; int text_dos = 0; *************** *** 112,118 **** int list_only = 1; char skipped_str[] = "[skipped]"; ! char *only_dir; /*------------------------------------------------------------------------*/ --- 114,121 ---- int list_only = 1; char skipped_str[] = "[skipped]"; ! char *only_dir = NULL; ! char *only_file = NULL; /*------------------------------------------------------------------------*/ *************** *** 355,360 **** --- 358,370 ---- if (should_be_written && only_dir && strncmp(only_dir, header.name, strlen(only_dir))) should_be_written = 0; + + /* ONLY_FILE says to extract only files which match + the given name. */ + if (should_be_written && + only_file && fnmatch(only_file, header.name, 0)) + should_be_written = 0; + sscanf(header.operm, " %lo", &perm); sscanf(header.ouid, " %lo", &uid); sscanf(header.ogid, " %lo", &gid); *************** *** 482,487 **** --- 492,499 ---- } } + if (should_be_written || !quiet) + { if (v_switch) fprintf(log_out, "%08lx %6lo ", posn, perm); else *************** *** 498,503 **** --- 510,516 ---- fprintf(log_out, " -> %s", header.filler); fprintf(log_out, "%s\n", !should_be_written && !list_only ? "\t[ skipped ]" : ""); + } posn += 512 + ((size+511) & ~511); #if 0 fprintf(log_out, "%6lo %02x %12ld %s\n",perm,header.flags[0],size,changed_name); *************** *** 720,726 **** if (argc < 2) { ! fprintf(stderr, "Usage: %s [-n changeFile] [-p] [-i] [-t|x] [-o dir] [-v] [-u|d|b] [-[!].] tarfile...\n", progname); exit(1); } --- 733,739 ---- if (argc < 2) { ! fprintf(stderr, "Usage: %s [-n changeFile] [-p] [-i] [-t|x] [-o dir] [-f filespec] [-v] [-q] [-u|d|b] [-[!].] tarfile...\n", progname); exit(1); } *************** *** 743,748 **** --- 756,764 ---- case 'v': v_switch = 1; break; + case 'q': + quiet++; + break; case 'u': text_unix = 1; text_dos = 0; *************** *** 764,769 **** --- 780,788 ---- break; case 'o': only_dir = strdup(argv[++i]); + break; + case 'f': + only_file = strdup(argv[++i]); break; case 'p': to_stdout = 1; ----=_34f272d7138491830b2b6d09.MFSBCHJLHS Content-Type: text/plain; charset=us-ascii; name=utils.dif Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename=utils.dif *** ../utils.tex Wed Jan 24 05:19:30 1996 --- new/utils.tex Tue Feb 24 07:28:38 1998 *************** *** 243,248 **** --- 243,258 ---- you can specify incomplete directory names, thus using it as a poor man's wildcard facility. + @item -f @file{filespec} + + Only extract files which match the given @file{filespec}. @file{filespec} + may contain wildcards such as `*' and `?'. + + @item -q + + With this option, @code{djtar} doesn't show the skipped files when using + the @code{-o} or @code{-f} option. + @item -i By default, @code{djtar} will refuse to create files whose directory ----=_34f272d7138491830b2b6d09.MFSBCHJLHS--