add standard lua os methods, another fix for vfs links within links, allow write on urlfs mounted files
This commit is contained in:
@@ -5,7 +5,7 @@ local linkfs = { }
|
||||
-- TODO: implement broken links
|
||||
|
||||
local methods = { 'exists', 'getFreeSpace', 'getSize', 'attributes',
|
||||
'isDir', 'isReadOnly', 'list', 'listEx', 'makeDir', 'open', 'getDrive' }
|
||||
'isDir', 'isReadOnly', 'list', 'makeDir', 'open', 'getDrive' }
|
||||
|
||||
for _,m in pairs(methods) do
|
||||
linkfs[m] = function(node, dir, ...)
|
||||
@@ -18,7 +18,7 @@ function linkfs.resolve(node, dir)
|
||||
return dir:gsub(node.mountPoint, node.source, 1)
|
||||
end
|
||||
|
||||
function linkfs.mount(_, source)
|
||||
function linkfs.mount(path, source)
|
||||
if not source then
|
||||
error('Source is required')
|
||||
end
|
||||
@@ -26,6 +26,9 @@ function linkfs.mount(_, source)
|
||||
if not fs.exists(source) then
|
||||
error('Source is missing')
|
||||
end
|
||||
if path == source then
|
||||
return
|
||||
end
|
||||
if fs.isDir(source) then
|
||||
return {
|
||||
source = source,
|
||||
|
||||
@@ -5,15 +5,19 @@ local fs = _G.fs
|
||||
|
||||
local urlfs = { }
|
||||
|
||||
function urlfs.mount(_, url)
|
||||
function urlfs.mount(path, url, force)
|
||||
if not url then
|
||||
error('URL is required')
|
||||
end
|
||||
return {
|
||||
url = url,
|
||||
created = os.epoch('utc'),
|
||||
modification = os.epoch('utc'),
|
||||
}
|
||||
|
||||
-- only mount if the file does not exist already
|
||||
if not fs.exists(path) or force then
|
||||
return {
|
||||
url = url,
|
||||
created = os.epoch('utc'),
|
||||
modification = os.epoch('utc'),
|
||||
}
|
||||
end
|
||||
end
|
||||
|
||||
function urlfs.attributes(node)
|
||||
@@ -38,7 +42,7 @@ function urlfs.getSize(node)
|
||||
end
|
||||
|
||||
function urlfs.isReadOnly()
|
||||
return true
|
||||
return false
|
||||
end
|
||||
|
||||
function urlfs.isDir()
|
||||
|
||||
@@ -89,6 +89,7 @@ return function(env)
|
||||
os = os,
|
||||
string = string,
|
||||
table = table,
|
||||
debug = debug,
|
||||
},
|
||||
loaders = {
|
||||
preloadSearcher,
|
||||
|
||||
Reference in New Issue
Block a user