disambiguate zip reads from appdata reads using bogus identity
This commit is contained in:
parent
0b30988408
commit
1a4352f40b
16
main.lua
16
main.lua
@ -40,13 +40,10 @@ void update(float time);
|
|||||||
local platform = love.system.getOS()
|
local platform = love.system.getOS()
|
||||||
|
|
||||||
local lib_name
|
local lib_name
|
||||||
local love_name
|
|
||||||
if platform == "Linux" then
|
if platform == "Linux" then
|
||||||
lib_name = "test.so"
|
lib_name = "test.so"
|
||||||
love_name = "love"
|
|
||||||
elseif platform == "Windows" then
|
elseif platform == "Windows" then
|
||||||
lib_name = "test.dll"
|
lib_name = "test.dll"
|
||||||
love_name = "LOVE"
|
|
||||||
else
|
else
|
||||||
assert(false, "unsupported platform " .. platform)
|
assert(false, "unsupported platform " .. platform)
|
||||||
end
|
end
|
||||||
@ -56,14 +53,19 @@ void update(float time);
|
|||||||
local archive = love.filesystem.getSourceBaseDirectory()
|
local archive = love.filesystem.getSourceBaseDirectory()
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- there is nothing wrong with the following 5 lines from an API
|
||||||
|
-- design/usability perspective
|
||||||
|
local identity = love.filesystem.getIdentity()
|
||||||
|
local non_existing_identity = "https://github.com/love2d/love/issues/2295"
|
||||||
|
love.filesystem.setIdentity(non_existing_identity:gsub("/", "_"))
|
||||||
local contents, size = love.filesystem.read("data", lib_name)
|
local contents, size = love.filesystem.read("data", lib_name)
|
||||||
|
love.filesystem.setIdentity(identity)
|
||||||
|
|
||||||
assert(contents ~= nil, size)
|
assert(contents ~= nil, size)
|
||||||
local write_success, message = love.filesystem.write(lib_name, contents, size)
|
local write_success, message = love.filesystem.write(lib_name, contents, size)
|
||||||
assert(write_success, lib_name, message)
|
assert(write_success, lib_name, message)
|
||||||
local app_data = love.filesystem.getAppdataDirectory()
|
local lib_directory = love.filesystem.getRealDirectory(lib_name)
|
||||||
-- the love2d "filesystem" API is the worst possible design in the
|
test = ffi.load(lib_directory .. "/" .. lib_name)
|
||||||
-- entire history of computing
|
|
||||||
test = ffi.load(app_data .. "/" .. love_name .. "/love-demo2/" .. lib_name)
|
|
||||||
else
|
else
|
||||||
test = ffi.load("./" .. lib_name)
|
test = ffi.load("./" .. lib_name)
|
||||||
end
|
end
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user