mirror of
https://git.shadowkat.net/izaya/OC-PsychOS2.git
synced 2024-11-16 09:31:35 -05:00
document new functions, remove dprints
This commit is contained in:
parent
69eae00ec1
commit
23680afd75
@ -15,11 +15,8 @@ function fs.resolve(path) -- resolves *path* to a specific filesystem mount and
|
|||||||
if path:sub(1,1) ~= "/" then path=(os.getenv("PWD") or "").."/"..path end
|
if path:sub(1,1) ~= "/" then path=(os.getenv("PWD") or "").."/"..path end
|
||||||
local segments, rpath, rfs= fs.segments(path)
|
local segments, rpath, rfs= fs.segments(path)
|
||||||
local rc = #segments
|
local rc = #segments
|
||||||
dprint(rc)
|
|
||||||
for i = #segments, 1, -1 do
|
for i = #segments, 1, -1 do
|
||||||
dprint("testing "..table.concat(segments, "/", 1, i),tostring(fsmounts[table.concat(segments, "/", 1, i)]))
|
|
||||||
if fsmounts[table.concat(segments, "/", 1, i)] ~= nil then
|
if fsmounts[table.concat(segments, "/", 1, i)] ~= nil then
|
||||||
dprint("ret",table.concat(segments, "/", 1, i), table.concat(segments, "/", i+1))
|
|
||||||
return table.concat(segments, "/", 1, i), table.concat(segments, "/", i+1)
|
return table.concat(segments, "/", 1, i), table.concat(segments, "/", i+1)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -99,7 +96,7 @@ function fs.rename(from,to) -- moves file *from* to *to*
|
|||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
|
|
||||||
function fs.mount(path,proxy)
|
function fs.mount(path,proxy) -- mounts the filesystem *proxy* to the mount point *path* if it is a directory. BYO proxy.
|
||||||
if fs.isDirectory(path) then
|
if fs.isDirectory(path) then
|
||||||
fsmounts[table.concat(fs.segments(path),"/")] = proxy
|
fsmounts[table.concat(fs.segments(path),"/")] = proxy
|
||||||
return true
|
return true
|
||||||
@ -107,7 +104,7 @@ function fs.mount(path,proxy)
|
|||||||
return false, "path is not a directory"
|
return false, "path is not a directory"
|
||||||
end
|
end
|
||||||
|
|
||||||
function fs.mounts()
|
function fs.mounts() -- returns a table containing the mount points of all mounted filesystems
|
||||||
local rt = {}
|
local rt = {}
|
||||||
for k,v in pairs(fsmounts) do
|
for k,v in pairs(fsmounts) do
|
||||||
rt[#rt+1] = k,v.address or "unknown"
|
rt[#rt+1] = k,v.address or "unknown"
|
||||||
@ -115,11 +112,11 @@ function fs.mounts()
|
|||||||
return rt
|
return rt
|
||||||
end
|
end
|
||||||
|
|
||||||
function fs.address(path)
|
function fs.address(path) -- returns the address of the filesystem at a given path, if applicable
|
||||||
local fsi,_ = fs.resolve(path)
|
local fsi,_ = fs.resolve(path)
|
||||||
return fsmounts[fsi].address
|
return fsmounts[fsi].address
|
||||||
end
|
end
|
||||||
function fs.type(path)
|
function fs.type(path) -- returns the component type of the filesystem at a given path, if applicable
|
||||||
local fsi,_ = fs.resolve(path)
|
local fsi,_ = fs.resolve(path)
|
||||||
return fsmounts[fsi].type
|
return fsmounts[fsi].type
|
||||||
end
|
end
|
||||||
|
Loading…
Reference in New Issue
Block a user