Skip to content

Replace boost dependency with simple mkdir -p implementation #706

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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