add standard lua os methods, another fix for vfs links within links, allow write on urlfs mounted files

This commit is contained in:
kepler155c@gmail.com
2020-05-17 19:36:33 -06:00
parent c7c594d6c3
commit a7e3318226
7 changed files with 64 additions and 39 deletions

View File

@@ -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,

View File

@@ -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()

View File

@@ -89,6 +89,7 @@ return function(env)
os = os,
string = string,
table = table,
debug = debug,
},
loaders = {
preloadSearcher,