sonoro1234 / luafilesystem

Reimplement luafilesystem via LuaJIT FFI with unicode facilities
MIT License
24 stars 6 forks source link

[Fix for Winx64] Change windows find handle type to intptr_t #3

Closed barrybingo closed 4 years ago

barrybingo commented 4 years ago

Spacewander's repo has removed windows support so this seems to be the repo for all machines.

note that intptr_t on 32 bit machines is int so that code is unaffected

sonoro1234 commented 4 years ago

yes, the declarations in https://docs.microsoft.com/es-es/cpp/c-runtime-library/reference/findfirst-functions?view=vs-2019 use intptr_t (8bytes on 64 bits and 4 bytes on 32bits)

What I dont understand is why int was working correctly for me on 32 and 64bits

barrybingo commented 4 years ago

byte luck? I'm using luaJit 2.1.0-beta3 x64 and it never once worked for me in but I've only been using this module since today.

Doing a directory list the findfirst works but then luaJIT silently terminates. Running in VS2019 debugger caught an exception in findnext so that's where the problem was, which isn't supprising considering.

I can't see how it ever worked for you, but I don't know the history of that API so it might have changed somewhere.

sonoro1234 commented 4 years ago

Thanks!!

barrybingo commented 4 years ago

np

Though I've had a thought; you used a struct to house the 32bit int

local dir_type = ffi.metatype("struct {int handle;}", 

and if this struct was padded then the code would work fine. Maybe some compiler option gave it extra size.