utility: boost integration
Added boost components: filesystem and system to the project environment varibable BOOST_155_DIR targeting the boost_1_55_0 folder is needed review id = 14 fortune cookie message = when you speak honestly and openly, others truly listen to you
This commit is contained in:
@@ -98,7 +98,7 @@ add_files(
|
||||
utility/logging/LogManagerImplementation.cpp
|
||||
utility/logging/LogManagerImplementation.h
|
||||
utility/logging/LogMessage.h
|
||||
|
||||
|
||||
utility/math/Color.h
|
||||
utility/math/Vector2.h
|
||||
utility/math/Vector4.h
|
||||
@@ -112,6 +112,8 @@ add_files(
|
||||
|
||||
utility/ConfigManager.cpp
|
||||
utility/ConfigManager.h
|
||||
utility/FileSystem.cpp
|
||||
utility/FileSystem.h
|
||||
utility/Vector.h
|
||||
|
||||
Application.cpp
|
||||
|
||||
@@ -0,0 +1,43 @@
|
||||
#include "utility/FileSystem.h"
|
||||
|
||||
#include "boost/filesystem.hpp"
|
||||
#include "utility/logging/logging.h"
|
||||
|
||||
std::vector<std::string> FileSystem::getSourceFilesFromDirectory(
|
||||
const std::string& path, const std::vector<std::string>& extensions
|
||||
)
|
||||
{
|
||||
std::vector<std::string> files;
|
||||
if (boost::filesystem::is_directory(path))
|
||||
{
|
||||
boost::filesystem::recursive_directory_iterator it(path);
|
||||
boost::filesystem::recursive_directory_iterator endit;
|
||||
while(it != endit)
|
||||
{
|
||||
if (boost::filesystem::is_regular_file(*it) && isValidExtension(it->path().string(), extensions))
|
||||
{
|
||||
files.push_back(it->path().string());
|
||||
}
|
||||
++it;
|
||||
}
|
||||
}
|
||||
return files;
|
||||
}
|
||||
|
||||
bool FileSystem::isValidExtension(const std::string& filepath, const std::vector<std::string>& extensions)
|
||||
{
|
||||
boost::filesystem::path path(filepath);
|
||||
for(std::string extension : extensions)
|
||||
{
|
||||
if(path.extension() == extension)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool FileSystem::exists(const std::string& path)
|
||||
{
|
||||
return boost::filesystem::exists(boost::filesystem::path(path));
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
#ifndef FILE_SYSTEM_H
|
||||
#define FILE_SYSTEM_H
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
class FileSystem
|
||||
{
|
||||
public:
|
||||
static std::vector<std::string> getSourceFilesFromDirectory(
|
||||
const std::string& path, const std::vector<std::string>& extensions
|
||||
);
|
||||
static bool exists(const std::string& path);
|
||||
private:
|
||||
static bool isValidExtension(const std::string& filepath, const std::vector<std::string>& extensions);
|
||||
};
|
||||
|
||||
#endif // FILE_SYSTEM_H
|
||||
Reference in New Issue
Block a user