Attempt to properly scan all the files during scan
This commit is contained in:
@@ -87,3 +87,39 @@ getLastWriteTime(const std::filesystem::path& file)
|
||||
return Wt::WDateTime::fromTime_t(sb.st_mtime);
|
||||
}
|
||||
|
||||
void
|
||||
exploreFilesRecursive(const std::filesystem::path& directory, std::function<void(std::error_code, const std::filesystem::path&)> cb)
|
||||
{
|
||||
std::error_code ec;
|
||||
std::filesystem::directory_iterator itPath {directory, std::filesystem::directory_options::follow_directory_symlink, ec};
|
||||
|
||||
if (ec)
|
||||
{
|
||||
cb(ec, directory);
|
||||
return;
|
||||
}
|
||||
|
||||
std::filesystem::directory_iterator itEnd;
|
||||
while (itPath != itEnd)
|
||||
{
|
||||
if (ec)
|
||||
{
|
||||
cb(ec, *itPath);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (std::filesystem::is_regular_file(*itPath, ec))
|
||||
cb(ec, *itPath);
|
||||
else if (std::filesystem::is_directory(*itPath, ec))
|
||||
{
|
||||
if (!ec)
|
||||
exploreFilesRecursive(*itPath, cb);
|
||||
else
|
||||
cb(ec, *itPath);
|
||||
}
|
||||
}
|
||||
|
||||
itPath.increment(ec);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -20,6 +20,7 @@
|
||||
#pragma once
|
||||
|
||||
#include <filesystem>
|
||||
#include <functional>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
@@ -34,10 +35,13 @@ bool ensureDirectory(const std::filesystem::path& dir);
|
||||
// Get the last write time since Epoch
|
||||
Wt::WDateTime getLastWriteTime(const std::filesystem::path& dir);
|
||||
|
||||
namespace std {
|
||||
void exploreFilesRecursive(const std::filesystem::path& directory, std::function<void(std::error_code, const std::filesystem::path&)> cb);
|
||||
|
||||
namespace std
|
||||
{
|
||||
template <>
|
||||
struct hash<std::filesystem::path> {
|
||||
struct hash<std::filesystem::path>
|
||||
{
|
||||
inline std::size_t operator()(const std::filesystem::path &path) const { return hash_value(path); }
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user