Files
spark/src/lib/utils/file_utils.cpp
T

30 lines
739 B
C++

#include "file_utils.h"
#include "bts_assert.h"
#include "lib/os/os.h"
#include <boost/algorithm/string/predicate.hpp>
#include <boost/algorithm/string/replace.hpp>
#include <boost/filesystem.hpp>
namespace bts {
namespace utils {
bool create_if_not_there(std::string const &path) {
if (!boost::filesystem::exists(path)) {
bts_assert_msg(
boost::filesystem::create_directories(path),
"Unable to create directory");
return false;
} else
return true;
}
std::string normalize_data_path(std::string const &input_path) {
std::string result(input_path);
boost::algorithm::replace_first(result, "$data_path", os::bts_data_path());
return result;
}
} // namespace utils
} // namespace bts