From 55519c1962aa44c10f4f28df3bec0778da8e656f Mon Sep 17 00:00:00 2001 From: yaman-lunarg <159067796+yaman-lunarg@users.noreply.github.com> Date: Thu, 22 Feb 2024 08:39:50 -0800 Subject: [PATCH] fixes #1422:gfxrecon-replay to create --screenshot-dir if it doesn't exist (#1425) --- .../decode/vulkan_replay_consumer_base.cpp | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/framework/decode/vulkan_replay_consumer_base.cpp b/framework/decode/vulkan_replay_consumer_base.cpp index fe95bdd804..ee717182c6 100644 --- a/framework/decode/vulkan_replay_consumer_base.cpp +++ b/framework/decode/vulkan_replay_consumer_base.cpp @@ -2056,6 +2056,25 @@ void VulkanReplayConsumerBase::InitializeScreenshotHandler() if (!options_.screenshot_dir.empty()) { + if (util::filepath::Exists(options_.screenshot_dir)) + { + if (!util::filepath::IsDirectory(options_.screenshot_dir)) + { + GFXRECON_WRITE_CONSOLE("Error while creating directory %s: Already exists as file", + options_.screenshot_dir.c_str()); + exit(-1); + } + } + else + { + int32_t result = gfxrecon::util::platform::MakeDirectory(options_.screenshot_dir.c_str()); + if (result < 0) + { + GFXRECON_WRITE_CONSOLE("Error while creating directory %s: Could not open", + options_.screenshot_dir.c_str()); + exit(-1); + } + } screenshot_file_prefix_ = util::filepath::Join(options_.screenshot_dir, screenshot_file_prefix_); }