mirror of https://github.com/AxioDL/metaforce.git
ProjectPath DirectoryEnumerator integration
This commit is contained in:
parent
7c1b4572d6
commit
195c58cd8b
|
@ -1 +1 @@
|
||||||
Subproject commit 8df75c8f23e32c38c7a9735fcc06538fbf412660
|
Subproject commit ca0ff04340bd6a25eed1e738e6d976d4a10acf31
|
|
@ -1 +1 @@
|
||||||
Subproject commit 8ce4e6ffd32dc579bdbbad39abce1519251d7e37
|
Subproject commit e9bd443e492478b7127ddce039c362f364792844
|
|
@ -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)))
|
|
||||||
{
|
{
|
||||||
if (!strcmp(de->d_name, "."))
|
return HECL::DirectoryEnumerator(m_absPath);
|
||||||
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
|
||||||
|
|
Loading…
Reference in New Issue