You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
But I run into problems while comparing in my conditions because of some type mismatches.
Problem 1: Can't check for invalid file handle
constW=std.unicode.utf8ToUtf16LeStringLiteral;
constwin=@import("win32/win32.zig");
constfs=win.storage.file_system;
pubconstUNICODE: bool=true;
varffd: fs.WIN32_FIND_DATAW=undefined;
// I also had to set the type manually to a better fitting "FindFileHandle" instead of the automatically recommended "isize"constfileHandle: fs.FindFileHandle=fs.FindFirstFileW(W("C:/*"), &ffd);
if (fileHandle==win.foundation.INVALID_HANDLE_VALUE) {
std.debug.print("Could not open directory", .{});
}
Error:
src\main.zig:19:20: error: incompatible types: 'isize' and '*anyopaque'
if (fileHandle == win.foundation.INVALID_HANDLE_VALUE) {
Problem 2: Can't check for flags with bitwise AND &
varlargeInt: win.foundation.LARGE_INTEGER=undefined;
while (true) {
// u32 & FILE_FLAGS_AND_ATTRIBUTES{ .FILE_ATTRIBUTE_DIRECTORY = 1 };if (ffd.dwFileAttributes & fs.FILE_ATTRIBUTE_DIRECTORY) {
std.debug.print("[D] {s}", ffd.cFileName);
} else {
largeInt.u.LowPart=ffd.nFileSizeLow;
largeInt.u.HighPart=ffd.nFileSizeHigh;
std.debug.print("[F] {s} {i} bytes", ffd.cFileName, largeInt.QuadPart);
}
// Also: Why is there no do while loop in Zig?!fs.FindNextFileW(fileHandle, &ffd);
}
Error:
src\main.zig:24:38: error: incompatible types: 'u32' and 'win32.win32.storage.file_system.FILE_FLAGS_AND_ATTRIBUTES'
if (ffd.dwFileAttributes & fs.FILE_ATTRIBUTE_DIRECTORY) {
Problem 3: FindNextFileW does use another handle type than FindFirstFileW returns
FindFirstFileW returns a FindFileHandle but FindNextFileW needs a generic HANDLE?
Error:
src\main.zig:31:30: error: expected type '?*anyopaque', found 'isize'
fs.FindNextFileW(fileHandle, &ffd);
^~~~~~~~~~
src\win32\win32\storage\file_system.zig:5504:16: note: parameter type declared here
hFindFile: ?HANDLE,
The text was updated successfully, but these errors were encountered:
I am currently trying to transfer this MS WinAPI Example to Zig:
https://learn.microsoft.com/en-us/windows/win32/fileio/listing-the-files-in-a-directory
But I run into problems while comparing in my conditions because of some type mismatches.
Problem 1: Can't check for invalid file handle
Error:
Problem 2: Can't check for flags with bitwise AND &
Error:
Problem 3: FindNextFileW does use another handle type than FindFirstFileW returns
FindFirstFileW returns a
FindFileHandle
but FindNextFileW needs a genericHANDLE
?Error:
The text was updated successfully, but these errors were encountered: