Add method to manually split archive and delete last split if empty
This commit is contained in:
@@ -25,7 +25,12 @@ namespace openVulkanoCpp
|
||||
StartNewFile();
|
||||
}
|
||||
|
||||
MultiPartArchiveWriter::~MultiPartArchiveWriter() = default;
|
||||
MultiPartArchiveWriter::~MultiPartArchiveWriter()
|
||||
{
|
||||
bool deleteLast = m_writer->GetTotalWrittenBytes() == 0;
|
||||
m_writer = nullptr;
|
||||
if (deleteLast) std::filesystem::remove(m_archives.back());
|
||||
}
|
||||
|
||||
void MultiPartArchiveWriter::StartNewFile()
|
||||
{
|
||||
@@ -96,4 +101,10 @@ namespace openVulkanoCpp
|
||||
m_dir = newDir;
|
||||
StartNewFile();
|
||||
}
|
||||
|
||||
void MultiPartArchiveWriter::Split()
|
||||
{
|
||||
if (!m_writer->GetTotalWrittenBytes()) return; // Nothing has been written yet, no need to split file
|
||||
StartNewFile();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -45,5 +45,7 @@ namespace openVulkanoCpp
|
||||
void Move(const std::filesystem::path& newDir);
|
||||
|
||||
[[nodiscard]] const std::filesystem::path& GetDir() const { return m_dir; }
|
||||
|
||||
void Split();
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user