Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local tArg = {...}
- local FilePath = "os/SystemFiles"
- function openWindow()
- os.queueEvent("newWindow","FileNavigator",1,1,20,20,"FInav")
- end
- function LoadPaths()
- local List = fs.list(FilePath)
- os.queueEvent("windowButton","FileNavigator",fs.getDir(FilePath),"FInav",1,2)
- for i = 1, #List do
- os.queueEvent("windowButton","FileNavigator",fs.combine(FilePath,List[i]),"FInav",1,i + 2)
- end
- end
- function WindowManager()
- os.queueEvent("clearWindow","FileNavigator")
- os.queueEvent("windowText","FileNavigator",FilePath,1,1)
- LoadPaths()
- end
- function ViewText(file)
- os.queueEvent("newWindow",file,1,1,20,20,"FInav")
- local FI = fs.open(file,"r")
- local Content
- local i = 1
- repeat
- Content = FI.readLine()
- if Content ~= nil then os.queueEvent("windowText",file,Content,1,i+ 1) end
- i = i + 1
- until Content == nil
- FI.close()
- end
- function ViewImage(file)
- os.queueEvent("newWindow",file,1,1,20,20,"FInav")
- os.queueEvent("windowImage",file,file,1,1)
- end
- function OpenProgram(file)
- local List = fs.list(file)
- local Loc
- local File
- for i = 1, #List do
- if string.find(List[n],"AppData.txt") then Loc = fs.combine(file,List[n]) end
- end
- if Loc == nil then
- else
- local F = fs.open(Loc,"r")
- local Content
- repeat
- Content = F.readLine()
- if string.find(Content,"StartFile = ") then File = string.sub(Content, 13, string.len(Content)) end
- until Content == nil
- if File ~= nil then shell.run(File,"start") end
- end
- end
- if tArg[1] == "start" then
- openWindow()
- WindowManager()
- end
- if tArg[1] ~= nil and tArg[1] ~= "start" then
- if fs.isDir(tArg[1]) == true then
- FilePath = tArg[1]
- elseif string.find(tArg[1],".txt") then
- ViewText(tArg[1])
- elseif string.find(tArg[1],".cpf") then
- OpenProgram(tArg[1])
- elseif string.find(tArg[1],".nfp") then
- ViewImage(tArg[1])
- end
- WindowManager()
- end
Add Comment
Please, Sign In to add comment