Represents a set of folders that make up a search path. More...
#include <juce_FileSearchPath.h>
Public Member Functions | |
FileSearchPath () | |
Creates an empty search path. More... | |
FileSearchPath (const String &path) | |
Creates a search path from a string of pathnames. More... | |
FileSearchPath (const FileSearchPath &) | |
Creates a copy of another search path. More... | |
~FileSearchPath () | |
Destructor. More... | |
void | add (const File &directoryToAdd, int insertIndex=-1) |
Adds a new directory to the search path. More... | |
bool | addIfNotAlreadyThere (const File &directoryToAdd) |
Adds a new directory to the search path if it's not already in there. More... | |
void | addPath (const FileSearchPath &) |
Merges another search path into this one. More... | |
int | findChildFiles (Array< File > &results, int whatToLookFor, bool searchRecursively, const String &wildCardPattern="*") const |
Searches the path for a wildcard. More... | |
int | getNumPaths () const |
Returns the number of folders in this search path. More... | |
bool | isFileInPath (const File &fileToCheck, bool checkRecursively) const |
Finds out whether a file is inside one of the path's directories. More... | |
FileSearchPath & | operator= (const FileSearchPath &) |
Copies another search path. More... | |
FileSearchPath & | operator= (const String &path) |
Uses a string containing a list of pathnames to re-initialise this list. More... | |
File | operator[] (int index) const |
Returns one of the folders in this search path. More... | |
void | remove (int indexToRemove) |
Removes a directory from the search path. More... | |
void | removeNonExistentPaths () |
Removes any directories that don't actually exist. More... | |
void | removeRedundantPaths () |
Removes any directories that are actually subdirectories of one of the other directories in the search path. More... | |
String | toString () const |
Returns the search path as a semicolon-separated list of directories. More... | |
Private Member Functions | |
void | init (const String &) |
Private Attributes | |
StringArray | directories |
Represents a set of folders that make up a search path.
FileSearchPath::FileSearchPath | ( | ) |
Creates an empty search path.
FileSearchPath::FileSearchPath | ( | const String & | path | ) |
Creates a search path from a string of pathnames.
The path can be semicolon- or comma-separated, e.g. "/foo/bar;/foo/moose;/fish/moose"
The separate folders are tokenised and added to the search path.
FileSearchPath::FileSearchPath | ( | const FileSearchPath & | ) |
Creates a copy of another search path.
FileSearchPath::~FileSearchPath | ( | ) |
Destructor.
Adds a new directory to the search path.
The new directory is added to the end of the list if the insertIndex parameter is less than zero, otherwise it is inserted at the given index.
bool FileSearchPath::addIfNotAlreadyThere | ( | const File & | directoryToAdd | ) |
Adds a new directory to the search path if it's not already in there.
void FileSearchPath::addPath | ( | const FileSearchPath & | ) |
Merges another search path into this one.
This will remove any duplicate directories.
int FileSearchPath::findChildFiles | ( | Array< File > & | results, |
int | whatToLookFor, | ||
bool | searchRecursively, | ||
const String & | wildCardPattern = "*" |
||
) | const |
Searches the path for a wildcard.
This will search all the directories in the search path in order, adding any matching files to the results array.
results | an array to append the results to |
whatToLookFor | a value from the File::TypesOfFileToFind enum, specifying whether to return files, directories, or both. |
searchRecursively | whether to recursively search the subdirectories too |
wildCardPattern | a pattern to match against the filenames |
int FileSearchPath::getNumPaths | ( | ) | const |
Returns the number of folders in this search path.
|
private |
bool FileSearchPath::isFileInPath | ( | const File & | fileToCheck, |
bool | checkRecursively | ||
) | const |
Finds out whether a file is inside one of the path's directories.
This will return true if the specified file is a child of one of the directories specified by this path. Note that this doesn't actually do any searching or check that the files exist - it just looks at the pathnames to work out whether the file would be inside a directory.
fileToCheck | the file to look for |
checkRecursively | if true, then this will return true if the file is inside a subfolder of one of the path's directories (at any depth). If false it will only return true if the file is actually a direct child of one of the directories. |
FileSearchPath& FileSearchPath::operator= | ( | const FileSearchPath & | ) |
Copies another search path.
FileSearchPath& FileSearchPath::operator= | ( | const String & | path | ) |
Uses a string containing a list of pathnames to re-initialise this list.
This search path is cleared and the semicolon- or comma-separated folders in this string are added instead. e.g. "/foo/bar;/foo/moose;/fish/moose"
Returns one of the folders in this search path.
The file returned isn't guaranteed to actually be a valid directory.
void FileSearchPath::remove | ( | int | indexToRemove | ) |
Removes a directory from the search path.
void FileSearchPath::removeNonExistentPaths | ( | ) |
Removes any directories that don't actually exist.
void FileSearchPath::removeRedundantPaths | ( | ) |
Removes any directories that are actually subdirectories of one of the other directories in the search path.
If the search is intended to be recursive, there's no point having nested folders in the search path, because they'll just get searched twice and you'll get duplicate results.
e.g. if the path is "c:\abc\de;c:\abc", this method will simplify it to "c:\abc"
String FileSearchPath::toString | ( | ) | const |
Returns the search path as a semicolon-separated list of directories.
|
private |