32 : directories (
other.directories)
38 directories =
other.directories;
48void FileSearchPath::init (
const String& path)
55 for (
auto& d : directories)
61 return directories.
size();
71 return directories[index];
81 auto dirs = directories;
84 if (d.contains (separator))
97 for (
auto& d : directories)
107 directories.
remove (index);
112 for (
int i = 0; i <
other.getNumPaths(); ++i)
120 for (
const auto& directory : directories)
146 for (
int i = directories.
size(); --i >= 0;)
163 for (
auto& d : directories)
172 for (
auto& d : directories)
198 void runTest()
override
200 beginTest (
"removeRedundantPaths");
203 const String prefix =
"C:";
205 const String prefix =
"";
209 FileSearchPath
fsp { prefix +
"/a/b/c/d;" + prefix +
"/a/b/c/e;" + prefix +
"/a/b/c" };
210 fsp.removeRedundantPaths();
211 expectEquals (
fsp.toString(), prefix +
"/a/b/c");
215 FileSearchPath
fsp { prefix +
"/a/b/c;" + prefix +
"/a/b/c/d;" + prefix +
"/a/b/c/e" };
216 fsp.removeRedundantPaths();
217 expectEquals (
fsp.toString(), prefix +
"/a/b/c");
221 FileSearchPath
fsp { prefix +
"/a/b/c/d;" + prefix +
"/a/b/c;" + prefix +
"/a/b/c/e" };
222 fsp.removeRedundantPaths();
223 expectEquals (
fsp.toString(), prefix +
"/a/b/c");
227 FileSearchPath
fsp {
"%FOO%;" + prefix +
"/a/b/c;%FOO%;" + prefix +
"/a/b/c/d" };
228 fsp.removeRedundantPaths();
229 expectEquals (
fsp.toString(),
"%FOO%;" + prefix +
"/a/b/c");
Holds a resizable array of primitive or copy-by-value objects.
Represents a set of folders that make up a search path.
bool isFileInPath(const File &fileToCheck, bool checkRecursively) const
Finds out whether a file is inside one of the path's directories.
void add(const File &directoryToAdd, int insertIndex=-1)
Adds a new directory to the search path.
void remove(int indexToRemove)
Removes a directory from the search path.
void removeNonExistentPaths()
Removes any directories that don't actually exist.
FileSearchPath & operator=(const FileSearchPath &)
Copies another search path.
void addPath(const FileSearchPath &)
Merges another search path into this one.
String toString() const
Returns the search path as a semicolon-separated list of directories.
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.
void removeRedundantPaths()
Removes any directories that are actually subdirectories of one of the other directories in the searc...
FileSearchPath()=default
Creates an empty search path.
bool addIfNotAlreadyThere(const File &directoryToAdd)
Adds a new directory to the search path if it's not already in there.
String toStringWithSeparator(StringRef separator) const
Returns the search paths, joined with the provided separator.
Array< File > findChildFiles(int whatToLookFor, bool searchRecursively, const String &wildCardPattern="*") const
Searches the path for a wildcard.
String getRawString(int index) const
Returns the unaltered text of the folder at the specified index.
Represents a local file or directory.
bool isDirectory() const
Checks whether the file is a directory that exists.
Array< File > findChildFiles(int whatToLookFor, bool searchRecursively, const String &wildCardPattern="*", FollowSymlinks followSymlinks=FollowSymlinks::yes) const
Searches this directory for files matching a wildcard pattern.
const String & getFullPathName() const noexcept
Returns the complete, absolute path of this file.
static bool isAbsolutePath(StringRef path)
Returns true if the string seems to be a fully-specified absolute path.
bool isAChildOf(const File &potentialParentDirectory) const
Checks whether a file is somewhere inside a directory.
A special array for holding a list of strings.
String joinIntoString(StringRef separatorString, int startIndex=0, int numberOfElements=-1) const
Joins the strings in the array together into one string.
void removeEmptyStrings(bool removeWhitespaceStrings=true)
Removes empty strings from the array.
void insert(int index, String stringToAdd)
Inserts a string into the array.
void clear()
Removes all elements from the array.
int size() const noexcept
Returns the number of strings in the array.
void trim()
Deletes any whitespace characters from the starts and ends of all the strings.
void remove(int index)
Removes a string from the array.
int addTokens(StringRef stringToTokenise, bool preserveQuotedStrings)
Breaks up a string into tokens and adds them to this array.
A simple class for holding temporary references to a string literal or String.
This is a base class for classes that perform a unit test.
Type unalignedPointerCast(void *ptr) noexcept
Casts a pointer to another type via void*, which suppresses the cast-align warning which sometimes ar...