Fix opmpack copy_file option in the case of empty directories

This commit is contained in:
Joakim Hove 2020-03-10 10:58:30 +01:00
parent b8a30805d3
commit 02fd4ab340

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;