From 79abe3b1d60295e179ab6766310714d2ec5ed00b Mon Sep 17 00:00:00 2001 From: bjorn Date: Tue, 21 Nov 2023 20:19:49 -0800 Subject: [PATCH] Windows fixes; --- src/core/fs.c | 16 ++++++++++++++++ src/modules/filesystem/filesystem.c | 6 +++--- 2 files changed, 19 insertions(+), 3 deletions(-) diff --git a/src/core/fs.c b/src/core/fs.c index 90f8fb577..9360c1368 100644 --- a/src/core/fs.c +++ b/src/core/fs.c @@ -53,6 +53,22 @@ bool fs_write(fs_handle file, const void* buffer, size_t* bytes) { return success; } +bool fs_seek(fs_handle file, uint64_t offset) { + LARGE_INTEGER n = { .QuadPart = offset }; + return SetFilePointerEx(file.handle, n, NULL, FILE_BEGIN); +} + +bool fs_fstat(fs_handle file, FileInfo* info) { + LARGE_INTEGER size; + if (!GetFileSizeEx(file.handle, &size)) { + return false; + } + info->size = size.QuadPart; + info->lastModified = 0; + info->type = FILE_REGULAR; + return true; +} + void* fs_map(const char* path, size_t* size) { WCHAR wpath[FS_PATH_MAX]; if (!MultiByteToWideChar(CP_UTF8, 0, path, -1, wpath, FS_PATH_MAX)) { diff --git a/src/modules/filesystem/filesystem.c b/src/modules/filesystem/filesystem.c index 736ff6752..084432cf3 100644 --- a/src/modules/filesystem/filesystem.c +++ b/src/modules/filesystem/filesystem.c @@ -642,7 +642,7 @@ static bool zip_init(Archive* archive, const char* filename, const char* root) { node.mdate = readu16(p + 14); node.compressed = readu16(p + 10) == 8; node.directory = false; - uint16_t length = readu16(p + 28); + size_t length = readu16(p + 28); const char* path = (const char*) (p + 46); cursor += 46 + readu16(p + 28) + readu16(p + 30) + readu16(p + 32); @@ -705,13 +705,13 @@ static bool zip_init(Archive* archive, const char* filename, const char* root) { break; } - uint16_t end = length; + size_t end = length; while (length && path[length - 1] != '/') { length--; } archive->nodes.data[index].filename = path + length; - archive->nodes.data[index].filenameLength = end - length; + archive->nodes.data[index].filenameLength = (uint16_t) (end - length); // Root node if (length == 0) {