Silence warnings and fix bugs

This commit is contained in:
Georg Hagen
2025-02-12 13:21:30 +01:00
parent c2b8dcb408
commit 4da64d2d42
7 changed files with 28 additions and 15 deletions

View File

@@ -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))
{

View File

@@ -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;

View File

@@ -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)

View File

@@ -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());
}

View File

@@ -46,6 +46,17 @@ namespace OpenVulkano
};
}
static FileDescription MkFile(const std::filesystem::path& path, const size_t size)
{
return {
std::filesystem::file_type::regular,
path.string(),
size,
std::filesystem::perms::owner_write | ALL_READ,
std::time(nullptr), std::time(nullptr)
};
}
static FileDescription MkDir(const char* path)
{
FileDescription desc = MkFile(path, 0);

View File

@@ -55,7 +55,7 @@ namespace OpenVulkano
[[nodiscard]] std::filesystem::path GetXDGFolderDefault(const char* envName, std::string_view defaultRelativePath)
{
#ifndef TARGET_OS_IOS != 1
#if TARGET_OS_IOS != 1
if (const char* envValue = std::getenv(envName))
{
if (envValue[0] == '/') return envValue;

View File

@@ -15,8 +15,9 @@
namespace OpenVulkano::Scene
{
struct GlyphInfo
class GlyphInfo
{
public:
//GlyphGeometry geometry;
//GlyphBox glyphBox;
Math::Vector2f_SIMD pos[4] = {};