src: use FilePath in FileSystem::getFileNamesFromDirectory
This commit is contained in:
@@ -5,11 +5,11 @@
|
||||
#include "boost/date_time.hpp"
|
||||
#include "boost/filesystem.hpp"
|
||||
|
||||
std::vector<std::string> FileSystem::getFileNamesFromDirectory(
|
||||
std::vector<FilePath> FileSystem::getFilePathsFromDirectory(
|
||||
const FilePath& path, const std::vector<std::string>& extensions
|
||||
){
|
||||
std::set<std::string> ext(extensions.begin(), extensions.end());
|
||||
std::vector<std::string> files;
|
||||
std::vector<FilePath> files;
|
||||
|
||||
if (boost::filesystem::is_directory(path.path()))
|
||||
{
|
||||
@@ -30,7 +30,7 @@ std::vector<std::string> FileSystem::getFileNamesFromDirectory(
|
||||
|
||||
if (boost::filesystem::is_regular_file(*it) && ext.find(it->path().extension().string()) != ext.end())
|
||||
{
|
||||
files.push_back(it->path().generic_string());
|
||||
files.push_back(FilePath(it->path().generic_string()));
|
||||
}
|
||||
++it;
|
||||
}
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
class FileSystem
|
||||
{
|
||||
public:
|
||||
static std::vector<std::string> getFileNamesFromDirectory(
|
||||
static std::vector<FilePath> getFilePathsFromDirectory(
|
||||
const FilePath& path, const std::vector<std::string>& extensions);
|
||||
|
||||
static FileInfo getFileInfoForPath(const FilePath& filePath);
|
||||
|
||||
@@ -4,8 +4,10 @@
|
||||
#include <algorithm>
|
||||
#include <cstdarg>
|
||||
#include <deque>
|
||||
#include <functional>
|
||||
#include <set>
|
||||
#include <time.h>
|
||||
#include <vector>
|
||||
#include <unordered_set>
|
||||
|
||||
#include "boost/date_time/posix_time/posix_time.hpp"
|
||||
@@ -58,6 +60,9 @@ namespace utility
|
||||
template<typename T, typename... Args>
|
||||
std::vector<T> createVectorFromElements(const Args&... args);
|
||||
|
||||
template<typename SourceType, typename TargetType>
|
||||
std::vector<TargetType> convert(const std::vector<SourceType>& sourceContainer, std::function<TargetType(const SourceType&)> conversion);
|
||||
|
||||
template<typename T>
|
||||
std::vector<std::string> toStrings(const std::vector<T>& d);
|
||||
template<>
|
||||
@@ -198,6 +203,17 @@ std::vector<T> utility::createVectorFromElements(const Args&... args)
|
||||
return v;
|
||||
}
|
||||
|
||||
template<typename SourceType, typename TargetType>
|
||||
std::vector<TargetType> utility::convert(const std::vector<SourceType>& sourceContainer, std::function<TargetType(const SourceType&)> conversion)
|
||||
{
|
||||
std::vector<TargetType> targetContainer;
|
||||
for (const SourceType& sourceElement: sourceContainer)
|
||||
{
|
||||
targetContainer.push_back(conversion(sourceElement));
|
||||
}
|
||||
return targetContainer;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
std::vector<std::string> utility::toStrings(const std::vector<T>& d)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user