v1.6.0 - Removed low level libraries computer and component. They must now be imported.
This commit is contained in:
+1
-1
@@ -19,7 +19,7 @@ if not fs.exists(fromFile) then
|
||||
print("\27[91mSource file does not exist.")
|
||||
return
|
||||
end
|
||||
if fs.exists(toFile) and not (table.find(args, "-o") or table.find(args, "--overwrite")) then
|
||||
if fs.exists(toFile) and not (table.find({...}, "-o") or table.find({...}, "--overwrite")) then
|
||||
print("\27[91mDestination file already exists. Run this command again with -o to overwrite it.")
|
||||
return
|
||||
end
|
||||
|
||||
@@ -1,3 +1,6 @@
|
||||
local component = import("component")
|
||||
local computer = import("computer")
|
||||
|
||||
local function printstat(text)
|
||||
termlib.cursorPosX = 35
|
||||
print(text, true, false)
|
||||
|
||||
+1
-1
@@ -17,7 +17,7 @@ end
|
||||
if not fs.exists(fromFile) then
|
||||
print("\27[91mSource file does not exist.")
|
||||
end
|
||||
if fs.exists(toFile) and not (table.find(args, "-o") or table.find(args, "--overwrite")) then
|
||||
if fs.exists(toFile) and not (table.find({...}, "-o") or table.find({...}, "--overwrite")) then
|
||||
print("\27[91mDestination file already exists. Run this command again with -o to overwrite it.")
|
||||
return
|
||||
end
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
/halyde/core/datatools.lua
|
||||
/halyde/core/fullkb.lua
|
||||
/halyde/core/evmgr.lua
|
||||
/halyde/core/shell.lua
|
||||
|
||||
+22
-4
@@ -1,7 +1,7 @@
|
||||
local loadfile = ...
|
||||
local filesystem = loadfile("/halyde/lib/filesystem.lua")(loadfile)
|
||||
|
||||
_G._OSVERSION = "Halyde 1.5.0"
|
||||
_G._OSVERSION = "Halyde 1.6.0"
|
||||
_G._OSLOGO = ""
|
||||
local handle, tmpdata = filesystem.open("/halyde/config/oslogo.ans", "r"), nil
|
||||
repeat
|
||||
@@ -40,8 +40,15 @@ gpu.bind(screenAddress)
|
||||
--gpu.setResolution(targetWidth, targetHeight)
|
||||
gpu.setResolution(gpu.maxResolution())
|
||||
|
||||
_G.package = {["preloaded"] = {}}
|
||||
|
||||
loadfile("/halyde/core/datatools.lua")()
|
||||
|
||||
function _G.import(module, ...)
|
||||
local args = table.pack(...)
|
||||
if package.preloaded[module] then
|
||||
return package.preloaded[module]
|
||||
end
|
||||
local modulepath
|
||||
if module:find("^/") then
|
||||
if filesystem.exists(module) then
|
||||
@@ -53,9 +60,7 @@ function _G.import(module, ...)
|
||||
modulepath = shell.workingDirectory..module
|
||||
end
|
||||
assert(modulepath, "module not found\npossible locations:\n/halyde/lib/"..module..".lua")
|
||||
local handle = filesystem.open(modulepath)
|
||||
local data = ""
|
||||
local tmpdata = ""
|
||||
local handle, data, tmpdata = filesystem.open(modulepath), "", nil
|
||||
repeat
|
||||
tmpdata = handle:read(math.huge or math.maxinteger)
|
||||
data = data .. (tmpdata or "")
|
||||
@@ -63,6 +68,19 @@ function _G.import(module, ...)
|
||||
return(assert(load(data, "="..modulepath))(table.unpack(args)))
|
||||
end
|
||||
|
||||
local function preload(module)
|
||||
local handle, data, tmpdata = assert(filesystem.open("/halyde/lib/" .. module .. ".lua", "r")), "", nil
|
||||
repeat
|
||||
tmpdata = handle:read(math.huge or math.maxinteger)
|
||||
data = data .. (tmpdata or "")
|
||||
until not tmpdata
|
||||
package.preloaded[module] = assert(load(data, "="..module))()
|
||||
_G[module] = nil
|
||||
end
|
||||
|
||||
preload("component")
|
||||
preload("computer")
|
||||
|
||||
--local handle = assert(filesystem.open("/bazinga.txt", "w"))
|
||||
--assert(handle:write("Bazinga!"))
|
||||
--handle:close()
|
||||
|
||||
@@ -3,6 +3,7 @@ _G.cormgr.corList = {}
|
||||
|
||||
--local ocelot = component.proxy(component.list("ocelot")())
|
||||
|
||||
local component = import("component")
|
||||
local filesystem = import("filesystem")
|
||||
local gpu = component.proxy(component.list("gpu")())
|
||||
|
||||
|
||||
@@ -2,6 +2,8 @@ _G.evmgr = {}
|
||||
_G.evmgr.eventQueue = {}
|
||||
local maxEventQueueLength = 10 -- increase if events start getting dropped
|
||||
|
||||
local computer = import("computer")
|
||||
|
||||
keyboard.ctrlDown = false
|
||||
keyboard.altDown = false
|
||||
|
||||
|
||||
@@ -2,6 +2,7 @@ local shellcfg = import("/halyde/config/shell.cfg")
|
||||
import("/halyde/core/termlib.lua")
|
||||
local event = import("event")
|
||||
local filesystem = import("filesystem")
|
||||
local component = import("component")
|
||||
local gpu = component.proxy(component.list("gpu")())
|
||||
|
||||
_G.shell = {}
|
||||
|
||||
@@ -2,6 +2,7 @@ local event = import("event")
|
||||
--local keyboard = import("keyboard")
|
||||
|
||||
--local ocelot = component.proxy(component.list("ocelot")())
|
||||
local component = import("component")
|
||||
local gpu = component.proxy(component.list("gpu")()) -- replace with component.gpu once implemented
|
||||
_G.termlib = {}
|
||||
termlib.cursorPosX = 1
|
||||
|
||||
@@ -19,4 +19,4 @@ end
|
||||
|
||||
componentlib.invoke = component.invoke
|
||||
|
||||
return(componentlib)
|
||||
return componentlib
|
||||
|
||||
@@ -0,0 +1,14 @@
|
||||
local computerlib = table.copy(computer)
|
||||
local LLcomputer = table.copy(computer)
|
||||
|
||||
function computerlib.pullSignal(timeout)
|
||||
local startTime = LLcomputer.uptime()
|
||||
local result
|
||||
repeat
|
||||
result = {LLcomputer.pullSignal(0)}
|
||||
coroutine.yield()
|
||||
until result or timeout and LLcomputer.uptime() >= startTime + timeout
|
||||
return table.unpack(result)
|
||||
end
|
||||
|
||||
return computerlib
|
||||
@@ -1,3 +1,4 @@
|
||||
local computer = import("computer")
|
||||
local event = {}
|
||||
|
||||
--local ocelot = component.proxy(component.list("ocelot")())
|
||||
@@ -50,4 +51,4 @@ function event.pull(...)
|
||||
until false -- Loop until we find an event or timeout
|
||||
end
|
||||
|
||||
return event
|
||||
return event
|
||||
|
||||
@@ -1,10 +1,12 @@
|
||||
local loadfile = ... -- raw loadfile from boot.lua
|
||||
local component
|
||||
local component, computer
|
||||
|
||||
if loadfile then
|
||||
component = loadfile("/halyde/lib/component.lua")(loadfile)
|
||||
computer = _G.computer
|
||||
elseif import then
|
||||
component = import("component")
|
||||
computer = import("computer")
|
||||
end
|
||||
|
||||
local filesystem = {}
|
||||
@@ -127,15 +129,6 @@ function filesystem.size(path)
|
||||
return component.invoke(address, "size", absPath)
|
||||
end
|
||||
|
||||
function filesystem.isDirectory(path)
|
||||
checkArg(1, path, "string")
|
||||
local address, absPath = filesystem.absolutePath(path)
|
||||
if not address then
|
||||
return false
|
||||
end
|
||||
return component.invoke(address, "isDirectory", absPath)
|
||||
end
|
||||
|
||||
function filesystem.rename(fromPath, toPath)
|
||||
checkArg(1, fromPath, "string")
|
||||
checkArg(2, toPath, "string")
|
||||
|
||||
Reference in New Issue
Block a user