mirror of
https://github.com/AxioDL/metaforce.git
synced 2025-12-09 05:07:43 +00:00
ProjectPath DirectoryEnumerator integration
This commit is contained in:
2
hecl/extern/Athena
vendored
2
hecl/extern/Athena
vendored
Submodule hecl/extern/Athena updated: 8df75c8f23...ca0ff04340
2
hecl/extern/libBoo
vendored
2
hecl/extern/libBoo
vendored
Submodule hecl/extern/libBoo updated: 8ce4e6ffd3...e9bd443e49
@@ -1083,6 +1083,11 @@ public:
|
|||||||
*/
|
*/
|
||||||
void getDirChildren(std::map<SystemString, ProjectPath>& outPaths) const;
|
void getDirChildren(std::map<SystemString, ProjectPath>& outPaths) const;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Construct DirectoryEnumerator set to project path
|
||||||
|
*/
|
||||||
|
HECL::DirectoryEnumerator enumerateDir() const;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Insert glob matches into existing vector
|
* @brief Insert glob matches into existing vector
|
||||||
* @param outPaths Vector to add matches to (will not erase existing contents)
|
* @param outPaths Vector to add matches to (will not erase existing contents)
|
||||||
|
|||||||
@@ -175,22 +175,15 @@ Time ProjectPath::getModtime() const
|
|||||||
}
|
}
|
||||||
else if (S_ISDIR(theStat.st_mode))
|
else if (S_ISDIR(theStat.st_mode))
|
||||||
{
|
{
|
||||||
#if _WIN32
|
HECL::DirectoryEnumerator de(m_absPath);
|
||||||
#else
|
for (const HECL::DirectoryEnumerator::Entry& ent : de)
|
||||||
DIR* dir = opendir(m_absPath.c_str());
|
|
||||||
dirent* de;
|
|
||||||
while ((de = readdir(dir)))
|
|
||||||
{
|
{
|
||||||
if (de->d_name[0] == '.')
|
if (!HECL::Stat(ent.m_path.c_str(), &theStat))
|
||||||
continue;
|
|
||||||
if (!HECL::Stat(de->d_name, &theStat))
|
|
||||||
{
|
{
|
||||||
if (S_ISREG(theStat.st_mode) && theStat.st_mtime > latestTime)
|
if (S_ISREG(theStat.st_mode) && theStat.st_mtime > latestTime)
|
||||||
latestTime = theStat.st_mtime;
|
latestTime = theStat.st_mtime;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
closedir(dir);
|
|
||||||
#endif
|
|
||||||
return Time(latestTime);
|
return Time(latestTime);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -238,65 +231,38 @@ static void _recursiveGlob(Database::Project& proj,
|
|||||||
/* Compile component into regex */
|
/* Compile component into regex */
|
||||||
SystemRegex regComp(comp, SystemRegex::ECMAScript);
|
SystemRegex regComp(comp, SystemRegex::ECMAScript);
|
||||||
|
|
||||||
#if _WIN32
|
HECL::DirectoryEnumerator de(itStr);
|
||||||
#else
|
for (const HECL::DirectoryEnumerator::Entry& ent : de)
|
||||||
DIR* dir = opendir(itStr.c_str());
|
|
||||||
if (!dir)
|
|
||||||
{
|
{
|
||||||
LogModule.report(LogVisor::Error, "unable to open directory for traversal at '%s'", itStr.c_str());
|
if (std::regex_search(ent.m_name, regComp))
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
struct dirent* de;
|
|
||||||
while ((de = readdir(dir)))
|
|
||||||
{
|
|
||||||
if (std::regex_search(de->d_name, regComp))
|
|
||||||
{
|
{
|
||||||
SystemString nextItStr = itStr;
|
SystemString nextItStr = itStr;
|
||||||
if (needSlash)
|
if (needSlash)
|
||||||
nextItStr += '/';
|
nextItStr += '/';
|
||||||
nextItStr += de->d_name;
|
nextItStr += ent.m_name;
|
||||||
|
|
||||||
struct stat theStat;
|
struct stat theStat;
|
||||||
if (stat(nextItStr.c_str(), &theStat))
|
if (stat(nextItStr.c_str(), &theStat))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (S_ISDIR(theStat.st_mode))
|
if (ent.m_isDir)
|
||||||
_recursiveGlob(proj, outPaths, level+1, pathCompMatches, nextItStr, true);
|
_recursiveGlob(proj, outPaths, level+1, pathCompMatches, nextItStr, true);
|
||||||
else if (S_ISREG(theStat.st_mode))
|
else
|
||||||
outPaths.emplace_back(proj, nextItStr);
|
outPaths.emplace_back(proj, nextItStr);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
closedir(dir);
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void ProjectPath::getDirChildren(std::map<SystemString, ProjectPath>& outPaths) const
|
void ProjectPath::getDirChildren(std::map<SystemString, ProjectPath>& outPaths) const
|
||||||
{
|
{
|
||||||
#if _WIN32
|
HECL::DirectoryEnumerator de(m_absPath);
|
||||||
#else
|
for (const HECL::DirectoryEnumerator::Entry& ent : de)
|
||||||
struct dirent* de;
|
outPaths[ent.m_name] = ProjectPath(*this, ent.m_name);
|
||||||
DIR* dir = opendir(m_absPath.c_str());
|
}
|
||||||
if (!dir)
|
|
||||||
{
|
|
||||||
LogModule.report(LogVisor::Error, "unable to open directory for traversal at '%s'", m_absPath.c_str());
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Add elements */
|
HECL::DirectoryEnumerator ProjectPath::enumerateDir() const
|
||||||
rewinddir(dir);
|
{
|
||||||
while ((de = readdir(dir)))
|
return HECL::DirectoryEnumerator(m_absPath);
|
||||||
{
|
|
||||||
if (!strcmp(de->d_name, "."))
|
|
||||||
continue;
|
|
||||||
if (!strcmp(de->d_name, ".."))
|
|
||||||
continue;
|
|
||||||
outPaths[de->d_name] = ProjectPath(*this, de->d_name);
|
|
||||||
}
|
|
||||||
|
|
||||||
closedir(dir);
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void ProjectPath::getGlobResults(std::vector<ProjectPath>& outPaths) const
|
void ProjectPath::getGlobResults(std::vector<ProjectPath>& outPaths) const
|
||||||
|
|||||||
Reference in New Issue
Block a user