Support symlinks; allow requiring core before love.run()

This commit is contained in:
Jeremy Penner 2020-09-16 22:00:17 -04:00
parent 74b2f1970f
commit 857e9dc8c5

View file

@ -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 = ""
function love.run()
ARGS = love.arg.parseGameArguments(arg) ARGS = love.arg.parseGameArguments(arg)
VERSION = "1.11" VERSION = "1.11"
PLATFORM = "love2d" PLATFORM = "love2d"
SCALE = love.graphics.getDPIScale() SCALE = love.graphics.getDPIScale()
EXEDIR = "" EXEDIR = ""
PATHSEP = package.config:sub(1, 1) PATHSEP = package.config:sub(1, 1)
love.filesystem.mount(love.filesystem.getSourceBaseDirectory(), love.filesystem.getSourceBaseDirectory()) -- love.filesystem.mount(love.filesystem.getSourceBaseDirectory(), love.filesystem.getSourceBaseDirectory())
package.path = love.filesystem.getWorkingDirectory() .. '/data/?.lua;' .. love.filesystem.getWorkingDirectory() .. '/data/?/init.lua;' .. package.path package.path = love.filesystem.getWorkingDirectory() .. '/data/?.lua;' .. love.filesystem.getWorkingDirectory() .. '/data/?/init.lua;' .. package.path
core = require('core')
function love.run()
local 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()