Fix issues with not existing dirs for MultiPartArchiveWriter

This commit is contained in:
2021-05-17 00:10:20 +02:00
parent 3440c65ddc
commit 4eeafafe34
2 changed files with 6 additions and 2 deletions

View File

@@ -18,7 +18,7 @@ namespace openVulkanoCpp
: m_fileSizeLimit(sizeLimit), m_archiveId(0), m_archiveConfig(archiveConfiguration)
, m_dir(dir), m_fileNamePattern(fileNamePattern), m_logger(logger)
{
if (!std::filesystem::exists(m_dir))
if (!m_dir.empty() && !std::filesystem::exists(m_dir))
{
std::filesystem::create_directories(m_dir);
}
@@ -72,6 +72,10 @@ namespace openVulkanoCpp
{
bool hasToMove = m_archives.size() > 1 || m_writer->GetTotalWrittenBytes() > 0;
m_writer = nullptr; // Close current archive
if (!newDir.empty() && !std::filesystem::exists(newDir))
{
std::filesystem::create_directories(newDir);
}
if (hasToMove)
{ // Move all existing archives
std::vector<std::filesystem::path> newArchivePaths;

View File

@@ -44,6 +44,6 @@ namespace openVulkanoCpp
void Move(const std::filesystem::path& newDir);
const std::filesystem::path& GetDir() const { return m_dir; }
[[nodiscard]] const std::filesystem::path& GetDir() const { return m_dir; }
};
}