openOS command line programs
This commit is contained in:
@@ -1,6 +1,10 @@
|
||||
local fs = _G.fs
|
||||
|
||||
local function get(path)
|
||||
while not fs.exists(path) do
|
||||
path = fs.getDir(path)
|
||||
end
|
||||
|
||||
local label = fs.getDrive(path)
|
||||
|
||||
if label then
|
||||
@@ -35,25 +39,32 @@ local function mounts()
|
||||
end
|
||||
|
||||
local function list(path)
|
||||
local set = fs.list(path)
|
||||
return function()
|
||||
local key, value = next(set)
|
||||
set[key or false] = nil
|
||||
return value
|
||||
local success, set = pcall(fs.list, path)
|
||||
if success then
|
||||
return function()
|
||||
local key, value = next(set)
|
||||
set[key or false] = nil
|
||||
return value
|
||||
end
|
||||
end
|
||||
return success, set
|
||||
end
|
||||
|
||||
return {
|
||||
canonical = function(...) return ... end,
|
||||
concat = fs.combine,
|
||||
copy = function(...) fs.copy(...) return true end,
|
||||
exists = fs.exists,
|
||||
get = get,
|
||||
isDirectory = fs.isDir,
|
||||
isLink = function() return false end,
|
||||
link = function(s, t) return fs.mount(t, 'linkfs', s) end,
|
||||
list = list,
|
||||
makeDirectory = fs.makeDir,
|
||||
mounts = mounts,
|
||||
name = fs.getName,
|
||||
open = function(n, m) return fs.open(n, m or 'r') end,
|
||||
realPath = function(...) return ... end,
|
||||
remove = function(a) fs.delete(a) return true end,
|
||||
size = fs.getSize,
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user