diff --git a/hecl/lib/ProjectPath.cpp b/hecl/lib/ProjectPath.cpp index f69aa8017..b7801bc60 100644 --- a/hecl/lib/ProjectPath.cpp +++ b/hecl/lib/ProjectPath.cpp @@ -74,7 +74,7 @@ void ProjectPath::assign(Database::Project& project, const SystemString& path) else usePath = path; - m_relPath = CanonRelPath(usePath); + m_relPath = CanonRelPath(usePath, project.getProjectRootPath()); m_absPath = project.getProjectRootPath().getAbsolutePath() + _S('/') + m_relPath; SanitizePath(m_relPath); SanitizePath(m_absPath); @@ -134,11 +134,7 @@ ProjectPath ProjectPath::getCookedPath(const Database::DataSpecEntry& spec) cons ProjectPath::Type ProjectPath::getPathType() const { if (std::regex_search(m_absPath, regGLOB)) - { - std::vector globResults; - getGlobResults(globResults); - return globResults.size() ? Type::Glob : Type::None; - } + return Type::Glob; Sstat theStat; if (hecl::Stat(m_absPath.c_str(), &theStat)) return Type::None; @@ -165,6 +161,7 @@ Time ProjectPath::getModtime() const latestTime = theStat.st_mtime; } } + return Time(latestTime); } if (!hecl::Stat(m_absPath.c_str(), &theStat)) { @@ -192,22 +189,22 @@ Time ProjectPath::getModtime() const static void _recursiveGlob(Database::Project& proj, std::vector& outPaths, - size_t level, - const SystemRegexMatch& pathCompMatches, + const SystemString& remPath, const SystemString& itStr, bool needSlash) { - if (level >= pathCompMatches.size()) + SystemRegexMatch matches; + if (!std::regex_search(remPath, matches, regPATHCOMP)) return; - SystemString comp = pathCompMatches.str(level); + const SystemString& comp = matches[1]; if (!std::regex_search(comp, regGLOB)) { SystemString nextItStr = itStr; if (needSlash) nextItStr += _S('/'); nextItStr += comp; - _recursiveGlob(proj, outPaths, level+1, pathCompMatches, nextItStr, true); + _recursiveGlob(proj, outPaths, matches.suffix(), nextItStr, true); return; } @@ -229,7 +226,7 @@ static void _recursiveGlob(Database::Project& proj, continue; if (ent.m_isDir) - _recursiveGlob(proj, outPaths, level+1, pathCompMatches, nextItStr, true); + _recursiveGlob(proj, outPaths, matches.suffix(), nextItStr, true); else outPaths.emplace_back(proj, nextItStr); } @@ -262,9 +259,7 @@ void ProjectPath::getGlobResults(std::vector& outPaths) const SystemString itStr = _S("/"); #endif - SystemRegexMatch pathCompMatches; - if (std::regex_search(m_absPath, pathCompMatches, regPATHCOMP)) - _recursiveGlob(*m_proj, outPaths, 1, pathCompMatches, itStr, false); + _recursiveGlob(*m_proj, outPaths, m_absPath, itStr, false); } ProjectRootPath SearchForProject(const SystemString& path) diff --git a/hecl/lib/hecl.cpp b/hecl/lib/hecl.cpp index 8d52ad553..a33b78063 100644 --- a/hecl/lib/hecl.cpp +++ b/hecl/lib/hecl.cpp @@ -139,16 +139,10 @@ bool IsPathPNG(const hecl::ProjectPath& path) bool IsPathBlend(const hecl::ProjectPath& path) { - hecl::ProjectPath usePath; - if (path.getPathType() == hecl::ProjectPath::Type::Glob) - usePath = path.getWithExtension(_S(".blend"), true); - else - usePath = path; - - const SystemChar* lastCompExt = usePath.getLastComponentExt(); + const SystemChar* lastCompExt = path.getLastComponentExt(); if (!lastCompExt || hecl::StrCmp(lastCompExt, _S("blend"))) return false; - FILE* fp = hecl::Fopen(usePath.getAbsolutePath().c_str(), _S("rb")); + FILE* fp = hecl::Fopen(path.getAbsolutePath().c_str(), _S("rb")); if (!fp) return false; uint32_t buf;