Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function wrapPs(peripheralName)
- periTab = {}
- sideTab = {}
- if peripheralName == nil then
- print("Fehler")
- end
- local peripherals = peripheral.getNames()
- local i2 = 1
- for i = 1, #peripherals do
- if peripheral.getType(peripherals[i]) == peripheralName then
- periTab[i2] = peripheral.wrap(peripherals[i])
- sideTab[i2] = peripherals[i]
- i2 = i2 + 1
- end
- end
- if periTab ~= {} then
- return periTab, sideTab
- else
- return nil
- end
- function getPSide(peripheralName)
- if peripheralName == nil then
- print("Fehler")
- end
- local peripherals = peripheral.getNames()
- local i = 1
- while i < #peripherals and peripheral.getType(peripherals[i]) ~= peripheralName do
- i = i + 1
- end
- if peripheral.getType(peripherals[i]) == peripheralName then
- return peripherals[i]
- else
- return nil
- end
- end
- end
- args={...}
- ds,dss=wrapPs("drive")
- function getDriveData()
- driveData={}
- for i=1, #ds do
- data={}
- data["dID"]=ds[i].getDiskID()
- data["dLabel"]=ds[i].getDiskLabel()
- data["side"]=dss[i]
- data["path"]=ds[i].getMountPath()
- if data.path~=nil then
- data["size"]=fs.getFreeSpace(data["path"])
- data["files"]=fs.list(data["path"])
- end
- data["diskPresent"]=ds[i].isDiskPresent()
- data["hasAudio"]=ds[i].hasAudio()
- data["audioTitle"]=ds[i].getAudioTitle()
- table.insert(driveData,data)
- end
- return driveData
- end
- function listAllFiles()
- dd=getDriveData()
- files=""
- for i=1, #dd do
- if dd[i].path~=nil then
- for i2=1, #dd[i]["files"] do
- files=files..", "..dd[i].path.."/"..dd[i].files[i2]
- end
- end
- end
- print(files)
- end
- function listAudioTitles()
- dd=getDriveData()
- files=""
- for i=1, #dd do
- if dd[i]["hasAudio"] then
- files=files..", "..dd[i]["side"]..":"..dd[i]["audioTitle"]
- end
- end
- print(files)
- end
- function listAllFilesDetail()
- dd=getDriveData()
- files=""
- for i=1, #dd do
- if dd[i].path~=nil then
- for i2=1, #dd[i]["files"] do
- files=files..", "..dd[i].side..":"..dd[i].path.."/"..dd[i].files[i2]
- end
- end
- end
- print(files)
- end
- function main()
- if args[1]==nil then
- print("ls -> list Files")
- print("lsa -> list Details")
- print("lsm -> list music")
- end
- if args[1]=="ls" or args[1]=="dir" then
- listAllFiles()
- end
- if args[1]=="lsa" then
- listAllFilesDetail()
- end
- if args[1]=="lsm" or args[1]=="dirm" then
- listAudioTitles()
- end
- end
- main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement