Commit 99366b97 authored by Sebastian Wolf's avatar Sebastian Wolf

Allow './whatever.dat' in misc::create_directories_for_file

parent 8ab4f5ce
Pipeline #1811 failed with stages
in 12 minutes and 23 seconds
......@@ -42,8 +42,14 @@ namespace xerus { namespace misc {
void create_directories_for_file(const std::string& _path) {
if(_path.find('/') != std::string::npos) {
const std::string folder = _path.substr(0, _path.find_last_of('/'));
boost::filesystem::create_directories(folder);
std::string folder = _path.substr(0, _path.find_last_of('/'));
// Remove trailing / (can appear e.g. in "folder//file.dat").
while(folder.back() == '/') { folder.pop_back(); }
if(folder != ".") { // Boost doesn't like being called with ".".
boost::filesystem::create_directories(folder);
}
}
}
......
......@@ -27,10 +27,6 @@
#include <chrono>
#include <fstream>
#ifdef XERUS_LOG_BUFFER
#include <fstream>
#endif
#include <xerus/misc/namedLogger.h>
#include <xerus/misc/stringUtilities.h>
......
......@@ -37,7 +37,7 @@ namespace xerus {
if (realname) {
return std::string(realname.get());
}
}
return "";
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment