OpenShot Library | libopenshot-audio 0.2.0
|
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. | |
FileSearchPath (const String &path) | |
Creates a search path from a string of pathnames. | |
FileSearchPath (const FileSearchPath &) | |
Creates a copy of another search path. | |
FileSearchPath & | operator= (const FileSearchPath &) |
Copies another search path. | |
~FileSearchPath () | |
Destructor. | |
FileSearchPath & | operator= (const String &path) |
Uses a string containing a list of pathnames to re-initialise this list. | |
int | getNumPaths () const |
Returns the number of folders in this search path. | |
File | operator[] (int index) const |
Returns one of the folders in this search path. | |
String | toString () const |
Returns the search path as a semicolon-separated list of directories. | |
void | add (const File &directoryToAdd, int insertIndex=-1) |
Adds a new directory to the search path. | |
bool | addIfNotAlreadyThere (const File &directoryToAdd) |
Adds a new directory to the search path if it's not already in there. | |
void | remove (int indexToRemove) |
Removes a directory from the search path. | |
void | addPath (const FileSearchPath &) |
Merges another search path into this one. | |
void | removeRedundantPaths () |
Removes any directories that are actually subdirectories of one of the other directories in the search path. | |
void | removeNonExistentPaths () |
Removes any directories that don't actually exist. | |
Array< File > | findChildFiles (int whatToLookFor, bool searchRecursively, const String &wildCardPattern="*") const |
Searches the path for a wildcard. | |
int | findChildFiles (Array< File > &results, int whatToLookFor, bool searchRecursively, const String &wildCardPattern="*") const |
Searches the path for a wildcard. | |
bool | isFileInPath (const File &fileToCheck, bool checkRecursively) const |
Finds out whether a file is inside one of the path's directories. | |
Represents a set of folders that make up a search path.
Definition at line 38 of file juce_FileSearchPath.h.
juce::FileSearchPath::FileSearchPath | ( | ) |
Creates an empty search path.
Definition at line 26 of file juce_FileSearchPath.cpp.
juce::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.
Definition at line 29 of file juce_FileSearchPath.cpp.
juce::FileSearchPath::FileSearchPath | ( | const FileSearchPath & | other | ) |
Creates a copy of another search path.
Definition at line 34 of file juce_FileSearchPath.cpp.
juce::FileSearchPath::~FileSearchPath | ( | ) |
Destructor.
Definition at line 27 of file juce_FileSearchPath.cpp.
FileSearchPath & juce::FileSearchPath::operator= | ( | const FileSearchPath & | other | ) |
Copies another search path.
Definition at line 39 of file juce_FileSearchPath.cpp.
FileSearchPath & juce::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"
Definition at line 45 of file juce_FileSearchPath.cpp.
int juce::FileSearchPath::getNumPaths | ( | ) | const |
Returns the number of folders in this search path.
Definition at line 62 of file juce_FileSearchPath.cpp.
References juce::StringArray::size().
Referenced by addPath().
File juce::FileSearchPath::operator[] | ( | int | index | ) | const |
Returns one of the folders in this search path.
The file returned isn't guaranteed to actually be a valid directory.
Definition at line 67 of file juce_FileSearchPath.cpp.
String juce::FileSearchPath::toString | ( | ) | const |
Returns the search path as a semicolon-separated list of directories.
Definition at line 72 of file juce_FileSearchPath.cpp.
References juce::StringArray::joinIntoString().
void juce::FileSearchPath::add | ( | const File & | directoryToAdd, |
int | insertIndex = -1 |
||
) |
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.
Definition at line 83 of file juce_FileSearchPath.cpp.
References juce::File::getFullPathName(), and juce::StringArray::insert().
Referenced by addIfNotAlreadyThere().
bool juce::FileSearchPath::addIfNotAlreadyThere | ( | const File & | directoryToAdd | ) |
Adds a new directory to the search path if it's not already in there.
Definition at line 88 of file juce_FileSearchPath.cpp.
References add().
Referenced by addPath().
void juce::FileSearchPath::remove | ( | int | indexToRemove | ) |
Removes a directory from the search path.
Definition at line 98 of file juce_FileSearchPath.cpp.
References juce::StringArray::remove().
void juce::FileSearchPath::addPath | ( | const FileSearchPath & | other | ) |
Merges another search path into this one.
This will remove any duplicate directories.
Definition at line 103 of file juce_FileSearchPath.cpp.
References addIfNotAlreadyThere(), and getNumPaths().
void juce::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"
Definition at line 109 of file juce_FileSearchPath.cpp.
References juce::File::isAChildOf(), juce::StringArray::remove(), and juce::StringArray::size().
void juce::FileSearchPath::removeNonExistentPaths | ( | ) |
Removes any directories that don't actually exist.
Definition at line 128 of file juce_FileSearchPath.cpp.
References juce::File::isDirectory(), juce::StringArray::remove(), and juce::StringArray::size().
Array< File > juce::FileSearchPath::findChildFiles | ( | 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 and return an array of the files that were found.
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 |
Definition at line 135 of file juce_FileSearchPath.cpp.
References findChildFiles().
Referenced by findChildFiles().
int juce::FileSearchPath::findChildFiles | ( | Array< File > & | results, |
int | whatToLookFor, | ||
bool | searchRecursively, | ||
const String & | wildCardPattern = "*" |
||
) | const |
Searches the path for a wildcard.
Note that there's a newer, better version of this method which returns the results array, and in almost all cases, you should use that one instead! This one is kept around mainly for legacy code to use.
Definition at line 142 of file juce_FileSearchPath.cpp.
References juce::File::findChildFiles().
bool juce::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. |
Definition at line 153 of file juce_FileSearchPath.cpp.
References juce::File::getParentDirectory(), and juce::File::isAChildOf().