Skip to content

Commit

Permalink
Merge pull request #25 from kakol20/filesystem
Browse files Browse the repository at this point in the history
Avoid errors when creating folders that do not exist
  • Loading branch information
kakol20 authored Apr 7, 2023
2 parents 1875589 + afd0b10 commit 294b319
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions src/raytracing/Raytracing.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 -----

Expand Down

0 comments on commit 294b319

Please sign in to comment.