Skip to content

Commit

Permalink
Merge pull request #706 from smowton/remove_boost_fs_dependency
Browse files Browse the repository at this point in the history
Replace boost dependency with simple mkdir -p implementation
  • Loading branch information
peterschrammel authored Mar 28, 2017
2 parents 3f87bb2 + 037da22 commit 36851e1
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 15 deletions.
1 change: 0 additions & 1 deletion src/config.inc
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
32 changes: 18 additions & 14 deletions src/util/file_util.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,6 @@ Date: January 2012
#include <cstring>
#endif

#ifdef USE_BOOST
#include <boost/filesystem.hpp>
#endif

#include "file_util.h"


Expand Down Expand Up @@ -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(
Expand Down

0 comments on commit 36851e1

Please sign in to comment.