Merge pull request #1551 from joakim-hove/opmpack-fix2

Fix opmpack copy_file option in the case of empty directories
This commit is contained in:
Joakim Hove 2020-03-10 12:22:30 +01:00 committed by GitHub
commit e3600cfc19
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -85,9 +85,11 @@ void copy_file(const fs::path& source_dir, fs::path fname, const fs::path& targe
auto source_file = source_dir / fname;
auto target_file = target_dir / fname;
if (!fs::is_directory(target_file.parent_path()))
fs::create_directories(target_file.parent_path());
{
const auto& parent_path = target_file.parent_path();
if (!parent_path.empty() && !fs::is_directory(parent_path))
fs::create_directories(parent_path);
}
fs::copy_file(source_file, target_file, fs::copy_options::overwrite_existing);
std::cerr << "Copying file " << source_file.string() << " -> " << target_file.string() << std::endl;