From b11461ab9e5240d9df3fa7a5dd21d7bf9c90c659 Mon Sep 17 00:00:00 2001 From: speedie Date: Wed, 30 Aug 2023 16:32:31 +0200 Subject: [PATCH] Check if create_directories() was successful --- mcopy.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/mcopy.cpp b/mcopy.cpp index 48610c9..74d2c89 100644 --- a/mcopy.cpp +++ b/mcopy.cpp @@ -127,7 +127,9 @@ void getMetadataFromFile(std::string format, std::string str) { return; } - std::filesystem::create_directories(dir); + if (!std::filesystem::create_directories(dir)) { + std::cerr << "mcopy: Failed to create directory '" << dir << "'\n"; + } if (!std::filesystem::copy_file(str, filename)) { std::cerr << "mcopy: Failed to copy file " << str << " to " << filename << "\n";