diff --git a/src/WebsiteBuilder.cxx b/src/WebsiteBuilder.cxx index 6ba74fc..1f8f1da 100644 --- a/src/WebsiteBuilder.cxx +++ b/src/WebsiteBuilder.cxx @@ -208,19 +208,30 @@ void build_website(SwgContext &ctx, std::string const &path) { getFilename(ws_entry.path()).length()); if (!std::filesystem::exists(copied_subdir)) { std::filesystem::create_directories(copied_subdir); - std::cout << "--> Creating: " << copied_subdir << "\n"; + std::cout << "Creating: " << copied_subdir << "\n"; } // If this isn't a Markdown file, just copy it. - if (currentFile.find(".md") == std::string::npos) - std::filesystem::copy(ws_entry, copied_subdir); - else { + bool compiled = false; + if (currentFile.find(".md") == std::string::npos) { + try { + std::filesystem::copy(ws_entry, copied_subdir); + } catch (std::filesystem::filesystem_error const &cpyErr) { + // Ignore exception if it was + // thrown due to an existing + // file error while copying. + if (cpyErr.code().value() != 17) + throw cpyErr; + } + } else { // This is a Markdown file. Compile a HTML version. std::filesystem::path output_html = copied_subdir; // Remove the .md extension and use the HTML extension instead output_html /= currentFile.substr(0, currentFile.length() - 3) + ".html"; compile_markdown(path, ws_entry.path(), output_html); + compiled = true; } - std::cout << "\t!: " << ws_entry.path().string().substr(path.length()) << "\n"; + std::cout << (compiled ? "Compiled: " : "Copied: ") << + ws_entry.path().string().substr(path.length()) << "\n"; } } } catch (std::filesystem::filesystem_error const &e) {