Silence warnings and fix bugs
This commit is contained in:
@@ -35,9 +35,9 @@ namespace OpenVulkano
|
||||
return std::string(tName);
|
||||
}
|
||||
|
||||
ArchiveConfiguration ArchiveConfiguration::FromFileName(std::filesystem::path fileName)
|
||||
ArchiveConfiguration ArchiveConfiguration::FromFileName(const std::filesystem::path& fileName)
|
||||
{
|
||||
std::string_view fName = fileName.string();
|
||||
std::string fName = fileName.filename().string();
|
||||
ArchiveConfiguration ac;
|
||||
if (auto type = ArchiveType::FromExtension(fName))
|
||||
{
|
||||
|
||||
@@ -27,7 +27,7 @@ namespace OpenVulkano
|
||||
: type(archiveType), compression(compressionType), compressionLevel(level)
|
||||
{}
|
||||
|
||||
[[nodiscard]] static ArchiveConfiguration FromFileName(std::filesystem::path fileName);
|
||||
[[nodiscard]] static ArchiveConfiguration FromFileName(const std::filesystem::path& fileName);
|
||||
|
||||
[[nodiscard]] std::string GetFileExtension() const;
|
||||
|
||||
|
||||
@@ -115,7 +115,7 @@ namespace OpenVulkano
|
||||
bool ArchiveReader::Open(const std::vector<std::string>& archiveFiles)
|
||||
{
|
||||
if (archiveFiles.empty()) return false;
|
||||
const ArchiveConfiguration ac = ArchiveConfiguration::FromFileName(archiveFiles.front().c_str());
|
||||
const ArchiveConfiguration ac = ArchiveConfiguration::FromFileName(archiveFiles.front().c_str()); //TODO
|
||||
if (ac.type == ArchiveType::TAR) // TODO handle all archive types correctly
|
||||
{ // Queue based approach for all archive types that do not natively support split archives
|
||||
for(const std::string& file : archiveFiles)
|
||||
|
||||
@@ -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