Add option for lazy archive creation with MultiPartArchiveWriter
This commit is contained in:
@@ -14,15 +14,16 @@ namespace openVulkanoCpp
|
||||
{
|
||||
MultiPartArchiveWriter::MultiPartArchiveWriter(const std::string& dir, const std::string& fileNamePattern,
|
||||
const ArchiveConfiguration& archiveConfiguration,
|
||||
size_t sizeLimit, const std::shared_ptr<spdlog::logger>& logger)
|
||||
size_t sizeLimit, bool lazyCreation,
|
||||
const std::shared_ptr<spdlog::logger>& logger)
|
||||
: m_fileSizeLimit(sizeLimit), m_archiveId(0), m_archiveConfig(archiveConfiguration)
|
||||
, m_dir(dir), m_fileNamePattern(fileNamePattern), m_logger(logger)
|
||||
, m_dir(dir), m_fileNamePattern(fileNamePattern), m_logger(logger), m_lazyCreation(lazyCreation)
|
||||
{
|
||||
if (!m_dir.empty() && !std::filesystem::exists(m_dir))
|
||||
{
|
||||
std::filesystem::create_directories(m_dir);
|
||||
}
|
||||
StartNewFile();
|
||||
if (!lazyCreation) StartNewFile();
|
||||
}
|
||||
|
||||
MultiPartArchiveWriter::~MultiPartArchiveWriter()
|
||||
@@ -99,12 +100,12 @@ namespace openVulkanoCpp
|
||||
m_archives.clear();
|
||||
}
|
||||
m_dir = newDir;
|
||||
StartNewFile();
|
||||
if (!m_lazyCreation) StartNewFile();
|
||||
}
|
||||
|
||||
void MultiPartArchiveWriter::Split()
|
||||
{
|
||||
if (!m_writer->GetTotalWrittenBytes()) return; // Nothing has been written yet, no need to split file
|
||||
if (!m_writer || !m_writer->GetTotalWrittenBytes()) return; // Nothing has been written yet, no need to split file
|
||||
m_writer = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user