Refactored scanner to ease further improvements
This commit is contained in:
@@ -26,15 +26,25 @@
|
||||
|
||||
#include <Wt/WDateTime.h>
|
||||
|
||||
std::uint32_t computeCrc32(const std::filesystem::path& p);
|
||||
namespace PathUtils
|
||||
{
|
||||
std::uint32_t computeCrc32(const std::filesystem::path& p);
|
||||
|
||||
// Make sure the given path is a directory
|
||||
// Create it if needed
|
||||
bool ensureDirectory(const std::filesystem::path& dir);
|
||||
// Make sure the given path is a directory
|
||||
// Create it if needed
|
||||
bool ensureDirectory(const std::filesystem::path& dir);
|
||||
|
||||
// Get the last write time since Epoch
|
||||
Wt::WDateTime getLastWriteTime(const std::filesystem::path& dir);
|
||||
// Get the last write time since Epoch
|
||||
Wt::WDateTime getLastWriteTime(const std::filesystem::path& dir);
|
||||
|
||||
// returns false if aborted by user
|
||||
bool exploreFilesRecursive(const std::filesystem::path& directory, std::function<bool(std::error_code, const std::filesystem::path&)> cb, const std::filesystem::path& excludeDirFileName = {});
|
||||
// returns false if aborted by user
|
||||
bool exploreFilesRecursive(const std::filesystem::path& directory, std::function<bool(std::error_code, const std::filesystem::path&)> cb, const std::filesystem::path* excludeDirFileName = {});
|
||||
|
||||
// Check if file's extension is one of provided extensions
|
||||
bool hasFileAnyExtension(const std::filesystem::path& file, const std::vector<std::filesystem::path>& extensions);
|
||||
|
||||
// Check if a path is within a directory (excludeDirFileName is a relative can be used to exclude a whole directory and its subdirectory, must not have parent_path)
|
||||
bool isPathInRootPath(const std::filesystem::path& path, const std::filesystem::path& rootPath, const std::filesystem::path* excludeDirFileName = {});
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,51 @@
|
||||
/*
|
||||
* Copyright (C) 2015 Emeric Poupon
|
||||
*
|
||||
* This file is part of LMS.
|
||||
*
|
||||
* LMS is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* LMS is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with LMS. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <tuple>
|
||||
|
||||
namespace Utils
|
||||
{
|
||||
namespace Details
|
||||
{
|
||||
template<int... Is>
|
||||
struct Seq { };
|
||||
|
||||
template<int N, int... Is>
|
||||
struct GenSeq : GenSeq<N - 1, N - 1, Is...> { };
|
||||
|
||||
template<int... Is>
|
||||
struct GenSeq<0, Is...> : Seq<Is...> { };
|
||||
|
||||
template<typename T, typename Func, int... Is>
|
||||
void forEachTypeInTuple(T&& t, Func f, Seq<Is...>)
|
||||
{
|
||||
auto l = { (f(std::get<Is>(t)), 0)... };
|
||||
}
|
||||
}
|
||||
|
||||
template<typename... Ts, typename Func>
|
||||
void forEachTypeInTuple(std::tuple<Ts...> const& t, Func f)
|
||||
{
|
||||
Details::forEachTypeInTuple(t, f, Details::GenSeq<sizeof...(Ts)>());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user