bool PathUtil::createDir(const String& OSPath) { if (OSPath.find("..") != String::npos || OSPath.find("::") != String::npos) { return false; } String path = removeFilename(OSPath); if (OsUtil::mkdir(path.c_str()) == 0) return true; return false; }
bool PathMatch::match(const std::string &path) const { if (path.empty()) return false; for (std::vector<std::string>::const_iterator i = mExcludedPaths.begin(); i != mExcludedPaths.end(); ++i) { const std::string excludedPath((!Path::isAbsolute(path) && Path::isAbsolute(*i)) ? Path::getRelativePath(*i, mWorkingDirectory) : *i); std::string findpath = Path::fromNativeSeparators(path); if (!mCaseSensitive) std::transform(findpath.begin(), findpath.end(), findpath.begin(), ::tolower); // Filtering directory name if (endsWith(excludedPath,'/')) { if (!endsWith(findpath,'/')) findpath = removeFilename(findpath); if (excludedPath.length() > findpath.length()) continue; // Match relative paths starting with mask // -isrc matches src/foo.cpp if (findpath.compare(0, excludedPath.size(), excludedPath) == 0) return true; // Match only full directory name in middle or end of the path // -isrc matches myproject/src/ but does not match // myproject/srcfiles/ or myproject/mysrc/ if (findpath.find("/" + excludedPath) != std::string::npos) return true; } // Filtering filename else { if (excludedPath.length() > findpath.length()) continue; // Check if path ends with mask // -ifoo.cpp matches (./)foo.c, src/foo.cpp and proj/src/foo.cpp // -isrc/file.cpp matches src/foo.cpp and proj/src/foo.cpp if (findpath.compare(findpath.size() - excludedPath.size(), findpath.size(), excludedPath) == 0) return true; } } return false; }