Add option to get file size of all opened archives
This commit is contained in:
@@ -101,7 +101,7 @@ namespace OpenVulkano
|
||||
}
|
||||
}
|
||||
|
||||
bool ArchiveReader::Open(const std::filesystem::path& dir, const std::string& fileNamePattern)
|
||||
bool ArchiveReader::Open(const std::filesystem::path& dir, const std::string& fileNamePattern, size_t* outSize)
|
||||
{
|
||||
std::vector<std::string> files;
|
||||
|
||||
@@ -109,9 +109,13 @@ namespace OpenVulkano
|
||||
for(const std::filesystem::directory_entry& dirEntry : std::filesystem::directory_iterator(dir))
|
||||
{
|
||||
std::string entryPath = dirEntry.path().string();
|
||||
if (std::regex_match(entryPath, fileRegex))
|
||||
if (!dirEntry.is_directory() && std::regex_match(entryPath, fileRegex))
|
||||
{
|
||||
files.push_back(std::move(entryPath));
|
||||
if (outSize)
|
||||
{
|
||||
*outSize += dirEntry.file_size();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -42,7 +42,7 @@ namespace OpenVulkano
|
||||
|
||||
bool Open(const std::vector<std::string>& archiveFiles);
|
||||
|
||||
bool Open(const std::filesystem::path& dir, const std::string& fileNamePattern);
|
||||
bool Open(const std::filesystem::path& dir, const std::string& fileNamePattern, size_t* outSize = nullptr);
|
||||
|
||||
[[nodiscard]] bool IsOpen() const { return m_open; }
|
||||
|
||||
|
||||
@@ -36,7 +36,7 @@ namespace OpenVulkano
|
||||
ArchiveWriter::~ArchiveWriter()
|
||||
{
|
||||
if (m_asBuffer) { m_asBuffer->Close(); m_asBuffer = nullptr; }
|
||||
archive_write_close(m_archive);
|
||||
ChkErr(archive_write_close(m_archive));
|
||||
archive_entry_free(m_archiveEntry);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user