Thanks to physfs and nativefs.lua
nativefs still introduces some inconsistencies with love.filesystem with relative paths:
love.fs.read: reads from save dir if it exists, falls back to source dir if not
nativefs.read: reads from save dir if it exists, falls back to source dir if not ✓
love.fs.write: always writes to save dir
nativefs.write: always writes to source dir (since no restrictions)
love.fs.newFile followed by file:open('r'): reads from save dir if it exists, source dir if not
nativefs.newFile followed by file:open('r'): always reads from working dir
love.fs.newFile followed by file:open('w'): always writes to save dir
nativefs.newFile followed by file:open('w'): always writes to working dir
So avoid using relative paths with App primitives.
D6DV2L5CX6YGDXHI3SQKYEOBNTKUOBB6M5OJTPSECRQJHRIAGSYAC
WOQELCJJ7FPYJEKT57NJ3FJARPNWMHLITDTCUICFYU4YWXDSASYQC
KKMFQDR43ZWVCDRHQLWWX3FCWCFA3ZSXYOBRJNPHUQZR2XPKWULAC
N2NUGNN4E37TNLC6JZE4H4HKJZPNVBV4VYTLXW57AP5BOU4ZK7LQC
AD34IX2ZSGYGU3LGY2IZOZNKD4HRQOYJVG5UWMWLXJZJSM62FFOAC
2CK5QI7WA7M4IVSACFGOJYAIDKRUTZVMMPSFWEJTUNMWTN7AX4NAC
3QNOKBFMKBGXBVJIRHR2444JRRMBTABHE4674NR3DT67RRM2X6GAC
AIMA4HLDQ6GI74ESXMOJJ5UVHKZWPNED26G6SXX76G6ORQLYS5PAC
ORRSP7FVCHI2TF5GXBRGQYYJAA3JFYXZBM3T663BKSBV22FCZVCAC
AVTNUQYRBW7IX2YQ3KDLVQ23RGW3BAKTAE7P73ASBYNKOHMQMH5AC
R3KXFRZNL4CAT5OSKIIGWR3CHL2YJ5S4TKQDIPEHIJ2HW2WS46BQC
HKV72RZVJEOF5GCHCRKEBGC3FQN7AYETY7LKEJUXVIQAB4QPEPYQC
* `love.filesystem.getDirectoryItems(dir)` -- returns an unsorted array of the
files and directories available under `dir`. `dir` must be relative to
[LÖVE's save directory](https://love2d.org/wiki/love.filesystem.getSaveDirectory).
There is no easy, portable way in Lua/LÖVE to list directories outside the
save dir.
* `App.files(dir)` -- returns an unsorted array of the files and directories
available under `dir`.
if Current_app == nil or Current_app == 'run' then
return {
write = function(self, ...)
local args = {...}
for i,s in ipairs(args) do
App.filesystem[filename] = App.filesystem[filename]..s
end
end,
close = function(self)
end,
}
elseif Current_app == 'source' then
return {
write = function(self, s)
App.filesystem[filename] = App.filesystem[filename]..s
end,
close = function(self)
end,
}
end
return {
write = function(self, s)
App.filesystem[filename] = App.filesystem[filename]..s
end,
close = function(self)
end,
}
if Current_app == nil or Current_app == 'run' then
App.open_for_reading = function(filename) return io.open(filename, 'r') end
App.open_for_writing = function(filename) return io.open(filename, 'w') end
elseif Current_app == 'source' then
-- HACK: source editor requires a couple of different foundational definitions
App.open_for_reading =
function(filename)
local result = love.filesystem.newFile(filename)
local ok, err = result:open('r')
if ok then
return result
else
return ok, err
end
App.open_for_reading =
function(filename)
local result = nativefs.newFile(filename)
local ok, err = result:open('r')
if ok then
return result
else
return ok, err
App.open_for_writing =
function(filename)
local result = love.filesystem.newFile(filename)
local ok, err = result:open('w')
if ok then
return result
else
return ok, err
end
end
App.open_for_writing =
function(filename)
local result = nativefs.newFile(filename)
local ok, err = result:open('w')
if ok then
return result
else
return ok, err