Skip to content

Commit d0aa922

Browse files
committed
make fs at least load on non luajit versions
1 parent 8d1196f commit d0aa922

File tree

2 files changed

+13
-5
lines changed

2 files changed

+13
-5
lines changed

nattlua/other/fs.lua

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
local fs = {}
2-
local ffi = require("ffi")
32

4-
if ffi.arch ~= "Windows" then
3+
if not jit then
4+
elseif jit.arch ~= "Windows" then
5+
local ffi = require("ffi")
56
ffi.cdef("char *strerror(int);")
67

78
function fs.last_error()
@@ -10,6 +11,8 @@ if ffi.arch ~= "Windows" then
1011
return err == "" and tostring(num) or err
1112
end
1213
else
14+
local ffi = require("ffi")
15+
1316
ffi.cdef("uint32_t GetLastError();")
1417
ffi.cdef[[
1518
uint32_t FormatMessageA(
@@ -38,7 +41,10 @@ else
3841
end
3942
end
4043

41-
if ffi.arch ~= "Windows" then
44+
if not jit then
45+
elseif jit.arch ~= "Windows" then
46+
local ffi = require("ffi")
47+
4248
do -- attributes
4349
local stat_struct
4450

@@ -353,6 +359,8 @@ if ffi.arch ~= "Windows" then
353359
end
354360
end
355361
else
362+
local ffi = require("ffi")
363+
356364
local DIRECTORY = 0x10
357365
local time_struct = ffi.typeof([[
358366
struct {
@@ -459,7 +467,7 @@ else
459467

460468
local ffi_cast = ffi.cast
461469
local ffi_string = ffi.string
462-
local INVALID_FILE = ffi.cast("void *", 0xffffffffffffffffULL)
470+
local INVALID_FILE = ffi.cast("void *", -1)
463471
local data_box = ffi.typeof("$[1]", find_data_struct)
464472
local data = data_box()
465473

nattlua/other/path.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ end
7272

7373
local ok, fs = pcall(require, "nattlua.other.fs")
7474

75-
if ok then exists = function(path)
75+
if ok and fs.get_type then exists = function(path)
7676
return fs.get_type(path) == "file"
7777
end end
7878

0 commit comments

Comments
 (0)