Silence warnings and fix bugs
This commit is contained in:
@@ -11,15 +11,15 @@
|
||||
*/
|
||||
|
||||
#include "ZipWriter.hpp"
|
||||
#include "Base/Utils.hpp"
|
||||
#include "IO/MemMappedFile.hpp"
|
||||
#include "Math/CRC32.hpp"
|
||||
|
||||
#include <ctime>
|
||||
#include <cstdint>
|
||||
|
||||
namespace
|
||||
{
|
||||
#pragma clang diagnostic push
|
||||
#pragma ide diagnostic ignored "OCUnusedGlobalDeclarationInspection"
|
||||
#pragma pack(push, 1)
|
||||
struct LocalFileHeader
|
||||
{
|
||||
@@ -38,7 +38,7 @@ namespace
|
||||
// Extra Field[m]
|
||||
};
|
||||
|
||||
struct CentalDirectoryFileHeader
|
||||
struct CentralDirectoryFileHeader
|
||||
{
|
||||
uint32_t signature = 0x02014b50;
|
||||
uint16_t versionMadeBy = 31; // Version made by
|
||||
@@ -100,9 +100,10 @@ namespace
|
||||
// Comment[n]
|
||||
};
|
||||
#pragma pack(pop)
|
||||
#pragma clang diagnostic pop
|
||||
|
||||
static_assert(sizeof(LocalFileHeader) == 30, "Well packed struct");
|
||||
static_assert(sizeof(CentalDirectoryFileHeader) == 46, "Well packed struct");
|
||||
static_assert(sizeof(CentralDirectoryFileHeader) == 46, "Well packed struct");
|
||||
static_assert(sizeof(EndOfCentralDirectoryHeader) == 22, "Well packed struct");
|
||||
static_assert(sizeof(NtfsExtraField) == 36, "Well packed struct");
|
||||
|
||||
@@ -119,7 +120,7 @@ namespace
|
||||
return Cat(dest, sizeof(T), reinterpret_cast<const uint8_t*>(thing));
|
||||
}
|
||||
|
||||
uint32_t Cat(std::vector<uint8_t>& dest, const std::vector<uint8_t>& thing)
|
||||
[[maybe_unused]] uint32_t Cat(std::vector<uint8_t>& dest, const std::vector<uint8_t>& thing)
|
||||
{
|
||||
return Cat(dest, thing.size(), thing.data());
|
||||
}
|
||||
@@ -156,14 +157,14 @@ namespace
|
||||
|
||||
namespace OpenVulkano
|
||||
{
|
||||
ZipWriter::ZipWriter(const std::filesystem::path& filePath, bool alignHeadersby64)
|
||||
ZipWriter::ZipWriter(const std::filesystem::path& filePath, bool alignHeadersBy64)
|
||||
{
|
||||
m_file = fopen(filePath.string().c_str(), "wb");
|
||||
if (!m_file)
|
||||
{
|
||||
throw std::runtime_error("Unable to open file for writing: " + filePath.string());
|
||||
}
|
||||
m_pad = alignHeadersby64;
|
||||
m_pad = alignHeadersBy64;
|
||||
}
|
||||
|
||||
void ZipWriter::AddFile(const FileDescription& description, const void* buffer)
|
||||
@@ -209,7 +210,7 @@ namespace OpenVulkano
|
||||
|
||||
fwrite(buffer, fileSize, 1, m_file);
|
||||
|
||||
CentalDirectoryFileHeader cdfh;
|
||||
CentralDirectoryFileHeader cdfh;
|
||||
cdfh.fileLastModTime = dosTime;
|
||||
cdfh.fileLastModDate = dosDate;
|
||||
cdfh.crc32 = crc32;
|
||||
@@ -231,7 +232,7 @@ namespace OpenVulkano
|
||||
void ZipWriter::AddFile(const std::filesystem::path& fileName, const char* inArchiveName)
|
||||
{
|
||||
MemMappedFile file = MemMappedFile(fileName.string());
|
||||
auto desc = OpenVulkano::FileDescription::MakeDescriptionForFile(inArchiveName, file.Size());
|
||||
auto desc = OpenVulkano::FileDescription::MkFile(inArchiveName, file.Size());
|
||||
AddFile(desc, file.Data());
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user