From 037da220c80f4e328ad7fdcd477dbc042655023f Mon Sep 17 00:00:00 2001 From: Chris Smowton Date: Tue, 28 Mar 2017 09:03:23 +0100 Subject: [PATCH] Replace boost dependency with simple mkdir -p implementation --- src/config.inc | 1 - src/util/file_util.cpp | 32 ++++++++++++++++++-------------- 2 files changed, 18 insertions(+), 15 deletions(-) diff --git a/src/config.inc b/src/config.inc index 84a7749ee07..fa5e167416d 100644 --- a/src/config.inc +++ b/src/config.inc @@ -13,7 +13,6 @@ BUILD_ENV = AUTO ifeq ($(shell uname),Linux) CXXFLAGS += -DUSE_BOOST - LIBS=-lboost_filesystem -lboost_system endif # On Windows this Makefile is subject to sed s/BUILD_ENV.*/BUILD_ENV = MSVC, diff --git a/src/util/file_util.cpp b/src/util/file_util.cpp index 6e4a16eb50a..a5a44d4236f 100644 --- a/src/util/file_util.cpp +++ b/src/util/file_util.cpp @@ -45,10 +45,6 @@ Date: January 2012 #include #endif -#ifdef USE_BOOST -#include -#endif - #include "file_util.h" @@ -238,18 +234,26 @@ std::string fileutl_remove_extension(std::string const &filename) void fileutl_create_directory(std::string const &pathname) { # if defined(WIN32) - std::system((std::string("mkdir \"") + pathname + "\"").c_str()); -# elif defined(__linux__) || defined(__APPLE__) -#ifdef USE_BOOST - boost::filesystem::create_directories(pathname); + char path_sep='\\'; #else - auto ignore = std::system( - (std::string("mkdir -p \"") + pathname + "\"").c_str()); - (void)ignore; + char path_sep='/'; #endif -# else -# error "Unsuported platform." -# endif + std::size_t search_from=0; + while(search_from!=std::string::npos) + { + // Search from after the previous path separator, incidentally + // skipping trying to create '/' if an absolute path is given + search_from=pathname.find(path_sep, search_from+1); + std::string truncated_pathname=pathname.substr(0, search_from); +#if defined(WIN32) + _mkdir(truncated_pathname.c_str()); +#else + mkdir(truncated_pathname.c_str(), 0777); +#endif + // Ignore return-- regardless of why we can't create a + // path prefix, we might as well keep trying down to more + // specific paths. + } } std::string fileutl_concatenate_file_paths(