diff --git a/Libraries/Filesystem.lua b/Libraries/Filesystem.lua index f0e15014..1b12dd2f 100644 --- a/Libraries/Filesystem.lua +++ b/Libraries/Filesystem.lua @@ -47,12 +47,16 @@ end --------------------------------------- Mounted filesystem support ----------------------------------------- -function filesystem.mount(cyka, path) +function filesystem.mount(cyka, path) if type(cyka) == "table" then + local mountedProxy + for i = 1, #mountedProxies do - if mountedProxies[i].path == path then + mountedProxy = mountedProxies[i] + + if mountedProxy.path == path then return false, "mount path has been taken by other mounted filesystem" - elseif mountedProxies[i].proxy == cyka then + elseif mountedProxy.proxy == cyka then return false, "proxy is already mounted" end end @@ -62,6 +66,8 @@ function filesystem.mount(cyka, path) proxy = cyka }) + table.sort(mountedProxies, function(a, b) return #b.path < #a.path end) + return true else error("bad argument #1 (filesystem proxy expected, got " .. tostring(cyka) .. ")")