diff --git a/mcopy.cpp b/mcopy.cpp index 74d2c89..bf895ba 100644 --- a/mcopy.cpp +++ b/mcopy.cpp @@ -123,12 +123,14 @@ void getMetadataFromFile(std::string format, std::string str) { std::string dir = (fs = filename).remove_filename(); if (dir.empty()) { - std::cerr << "mcopy: Failed to create directory '" << dir << "'\n"; + std::cerr << "mcopy: Was not able to get a directory.\n"; return; } - if (!std::filesystem::create_directories(dir)) { - std::cerr << "mcopy: Failed to create directory '" << dir << "'\n"; + if (!std::filesystem::exists(fs.remove_filename())) { + if (!std::filesystem::create_directories(dir)) { + std::cerr << "mcopy: Failed to create directory '" << dir << "'\n"; + } } if (!std::filesystem::copy_file(str, filename)) {