updated pzstd and largeNbDicts to use the new FileNamesTable* abstraction
This commit is contained in:
+7
-10
@@ -374,7 +374,7 @@ static size_t getTotalTableSize(FileNamesTable* table)
|
||||
}
|
||||
|
||||
FileNamesTable*
|
||||
UTIL_concatenateTwoTables(FileNamesTable* table1, FileNamesTable* table2)
|
||||
UTIL_mergeFileNamesTable(FileNamesTable* table1, FileNamesTable* table2)
|
||||
{
|
||||
unsigned newTableIdx = 0;
|
||||
size_t pos = 0;
|
||||
@@ -587,13 +587,11 @@ const char* UTIL_getFileExtension(const char* infilename)
|
||||
}
|
||||
|
||||
|
||||
static FileNamesTable*
|
||||
createFNT_fromFNT(FileNamesTable* fnt, int followLinks)
|
||||
FileNamesTable*
|
||||
UTIL_createExpandedFNT(const char** inputNames, size_t nbIfns, int followLinks)
|
||||
{
|
||||
size_t pos;
|
||||
size_t const nbIfns = fnt->tableSize;
|
||||
unsigned nbFiles;
|
||||
const char** const inputNames = fnt->fileNames;
|
||||
char* buf = (char*)malloc(LIST_SIZE_INCREASE);
|
||||
char* bufend = buf + LIST_SIZE_INCREASE;
|
||||
|
||||
@@ -637,12 +635,11 @@ createFNT_fromFNT(FileNamesTable* fnt, int followLinks)
|
||||
}
|
||||
|
||||
|
||||
FileNamesTable*
|
||||
UTIL_expandFileNamesTable(FileNamesTable* fnt, int followLinks)
|
||||
void UTIL_expandFNT(FileNamesTable** fnt, int followLinks)
|
||||
{
|
||||
FileNamesTable* const newFNT = createFNT_fromFNT(fnt, followLinks);
|
||||
UTIL_freeFileNamesTable(fnt);
|
||||
return newFNT;
|
||||
FileNamesTable* const newFNT = UTIL_createExpandedFNT((*fnt)->fileNames, (*fnt)->tableSize, followLinks);
|
||||
UTIL_freeFileNamesTable(*fnt);
|
||||
*fnt = newFNT;
|
||||
}
|
||||
|
||||
|
||||
|
||||
+15
-8
@@ -188,21 +188,28 @@ UTIL_createFileNamesTable(const char** filenames, size_t tableSize, char* buf);
|
||||
*/
|
||||
void UTIL_freeFileNamesTable(FileNamesTable* table);
|
||||
|
||||
/*! UTIL_concatenateTwoTables():
|
||||
/*! UTIL_mergeFileNamesTable():
|
||||
* @return : FileNamesTable*, concatenation of @table1 and @table2
|
||||
* note: @table1 and @table2 are consumed (freed) by this operation
|
||||
*/
|
||||
FileNamesTable*
|
||||
UTIL_concatenateTwoTables(FileNamesTable* table1, FileNamesTable* table2);
|
||||
UTIL_mergeFileNamesTable(FileNamesTable* table1, FileNamesTable* table2);
|
||||
|
||||
|
||||
/*! UTIL_expandFileNamesTable() :
|
||||
* read names from @fnt, expand those corresponding to directories
|
||||
* @return : an expanded FileNamesTable*, with only file names,
|
||||
* or NULL in case of error.
|
||||
* Note: the function takes ownership of fnt, and consumes it (free it)
|
||||
/*! UTIL_expandFNT() :
|
||||
* read names from @fnt, and expand those corresponding to directories
|
||||
* update @fnt, now containing only file names,
|
||||
* @return : 0 in case of success, 1 if error
|
||||
* note : in case of error, @fnt[0] is NULL
|
||||
*/
|
||||
FileNamesTable* UTIL_expandFileNamesTable(FileNamesTable* fnt, int followLinks);
|
||||
void UTIL_expandFNT(FileNamesTable** fnt, int followLinks);
|
||||
|
||||
/*! UTIL_createExpandedFNT() :
|
||||
* read names from @filenames, and expand those corresponding to directories
|
||||
* @return : an expanded FileNamesTable*, where each name is a file
|
||||
* or NULL in case of error
|
||||
*/
|
||||
FileNamesTable* UTIL_createExpandedFNT(const char** filenames, size_t nbFilenames, int followLinks);
|
||||
|
||||
|
||||
/*! UTIL_allocateFileNamesTable() :
|
||||
|
||||
+2
-2
@@ -1029,12 +1029,12 @@ int main(int argCount, const char* argv[])
|
||||
DISPLAYLEVEL(1, "zstd: error reading %s \n", file_of_names->fileNames[flNb]);
|
||||
CLEAN_RETURN(1);
|
||||
}
|
||||
filenames = UTIL_concatenateTwoTables(filenames, fnt);
|
||||
filenames = UTIL_mergeFileNamesTable(filenames, fnt);
|
||||
}
|
||||
}
|
||||
|
||||
if (recursive) { /* at this stage, filenameTable is a list of paths, which can contain both files and directories */
|
||||
filenames = UTIL_expandFileNamesTable(filenames, followLinks);
|
||||
UTIL_expandFNT(&filenames, followLinks);
|
||||
}
|
||||
#else
|
||||
(void)followLinks;
|
||||
|
||||
Reference in New Issue
Block a user