25 #include <boost/filesystem.hpp> 26 #include <boost/regex.hpp> 32 using boost::filesystem::directory_iterator;
82 std::list<UString>::iterator file =
_files.begin();
84 while (file !=
_files.end()) {
109 for (directory_iterator itEnd, itDir(directory.
c_str()); itDir != itEnd; ++itDir) {
110 const UString path = itDir->path().generic_string();
115 if (recurseDepth != 0)
116 if (!
addDirectory(path, (recurseDepth == -1) ? -1 : (recurseDepth - 1)))
137 for (directory_iterator itEnd, itDir(directory.
c_str()); itDir != itEnd; ++itDir) {
138 const UString path = itDir->path().generic_string();
152 bool foundMatch =
false;
155 for (Files::const_iterator it =
_files.begin(); it !=
_files.end(); ++it) {
156 bool matching = caseInsensitive ? it->
toLower().
endsWith(match) : it->endsWith(match);
159 subList.
_files.push_back(*it);
168 boost::regex::flag_type type = boost::regex::perl;
170 type |= boost::regex::icase;
171 boost::regex expression(glob.
c_str(), type);
173 bool foundMatch =
false;
176 for (Files::const_iterator it =
_files.begin(); it !=
_files.end(); ++it)
177 if (boost::regex_match(it->c_str(), expression)) {
178 subList.
_files.push_back(*it);
197 for (Files::const_iterator it =
_files.begin(); it !=
_files.end(); ++it) {
198 bool matching = caseInsensitive ? it->
toLower().
endsWith(match) : it->endsWith(match);
208 boost::regex::flag_type type = boost::regex::perl;
210 type |= boost::regex::icase;
211 boost::regex expression(glob.
c_str(), type);
214 for (Files::const_iterator it =
_files.begin(); it !=
_files.end(); ++it)
215 if (boost::regex_match(it->c_str(), expression))
bool addSubDirectories(const UString &directory)
Add subdirectories of a directory to the list.
FileList & operator+=(const FileList &list)
A class holding an UTF-8 string.
static bool isDirectory(const UString &p)
Does specified path exist and is it a directory?
bool endsWith(const UString &with) const
std::list< UString >::const_iterator const_iterator
UString findFirst(const UString &str, bool caseInsensitive) const
Find the first file ending with the given string.
FileList & operator=(const FileList &list)
const char * c_str() const
Return the (utf8 encoded) string data.
static UString canonicalize(const UString &p, bool resolveSymLinks=true)
Return the canonical, absolutized and normalized path.
bool empty() const
Is the string empty?
size_t size() const
Return the number of files in the list.
void relativize(const Common::UString &basePath)
Express all files in this archive as relative to the given base path.
bool getSubList(const UString &str, bool caseInsensitive, FileList &subList) const
Add files ending with the given string into another FileList.
UString toLower() const
Return a lowercased copy of the string.
UString findFirstGlob(const UString &glob, bool caseInsensitive) const
Find the first file matching the given regex.
bool empty() const
Is the list empty?
static UString relativize(const UString &basePath, const UString &path)
Return the path relative to the base path.
const_iterator begin() const
Return a const_iterator pointing to the beginning of the list.
bool addDirectory(const UString &directory, int recurseDepth=0)
Add a directory to the list.
void clear()
Clear the list.
void sort(bool caseInsensitive)
Sort this list alphabetically.
bool containsGlob(const UString &glob, bool caseInsensitive) const
Does the list contain at least one file matching the given regex?
bool getSubListGlob(const UString &glob, bool caseInsensitive, FileList &subList) const
Add files matching the given regex into another FileList.
Utility class for manipulating file paths.
const_iterator end() const
Return a const_iterator pointing past the end of the list.
bool contains(const UString &str, bool caseInsensitive) const
Does the list contain at least one file ending with the given string?