From c293e20d25dcb12469a0b0d3eb5a17135b0c95c9 Mon Sep 17 00:00:00 2001 From: "Ignacio R. Morelle" Date: Sun, 9 Nov 2014 18:53:49 -0300 Subject: [PATCH] fs: Fix relative directory creation incongruity with Boost.filesystem The non-BFS version of create_directory_if_missing_recursive() handles relative path names (e.g. "foo") correctly and doesn't attempt to create a parent that is left unspecified in the path (i.e. empty), but the BFS version does, predictably failing the whole operation. This fixes an issue where `./wesnoth -p data foo` from the source tree would fail with `error filesystem: Could not create parents to foo` if `foo` did not already exist, when using the Boost.filesystem-based implementation. `./wesnoth -p data ./foo` would succeed because there is a visible parent directory '.' that already exists and needs not be created again. --- src/filesystem_boost.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/filesystem_boost.cpp b/src/filesystem_boost.cpp index f9b660d18b64..b9962eac8866 100644 --- a/src/filesystem_boost.cpp +++ b/src/filesystem_boost.cpp @@ -283,7 +283,7 @@ static bool create_directory_if_missing_recursive(const path& dirpath) return false; } - if (create_directory_if_missing_recursive(dirpath.parent_path())) { + if (!dirpath.has_parent_path() || create_directory_if_missing_recursive(dirpath.parent_path())) { return create_directory_if_missing(dirpath); } else { ERR_FS << "Could not create parents to " << dirpath.string() << '\n';