getDefFilePathArray function
Implementation
List<String> getDefFilePathArray(
String fileFilter
)
{
fileFilter = fileFilter;
var folderPath = getDefFolderPath( fileFilter );
fileFilter = fileFilter.substring( folderPath.length );
if ( fileFilter == '' )
{
fileFilter = "^.*\\.def\$";
}
else
{
fileFilter =
'^'
+ fileFilter
.replaceAll( '.', '\\.' )
.replaceAll( '*', '.*' )
.replaceAll( '?', '.' )
.replaceAll( '[', '\\[' )
.replaceAll( ']', '\\]' )
.replaceAll( '(', '\\(' )
.replaceAll( ')', '\\)' )
.replaceAll( '{', '\\{' )
.replaceAll( '}', '\\}' )
.replaceAll( '|', '\\|' )
.replaceAll( '^', '\\^' )
.replaceAll( '\$', '\\\$' )
.replaceAll( '+', '\\+' )
.replaceAll( '-', '\\-' )
+ '\$';
}
var fileNameRegularExpression = RegExp( fileFilter );
var filePathArray = <String>[];
try
{
for ( FileSystemEntity entity in Directory( getPhysicalFilePath( folderPath ) ).listSync() )
{
var fileName = path.basename( entity.path );
if ( fileNameRegularExpression.hasMatch( fileName ) )
{
filePathArray.add( folderPath + fileName.replaceAll( '\\', '/' ) );
}
}
}
catch ( error )
{
print( error );
rethrow;
}
filePathArray.sort(
( firstFilePath, secondFilePath ) => getNaturalTextComparison( firstFilePath, secondFilePath )
);
return filePathArray;
}