mirror of
https://github.com/EngineerSmith/nativefs.git
synced 2025-11-08 23:15:02 +00:00
fix crash on Windows
This commit is contained in:
@@ -20,7 +20,7 @@ ffi.cdef([[
|
|||||||
]])
|
]])
|
||||||
|
|
||||||
local C = ffi.C
|
local C = ffi.C
|
||||||
local loveC = ffi.os == 'Windows' and pcall(ffi.load, 'love') or C
|
local loveC = ffi.os == 'Windows' and ffi.load('love') or C
|
||||||
local fopen, getcwd, chdir, unlink, mkdir, rmdir, BUFFERMODE
|
local fopen, getcwd, chdir, unlink, mkdir, rmdir, BUFFERMODE
|
||||||
|
|
||||||
if ffi.os == 'Windows' then
|
if ffi.os == 'Windows' then
|
||||||
@@ -37,7 +37,7 @@ if ffi.os == 'Windows' then
|
|||||||
int _wrmdir(const wchar_t* path);
|
int _wrmdir(const wchar_t* path);
|
||||||
]])
|
]])
|
||||||
|
|
||||||
BUFFERMODE = { full = 0, line = 64, none = 2 }
|
BUFFERMODE = { full = 0, line = 64, none = 4 }
|
||||||
|
|
||||||
local function towidestring(str)
|
local function towidestring(str)
|
||||||
local size = C.MultiByteToWideChar(65001, 0, str, #str, nil, 0)
|
local size = C.MultiByteToWideChar(65001, 0, str, #str, nil, 0)
|
||||||
@@ -115,6 +115,7 @@ function File:open(mode)
|
|||||||
local handle = fopen(self._name, MODEMAP[mode])
|
local handle = fopen(self._name, MODEMAP[mode])
|
||||||
if handle == nil then return false, "Could not open " .. self._name .. " in mode " .. mode end
|
if handle == nil then return false, "Could not open " .. self._name .. " in mode " .. mode end
|
||||||
|
|
||||||
|
print(self._bufferMode, BUFFERMODE[self._bufferMode], self._bufferSize)
|
||||||
if C.setvbuf(handle, nil, BUFFERMODE[self._bufferMode], self._bufferSize) ~= 0 then
|
if C.setvbuf(handle, nil, BUFFERMODE[self._bufferMode], self._bufferSize) ~= 0 then
|
||||||
self._bufferMode, self._bufferSize = 'none', 0
|
self._bufferMode, self._bufferSize = 'none', 0
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user