mirror of
https://github.com/AxioDL/metaforce.git
synced 2025-07-10 15:25:53 +00:00
Glob path fixes
This commit is contained in:
parent
f1fcd83824
commit
f6428c9407
@ -74,7 +74,7 @@ void ProjectPath::assign(Database::Project& project, const SystemString& path)
|
|||||||
else
|
else
|
||||||
usePath = path;
|
usePath = path;
|
||||||
|
|
||||||
m_relPath = CanonRelPath(usePath);
|
m_relPath = CanonRelPath(usePath, project.getProjectRootPath());
|
||||||
m_absPath = project.getProjectRootPath().getAbsolutePath() + _S('/') + m_relPath;
|
m_absPath = project.getProjectRootPath().getAbsolutePath() + _S('/') + m_relPath;
|
||||||
SanitizePath(m_relPath);
|
SanitizePath(m_relPath);
|
||||||
SanitizePath(m_absPath);
|
SanitizePath(m_absPath);
|
||||||
@ -134,11 +134,7 @@ ProjectPath ProjectPath::getCookedPath(const Database::DataSpecEntry& spec) cons
|
|||||||
ProjectPath::Type ProjectPath::getPathType() const
|
ProjectPath::Type ProjectPath::getPathType() const
|
||||||
{
|
{
|
||||||
if (std::regex_search(m_absPath, regGLOB))
|
if (std::regex_search(m_absPath, regGLOB))
|
||||||
{
|
return Type::Glob;
|
||||||
std::vector<ProjectPath> globResults;
|
|
||||||
getGlobResults(globResults);
|
|
||||||
return globResults.size() ? Type::Glob : Type::None;
|
|
||||||
}
|
|
||||||
Sstat theStat;
|
Sstat theStat;
|
||||||
if (hecl::Stat(m_absPath.c_str(), &theStat))
|
if (hecl::Stat(m_absPath.c_str(), &theStat))
|
||||||
return Type::None;
|
return Type::None;
|
||||||
@ -165,6 +161,7 @@ Time ProjectPath::getModtime() const
|
|||||||
latestTime = theStat.st_mtime;
|
latestTime = theStat.st_mtime;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
return Time(latestTime);
|
||||||
}
|
}
|
||||||
if (!hecl::Stat(m_absPath.c_str(), &theStat))
|
if (!hecl::Stat(m_absPath.c_str(), &theStat))
|
||||||
{
|
{
|
||||||
@ -192,22 +189,22 @@ Time ProjectPath::getModtime() const
|
|||||||
|
|
||||||
static void _recursiveGlob(Database::Project& proj,
|
static void _recursiveGlob(Database::Project& proj,
|
||||||
std::vector<ProjectPath>& outPaths,
|
std::vector<ProjectPath>& outPaths,
|
||||||
size_t level,
|
const SystemString& remPath,
|
||||||
const SystemRegexMatch& pathCompMatches,
|
|
||||||
const SystemString& itStr,
|
const SystemString& itStr,
|
||||||
bool needSlash)
|
bool needSlash)
|
||||||
{
|
{
|
||||||
if (level >= pathCompMatches.size())
|
SystemRegexMatch matches;
|
||||||
|
if (!std::regex_search(remPath, matches, regPATHCOMP))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
SystemString comp = pathCompMatches.str(level);
|
const SystemString& comp = matches[1];
|
||||||
if (!std::regex_search(comp, regGLOB))
|
if (!std::regex_search(comp, regGLOB))
|
||||||
{
|
{
|
||||||
SystemString nextItStr = itStr;
|
SystemString nextItStr = itStr;
|
||||||
if (needSlash)
|
if (needSlash)
|
||||||
nextItStr += _S('/');
|
nextItStr += _S('/');
|
||||||
nextItStr += comp;
|
nextItStr += comp;
|
||||||
_recursiveGlob(proj, outPaths, level+1, pathCompMatches, nextItStr, true);
|
_recursiveGlob(proj, outPaths, matches.suffix(), nextItStr, true);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -229,7 +226,7 @@ static void _recursiveGlob(Database::Project& proj,
|
|||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (ent.m_isDir)
|
if (ent.m_isDir)
|
||||||
_recursiveGlob(proj, outPaths, level+1, pathCompMatches, nextItStr, true);
|
_recursiveGlob(proj, outPaths, matches.suffix(), nextItStr, true);
|
||||||
else
|
else
|
||||||
outPaths.emplace_back(proj, nextItStr);
|
outPaths.emplace_back(proj, nextItStr);
|
||||||
}
|
}
|
||||||
@ -262,9 +259,7 @@ void ProjectPath::getGlobResults(std::vector<ProjectPath>& outPaths) const
|
|||||||
SystemString itStr = _S("/");
|
SystemString itStr = _S("/");
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
SystemRegexMatch pathCompMatches;
|
_recursiveGlob(*m_proj, outPaths, m_absPath, itStr, false);
|
||||||
if (std::regex_search(m_absPath, pathCompMatches, regPATHCOMP))
|
|
||||||
_recursiveGlob(*m_proj, outPaths, 1, pathCompMatches, itStr, false);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ProjectRootPath SearchForProject(const SystemString& path)
|
ProjectRootPath SearchForProject(const SystemString& path)
|
||||||
|
@ -139,16 +139,10 @@ bool IsPathPNG(const hecl::ProjectPath& path)
|
|||||||
|
|
||||||
bool IsPathBlend(const hecl::ProjectPath& path)
|
bool IsPathBlend(const hecl::ProjectPath& path)
|
||||||
{
|
{
|
||||||
hecl::ProjectPath usePath;
|
const SystemChar* lastCompExt = path.getLastComponentExt();
|
||||||
if (path.getPathType() == hecl::ProjectPath::Type::Glob)
|
|
||||||
usePath = path.getWithExtension(_S(".blend"), true);
|
|
||||||
else
|
|
||||||
usePath = path;
|
|
||||||
|
|
||||||
const SystemChar* lastCompExt = usePath.getLastComponentExt();
|
|
||||||
if (!lastCompExt || hecl::StrCmp(lastCompExt, _S("blend")))
|
if (!lastCompExt || hecl::StrCmp(lastCompExt, _S("blend")))
|
||||||
return false;
|
return false;
|
||||||
FILE* fp = hecl::Fopen(usePath.getAbsolutePath().c_str(), _S("rb"));
|
FILE* fp = hecl::Fopen(path.getAbsolutePath().c_str(), _S("rb"));
|
||||||
if (!fp)
|
if (!fp)
|
||||||
return false;
|
return false;
|
||||||
uint32_t buf;
|
uint32_t buf;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user