Fix trailing slashes not to rely on boost

This commit is contained in:
Tadas Baltrusaitis 2018-02-02 21:33:10 +00:00
parent d63cb0943f
commit 186f478dfc

View file

@ -55,13 +55,15 @@ std::cout << "Warning: " << stream << std::endl
void CreateDirectory(std::string output_path) void CreateDirectory(std::string output_path)
{ {
// Removing trailing separators, as that causes issues with directory creation in unix
while (output_path[output_path.size() - 1] == '/' || output_path[output_path.size() - 1] == '\\')
{
output_path = output_path.substr(0, output_path.size() - 1);
}
// Creating the right directory structure // Creating the right directory structure
auto p = path(output_path); auto p = path(output_path);
// Deal with a case where directory ends with a \\ or /
p = p.remove_trailing_separator();
if (!boost::filesystem::exists(p)) if (!boost::filesystem::exists(p))
{ {
bool success = boost::filesystem::create_directories(p); bool success = boost::filesystem::create_directories(p);