|
File Searching
[File I/O]
Functions for searching files by name patterns. More...
Functions | |
String | findFirstFile (string pattern, bool recurse=true) |
Returns the first file in the directory system matching the given pattern. | |
String | findFirstFileMultiExpr (string pattern, bool recurse=true) |
Returns the first file in the directory system matching the given patterns. | |
String | findNextFile (string pattern="") |
Returns the next file matching a search begun in findFirstFile(). | |
String | findNextFileMultiExpr (string pattern="") |
Returns the next file matching a search begun in findFirstFileMultiExpr(). | |
int | getFileCount (string pattern, bool recurse=true) |
Returns the number of files in the directory tree that match the given patterns. | |
int | getFileCountMultiExpr (string pattern, bool recurse=true) |
Returns the number of files in the directory tree that match the given patterns. |
Detailed Description
Functions for searching files by name patterns.
Function Documentation
String findFirstFile | ( | string | pattern, | |
bool | recurse = true | |||
) |
Returns the first file in the directory system matching the given pattern.
Use the corresponding findNextFile() to step through the results. If you're only interested in the number of files returned by the pattern match, use getFileCount().
This function differs from findFirstFileMultiExpr() in that it supports a single search pattern being passed in.
- Note:
- You cannot run multiple simultaneous file system searches with these functions. Each call to findFirstFile() and findFirstFileMultiExpr() initiates a new search and renders a previous search invalid.
- Parameters:
-
pattern The path and file name pattern to match against. recurse If true, the search will exhaustively recurse into subdirectories of the given path and match the given filename pattern.
- Returns:
- The path of the first file matched by the search or an empty string if no matching file could be found.
- Example:
// Execute all .cs files in a subdirectory and its subdirectories. for( %file = findFirstFile( "subdirectory/*.cs" ); %file !$= ""; %file = findNextFile() ) exec( %file );
String findFirstFileMultiExpr | ( | string | pattern, | |
bool | recurse = true | |||
) |
Returns the first file in the directory system matching the given patterns.
Use the corresponding findNextFileMultiExpr() to step through the results. If you're only interested in the number of files returned by the pattern match, use getFileCountMultiExpr().
This function differs from findFirstFile() in that it supports multiple search patterns to be passed in.
- Note:
- You cannot run multiple simultaneous file system searches with these functions. Each call to findFirstFile() and findFirstFileMultiExpr() initiates a new search and renders a previous search invalid.
- Parameters:
-
pattern The path and file name pattern to match against, such as *.cs. Separate multiple patterns with TABs. For example: "*.cs" TAB "*.dso" recurse If true, the search will exhaustively recurse into subdirectories of the given path and match the given filename patterns.
- Returns:
- String of the first matching file path, or an empty string if no matching files were found.
- Example:
// Find all DTS or Collada models %filePatterns = "*.dts" TAB "*.dae"; %fullPath = findFirstFileMultiExpr( %filePatterns ); while ( %fullPath !$= "" ) { echo( %fullPath ); %fullPath = findNextFileMultiExpr( %filePatterns ); }
String findNextFile | ( | string | pattern = "" |
) |
Returns the next file matching a search begun in findFirstFile().
- Parameters:
-
pattern The path and file name pattern to match against. This is optional and may be left out as it is not used by the code. It is here for legacy reasons.
- Returns:
- The path of the next filename matched by the search or an empty string if no more files match.
- Example:
// Execute all .cs files in a subdirectory and its subdirectories. for( %file = findFirstFile( "subdirectory/*.cs" ); %file !$= ""; %file = findNextFile() ) exec( %file );
- See also:
- findFirstFile()
String findNextFileMultiExpr | ( | string | pattern = "" |
) |
Returns the next file matching a search begun in findFirstFileMultiExpr().
- Parameters:
-
pattern The path and file name pattern to match against. This is optional and may be left out as it is not used by the code. It is here for legacy reasons.
- Returns:
- String of the next matching file path, or an empty string if no matching files were found.
- Example:
// Find all DTS or Collada models %filePatterns = "*.dts" TAB "*.dae"; %fullPath = findFirstFileMultiExpr( %filePatterns ); while ( %fullPath !$= "" ) { echo( %fullPath ); %fullPath = findNextFileMultiExpr( %filePatterns ); }
- See also:
- findFirstFileMultiExpr()
int getFileCount | ( | string | pattern, | |
bool | recurse = true | |||
) |
Returns the number of files in the directory tree that match the given patterns.
This function differs from getFileCountMultiExpr() in that it supports a single search pattern being passed in.
If you're interested in a list of files that match the given pattern and not just the number of files, use findFirstFile() and findNextFile().
- Parameters:
-
pattern The path and file name pattern to match against. recurse If true, the search will exhaustively recurse into subdirectories of the given path and match the given filename pattern counting files in subdirectories.
- Returns:
- Number of files located using the pattern
- Example:
// Count the number of .cs files in a subdirectory and its subdirectories. getFileCount( "subdirectory/*.cs" );
int getFileCountMultiExpr | ( | string | pattern, | |
bool | recurse = true | |||
) |
Returns the number of files in the directory tree that match the given patterns.
If you're interested in a list of files that match the given patterns and not just the number of files, use findFirstFileMultiExpr() and findNextFileMultiExpr().
- Parameters:
-
pattern The path and file name pattern to match against, such as *.cs. Separate multiple patterns with TABs. For example: "*.cs" TAB "*.dso" recurse If true, the search will exhaustively recurse into subdirectories of the given path and match the given filename pattern.
- Returns:
- Number of files located using the patterns
- Example:
// Count all DTS or Collada models %filePatterns = "*.dts" TAB "*.dae"; echo( "Nunmer of shape files:" SPC getFileCountMultiExpr( %filePatterns ) );