Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local dfile = "/files"
- local ufile = "/users"
- local cfile = dfile.."/alak"
- local users = {
- ["alak"] = "admin";
- }
- if not fs.exists(ufile) then
- local pm = fs.open(ufile, "w")
- pm.write(textutils.serialize(users))
- pm.close()
- else
- local pm = fs.open(ufile, "r")
- users = textutils.unserialize(pm.readAll())
- pm.close()
- end
- if not fs.exists(dfile) then
- fs.makeDir(dfile)
- end
- for i,v in pairs(users) do
- if not fs.exists(dfile.."/"..i) then
- fs.makeDir(dfile.."/"..i)
- end
- end
- local oldfs = {}
- for i,v in pairs(fs) do
- oldfs[i] = v
- end
- local function resolve(path)
- while true do
- if string.sub(path, 1, 1) == "/" then
- path = string.sub(path, 2)
- else
- break
- end
- end
- while true do
- if string.sub(path, #path, #path) == "/" then
- path = string.sub(path, 1, #path-1)
- else
- break
- end
- end
- return path
- end
- for i,v in pairs(fs.list("/")) do
- if v ~= dfile and v ~= ufile and v ~= "rom" and v ~= "cu" then
- -- fs.delete(v)
- end
- end
- for i,v in pairs(fs.list(cfile)) do
- fs.copy(cfile.."/"..v, "/")
- end
- --[[
- function fs.open(path, typ)
- return oldfs.open(cfile.."/"..resolve(path), typ)
- end
- function fs.list(path)
- return oldfs.list(cfile.."/"..resolve(path))
- end
- while true do
- term.setTextColor(colors.yellow)
- write(shell.dir().."> ")
- term.setTextColor(colors.white)
- local rd = read()
- local isp = shell.run(rd)
- if not isp and fs.exists("programs/"..rd) then
- shell.run("programs/"..rd)
- end
- end
- ]]
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement