Support symlinks; allow requiring core before love.run()
This commit is contained in:
parent
74b2f1970f
commit
857e9dc8c5
28
main.lua
28
main.lua
|
@ -149,6 +149,8 @@ function system.list_dir(path)
|
||||||
local info = love.filesystem.getInfo(path)
|
local info = love.filesystem.getInfo(path)
|
||||||
if info and info.type == 'directory' then
|
if info and info.type == 'directory' then
|
||||||
return love.filesystem.getDirectoryItems(path)
|
return love.filesystem.getDirectoryItems(path)
|
||||||
|
elseif info and info.type == 'symlink' then
|
||||||
|
return love.filesystem.getDirectoryItems(path .. "/.")
|
||||||
end
|
end
|
||||||
return nil, "Not a directory"
|
return nil, "Not a directory"
|
||||||
end
|
end
|
||||||
|
@ -165,6 +167,12 @@ function system.get_file_info(path)
|
||||||
type = 'file'
|
type = 'file'
|
||||||
elseif info.type == 'directory' then
|
elseif info.type == 'directory' then
|
||||||
type = 'dir'
|
type = 'dir'
|
||||||
|
elseif info.type == 'symlink' then
|
||||||
|
if love.filesystem.read(path, 1) then
|
||||||
|
type = 'file'
|
||||||
|
else
|
||||||
|
type = 'dir'
|
||||||
|
end
|
||||||
end
|
end
|
||||||
return {
|
return {
|
||||||
modified = info.modtime,
|
modified = info.modtime,
|
||||||
|
@ -222,17 +230,17 @@ function system.fuzzy_match(str, ptn)
|
||||||
end
|
end
|
||||||
table.unpack = unpack
|
table.unpack = unpack
|
||||||
|
|
||||||
core = ""
|
ARGS = love.arg.parseGameArguments(arg)
|
||||||
|
VERSION = "1.11"
|
||||||
|
PLATFORM = "love2d"
|
||||||
|
SCALE = love.graphics.getDPIScale()
|
||||||
|
EXEDIR = ""
|
||||||
|
PATHSEP = package.config:sub(1, 1)
|
||||||
|
-- love.filesystem.mount(love.filesystem.getSourceBaseDirectory(), love.filesystem.getSourceBaseDirectory())
|
||||||
|
package.path = love.filesystem.getWorkingDirectory() .. '/data/?.lua;' .. love.filesystem.getWorkingDirectory() .. '/data/?/init.lua;' .. package.path
|
||||||
|
|
||||||
function love.run()
|
function love.run()
|
||||||
ARGS = love.arg.parseGameArguments(arg)
|
local core = require('core')
|
||||||
VERSION = "1.11"
|
|
||||||
PLATFORM = "love2d"
|
|
||||||
SCALE = love.graphics.getDPIScale()
|
|
||||||
EXEDIR = ""
|
|
||||||
PATHSEP = package.config:sub(1, 1)
|
|
||||||
love.filesystem.mount(love.filesystem.getSourceBaseDirectory(), love.filesystem.getSourceBaseDirectory())
|
|
||||||
package.path = love.filesystem.getWorkingDirectory() .. '/data/?.lua;' .. love.filesystem.getWorkingDirectory() .. '/data/?/init.lua;' .. package.path
|
|
||||||
core = require('core')
|
|
||||||
local style = require('core.style')
|
local style = require('core.style')
|
||||||
style.code_font = renderer.font.load(EXEDIR .. "/data/fonts/monospace.ttf", 15 * SCALE)
|
style.code_font = renderer.font.load(EXEDIR .. "/data/fonts/monospace.ttf", 15 * SCALE)
|
||||||
core.init()
|
core.init()
|
||||||
|
|
Loading…
Reference in a new issue