readDefFiles function

dynamic readDefFiles(
  1. List<String> pathArray, {
  2. String baseFolderPath = '',
  3. String filePath = '',
  4. String readTextFileFunction(
    1. String, [
    2. String
    ])? = readTextFile,
  5. String stringProcessingQuote = '\'',
  6. dynamic processQuotedStringFunction(
    1. String,
    2. ParsingContext,
    3. int
    )? = processDefQuotedString,
  7. int levelSpaceCount = 4,
  8. bool hasImportCommands = true,
  9. String getImportedPathFunction(
    1. String
    )? = getImportedPath,
  10. List<String> getImportedFilePathArrayFunction(
    1. String
    )? = getImportedFilePathArray,
})

Implementation

dynamic readDefFiles(
    List<String> pathArray,
    {
        String baseFolderPath = '',
        String filePath = '',
        String Function( String, [String] )? readTextFileFunction = readTextFile,
        String stringProcessingQuote = '\'',
        dynamic Function( String, ParsingContext, int )? processQuotedStringFunction = processDefQuotedString,
        int levelSpaceCount = 4,
        bool hasImportCommands = true,
        String Function( String )? getImportedPathFunction = getImportedPath,
        List<String> Function( String )? getImportedFilePathArrayFunction = getImportedFilePathArray
    }
    )
{
    var scriptFolderPath = getDefFolderPath( filePath );
    var valueArray = <dynamic>[];

    for ( var path in pathArray )
    {
        if ( path.endsWith( '/' )
             || path.contains( '*' )
             || path.contains( '?' ) )
        {
            var folderFilePathArray = getDefFilePathArray( scriptFolderPath + path );

            for ( var folderFilePath in folderFilePathArray )
            {
                valueArray.add(
                    readDefFile(
                        folderFilePath,
                        baseFolderPath: baseFolderPath,
                        readTextFileFunction: readTextFileFunction,
                        stringProcessingQuote: stringProcessingQuote,
                        processQuotedStringFunction: processQuotedStringFunction,
                        levelSpaceCount: levelSpaceCount,
                        hasImportCommands: hasImportCommands,
                        getImportedPathFunction: getImportedPathFunction,
                        getImportedFilePathArrayFunction: getImportedFilePathArrayFunction
                        )
                    );
            }
        }
        else
        {
            dynamic value =
                readDefFile(
                    scriptFolderPath + path,
                    baseFolderPath: baseFolderPath,
                    readTextFileFunction: readTextFileFunction,
                    stringProcessingQuote: stringProcessingQuote,
                    processQuotedStringFunction: processQuotedStringFunction,
                    levelSpaceCount: levelSpaceCount,
                    hasImportCommands: hasImportCommands,
                    getImportedPathFunction: getImportedPathFunction,
                    getImportedFilePathArrayFunction: getImportedFilePathArrayFunction
                    );

            if ( pathArray.length == 1 )
            {
                return value;
            }
            else
            {
                valueArray.add( value );
            }
        }
    }

    return valueArray;
}