// Enable support for creation of tar files.
#define BB_FEATURE_TAR_CREATE
//
-// Enable support for "--exclude" for excluding files
+// Enable support for "--exclude" and "-X" for excluding files
#define BB_FEATURE_TAR_EXCLUDE
//
//// Enable reverse sort
#endif
#if defined BB_FEATURE_TAR_EXCLUDE
"[--exclude File] "
+ "[-X File]"
#endif
"[-f tarFile] [FILE(s)] ...\n"
#ifndef BB_FEATURE_TRIVIAL_HELP
"\tO\t\textract to stdout\n"
#if defined BB_FEATURE_TAR_EXCLUDE
"\texclude\t\tfile to exclude\n"
+ "\tX\t\tfile with names to exclude\n"
#endif
"\nInformative output:\n"
"\tv\t\tverbosely list files processed\n"
char** extractList=NULL;
#if defined BB_FEATURE_TAR_EXCLUDE
int excludeListSize=0;
+ char *excludeFileName ="-";
+ FILE *fileList;
+ char file[256];
#endif
const char *tarName="-";
int listFlag = FALSE;
break;
#if defined BB_FEATURE_TAR_EXCLUDE
case 'e':
- if (strcmp(*argv, "exclude")==0) {
+ if (strcmp(*argv, "xclude")==0) {
excludeList=xrealloc( excludeList, sizeof(char**) * (excludeListSize+2));
excludeList[excludeListSize] = *(++argv);
if (excludeList[excludeListSize] == NULL)
stopIt=TRUE;
break;
}
+ case 'X':
+ if (*excludeFileName != '-')
+ fatalError("Only one 'X' option allowed\n");
+ excludeFileName = *(++argv);
+ if (excludeFileName == NULL)
+ fatalError("Option requires an argument: No file specified\n");
+ fileList = fopen (excludeFileName, "rt");
+ if (! fileList)
+ fatalError("Exclude file: file not found\n");
+ while (!feof(fileList)) {
+ fscanf(fileList, "%s", file);
+ excludeList=xrealloc( excludeList, sizeof(char**) * (excludeListSize+2));
+ excludeList[excludeListSize] = malloc(sizeof(char) * (strlen(file)+1));
+ strcpy(excludeList[excludeListSize],file);
+ /* Remove leading "/"s */
+ if (*excludeList[excludeListSize] == '/')
+ excludeList[excludeListSize] = (excludeList[excludeListSize])+1;
+ /* Tack a NULL onto the end of the list */
+ excludeList[++excludeListSize] = NULL;
+ }
+
+ fclose(fileList);
+ stopIt=TRUE;
+ break;
#endif
case '-':
break;
char** extractList=NULL;
#if defined BB_FEATURE_TAR_EXCLUDE
int excludeListSize=0;
+ char *excludeFileName ="-";
+ FILE *fileList;
+ char file[256];
#endif
const char *tarName="-";
int listFlag = FALSE;
break;
#if defined BB_FEATURE_TAR_EXCLUDE
case 'e':
- if (strcmp(*argv, "exclude")==0) {
+ if (strcmp(*argv, "xclude")==0) {
excludeList=xrealloc( excludeList, sizeof(char**) * (excludeListSize+2));
excludeList[excludeListSize] = *(++argv);
if (excludeList[excludeListSize] == NULL)
stopIt=TRUE;
break;
}
+ case 'X':
+ if (*excludeFileName != '-')
+ fatalError("Only one 'X' option allowed\n");
+ excludeFileName = *(++argv);
+ if (excludeFileName == NULL)
+ fatalError("Option requires an argument: No file specified\n");
+ fileList = fopen (excludeFileName, "rt");
+ if (! fileList)
+ fatalError("Exclude file: file not found\n");
+ while (!feof(fileList)) {
+ fscanf(fileList, "%s", file);
+ excludeList=xrealloc( excludeList, sizeof(char**) * (excludeListSize+2));
+ excludeList[excludeListSize] = malloc(sizeof(char) * (strlen(file)+1));
+ strcpy(excludeList[excludeListSize],file);
+ /* Remove leading "/"s */
+ if (*excludeList[excludeListSize] == '/')
+ excludeList[excludeListSize] = (excludeList[excludeListSize])+1;
+ /* Tack a NULL onto the end of the list */
+ excludeList[++excludeListSize] = NULL;
+ }
+
+ fclose(fileList);
+ stopIt=TRUE;
+ break;
#endif
case '-':
break;
#endif
#if defined BB_FEATURE_TAR_EXCLUDE
"[--exclude File] "
+ "[-X File]"
#endif
"[-f tarFile] [FILE(s)] ...\n"
#ifndef BB_FEATURE_TRIVIAL_HELP
"\tO\t\textract to stdout\n"
#if defined BB_FEATURE_TAR_EXCLUDE
"\texclude\t\tfile to exclude\n"
+ "\tX\t\tfile with names to exclude\n"
#endif
"\nInformative output:\n"
"\tv\t\tverbosely list files processed\n"