From afd0b10d082a20a5e747ffd468cec53584c8007f Mon Sep 17 00:00:00 2001 From: Adrian Aquino-Neary Date: Fri, 7 Apr 2023 10:39:52 +0100 Subject: [PATCH] Avoid errors when creating folders that do not exist --- src/raytracing/Raytracing.cpp | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/src/raytracing/Raytracing.cpp b/src/raytracing/Raytracing.cpp index 4e38c46..d03391a 100644 --- a/src/raytracing/Raytracing.cpp +++ b/src/raytracing/Raytracing.cpp @@ -89,12 +89,18 @@ bool Raytracing::Init() { m_scene->Create(m_settings); } + // check if main renders folder exists + const std::filesystem::path p1{ "renders/" }; + std::filesystem::file_status s1 = std::filesystem::file_status{}; + bool pathExists = std::filesystem::status_known(s1) ? std::filesystem::exists(s1) : std::filesystem::exists(p1); + if (!pathExists) std::filesystem::create_directory(p1); + // checks if folder exists - const std::filesystem::path p{ m_fileFolder }; - std::filesystem::file_status s = std::filesystem::file_status{}; + const std::filesystem::path p2{ m_fileFolder }; + std::filesystem::file_status s2 = std::filesystem::file_status{}; - const bool pathExists = std::filesystem::status_known(s) ? std::filesystem::exists(s) : std::filesystem::exists(p); - if (!pathExists) std::filesystem::create_directory(p); + pathExists = std::filesystem::status_known(s2) ? std::filesystem::exists(s2) : std::filesystem::exists(p2); + if (!pathExists) std::filesystem::create_directory(p2); // ----- GENERATE BLUE NOISE -----