Merge branch 'master' into using_std_fs_path
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());
|
||||
}
|
||||
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -15,8 +15,9 @@
|
||||
|
||||
namespace OpenVulkano::Scene
|
||||
{
|
||||
struct GlyphInfo
|
||||
class GlyphInfo
|
||||
{
|
||||
public:
|
||||
//GlyphGeometry geometry;
|
||||
//GlyphBox glyphBox;
|
||||
Math::Vector2f_SIMD pos[4] = {};
|
||||
|
||||
Reference in New Issue
Block a user