First commit. Not even working prototype yet.
This commit is contained in:
@@ -0,0 +1,31 @@
|
||||
local loadfile = ...
|
||||
local filesystem = loadfile("/halyde/lib/filesystem.lua")(loadfile)
|
||||
|
||||
_G._OSVERSION = "Halyde 0.1.0"
|
||||
|
||||
function _G.import(module, ...)
|
||||
local args = table.pack(...)
|
||||
local modulepath
|
||||
if module:find("^/") then
|
||||
if filesystem.exists(module) then
|
||||
modulepath = module
|
||||
end
|
||||
elseif filesystem.exists("/halyde/lib/"..module..".lua") then
|
||||
modulepath = "/halyde/lib/"..module..".lua"
|
||||
end
|
||||
assert(modulepath, "module not found\npossible locations:\n/halyde/lib/"..module..".lua")
|
||||
local handle = filesystem.open(modulepath)
|
||||
local data = ""
|
||||
local tmpdata = ""
|
||||
repeat
|
||||
tmpdata = handle:read(math.huge or math.maxinteger)
|
||||
data = data .. (tmpdata or "")
|
||||
until not tmpdata
|
||||
assert(load(data, "="..modulepath))(table.unpack(args))
|
||||
end
|
||||
|
||||
--local handle = assert(filesystem.open("/bazinga.txt", "w"))
|
||||
--assert(handle:write("Bazinga!"))
|
||||
--handle:close()
|
||||
|
||||
import("/halyde/core/cormgr.lua")
|
||||
Reference in New Issue
Block a user