Skip to content

Commit

Permalink
COMMON: Add method addSubDirectories to class FileList
Browse files Browse the repository at this point in the history
  • Loading branch information
vkremianskii authored and DrMcCoy committed May 11, 2018
1 parent 2c50f7c commit b9f2df4
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 0 deletions.
18 changes: 18 additions & 0 deletions src/common/filelist.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,24 @@ bool FileList::addDirectory(const UString &directory, int recurseDepth) {
return true;
}

bool FileList::addSubDirectories(const UString &directory) {
if (!FilePath::isDirectory(directory))
return false;

try {
// Iterator over the directory's contents
for (directory_iterator itEnd, itDir(directory.c_str()); itDir != itEnd; ++itDir) {
const UString path = itDir->path().generic_string();
if (FilePath::isDirectory(path))
_files.push_back(FilePath::canonicalize(path, false));
}
} catch (...) {
return false;
}

return true;
}

bool FileList::getSubList(const UString &str, bool caseInsensitive, FileList &subList) const {
UString match = caseInsensitive ? str.toLower() : str;

Expand Down
8 changes: 8 additions & 0 deletions src/common/filelist.h
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,14 @@ class FileList {
*/
bool addDirectory(const UString &directory, int recurseDepth = 0);

/** Add subdirectories of a directory to the list.
*
* @param directory The directory to scan.
* @return true if the subdirectories were successfully added to the list,
* false otherwise.
*/
bool addSubDirectories(const UString &directory);

/** Add files ending with the given string into another FileList.
*
* @param str A file ending to match file names against.
Expand Down

0 comments on commit b9f2df4

Please sign in to comment.