Skip to content

Commit

Permalink
Windows fixes;
Browse files Browse the repository at this point in the history
  • Loading branch information
bjornbytes committed Nov 22, 2023
1 parent a8d44b2 commit 79abe3b
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 3 deletions.
16 changes: 16 additions & 0 deletions src/core/fs.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)) {
Expand Down
6 changes: 3 additions & 3 deletions src/modules/filesystem/filesystem.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down Expand Up @@ -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) {
Expand Down

0 comments on commit 79abe3b

Please sign in to comment.