Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local ending = "_f"
- local orfa = {} --original fake mapping
- local faor = {}
- local used = false
- for i,j in pairs(fs.list("/")) do
- local k = string.match(j,"(.*)"..ending.."$")
- while k do
- orfa[k..ending] = k
- faor[k] = k..ending
- used = true
- k=string.match(k,"(.*)"..ending.."$")
- end
- end
- local args = {...}
- if #args % 2 == 1 or (not used and #args == 0) then
- print(shell.getRunningProgram().." <actualFile> <displayName> [<actualFile>] <displayName> ...")
- return
- end
- for i=1,#args,2 do
- faor[args[i+1]] = args[i]
- orfa[args[i]] = args[i+1]
- end
- local ofs = {combine=true,getDrive=true,getDir=true,getName=true}
- local nfs = {}
- for i,j in pairs(fs) do
- if not ofs[i] then
- nfs[i] = j
- end
- end
- for i in pairs(nfs) do
- fs[i] = nil
- end
- local mt ={__index = function(t,k)
- if not nfs[k] then
- return
- end
- return function(...)
- local pars = {...}
- for i,file in ipairs(pars) do
- if orfa[file] then
- faor[file] = file..ending
- orfa[file..ending] = file
- end
- if faor[file] then
- pars[i] = faor[file]
- end
- end
- local r = nfs[k](unpack(pars))
- if k == "list" or k == "find" then
- local n = {}
- for i,file in ipairs(r) do
- if orfa[file] then
- table.insert(n,orfa[file])
- elseif not faor[file] then
- table.insert(n,file)
- end
- end
- r=n
- end
- return r
- end
- end,__metatable="nil"}
- setmetatable(fs,mt)
Advertisement
Add Comment
Please, Sign In to add comment