From 35b5e423da6e4ff02db9aac7611f6c534b2c88b7 Mon Sep 17 00:00:00 2001 From: Eberhard Graether Date: Wed, 2 Dec 2015 15:23:27 +0100 Subject: [PATCH] utility: creating directories with boost in FileSystem method --- src/lib/utility/file/FileSystem.cpp | 5 +++++ src/lib/utility/file/FileSystem.h | 1 + src/lib/utility/logging/FileLogger.cpp | 5 +++-- 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/src/lib/utility/file/FileSystem.cpp b/src/lib/utility/file/FileSystem.cpp index a75b5d71..ebadeeb2 100644 --- a/src/lib/utility/file/FileSystem.cpp +++ b/src/lib/utility/file/FileSystem.cpp @@ -159,6 +159,11 @@ bool FileSystem::equivalent(const std::string& pathA, const std::string& pathB) return boost::filesystem::path(pathA).compare(boost::filesystem::path(pathB)) == 0; } +void FileSystem::createDirectory(const FilePath& path) +{ + boost::filesystem::create_directory(path.str()); +} + std::vector FileSystem::getSubDirectories(const FilePath &path) { std::vector v; diff --git a/src/lib/utility/file/FileSystem.h b/src/lib/utility/file/FileSystem.h index 79eebb5a..e416d8b3 100644 --- a/src/lib/utility/file/FileSystem.h +++ b/src/lib/utility/file/FileSystem.h @@ -23,6 +23,7 @@ public: static TimePoint getLastWriteTime(const FilePath& filePath); static std::string getTimeStringNow(); + static void createDirectory(const FilePath& path); static std::vector getSubDirectories(const FilePath& path); static bool exists(const std::string& path); diff --git a/src/lib/utility/logging/FileLogger.cpp b/src/lib/utility/logging/FileLogger.cpp index a8e2f0d6..84712755 100644 --- a/src/lib/utility/logging/FileLogger.cpp +++ b/src/lib/utility/logging/FileLogger.cpp @@ -1,9 +1,10 @@ #include "FileLogger.h" -#include #include #include +#include "utility/file/FileSystem.h" + std::string FileLogger::s_filePath = "data/log/"; FileLogger::FileLogger() @@ -56,7 +57,7 @@ void FileLogger::createDirectory() { if (s_filePath.length() > 0) { - mkdir(s_filePath.c_str()); + FileSystem::createDirectory(s_filePath); } }