Jump to content




Acces Denied...


  • You cannot reply to this topic
4 replies to this topic

#1 xdxder

  • New Members
  • 2 posts

Posted 17 November 2013 - 07:54 AM

Hey.
I made a Program that remove all files on the Computer.
But there is one Problem....the ROM-Folder...
The Program works, it delete all files on the computer but it also try to delete the rom-folder.
...
Posted Image

Can i make a program that remove all files but that don't try to remove the rom-folder?
The Code...
function rmall()
shell.run("clear")
list = fs.list("/")
anzahl = #list
zaehler = 0
print("Do you really want to remove all files?")
write("Y/N>")
eingabe = read()
if eingabe == "Y" then
  while zaehler <= anzahl do
	fs.delete(tostring(list[zaehler]))
	zaehler = zaehler + 1
  end
elseif eingabe == "N" then
  print("canceled...")
  sleep(2)
  shell.run("disk/startup")
else
  print("What?")
  sleep(2)
  rmall()
end

(its not the whole script, only the function)

#2 Ziriee

  • Members
  • 47 posts

Posted 17 November 2013 - 02:27 PM

while zaehler <= anzahl do
  if tostring(list[zaehler]) ~= "rom" then
	fs.delete(tostring(list[zaehler]))
  end
  zaehler = zaehler + 1
end

Try that. It will check if it's trying to remove the rom.

Edited by Ziriee, 17 November 2013 - 02:27 PM.


#3 Agoldfish

  • Members
  • 451 posts
  • LocationSome Fish Bowl in Ohio.

Posted 17 November 2013 - 04:40 PM

Here, this is what you want to remove all non-read only files.
for _, f in pairs(fs.list("/")) do
    if not fs.isReadOnly(f) then
	  fs.delete(f)
    end
  end
end



#4 xdxder

  • New Members
  • 2 posts

Posted 18 November 2013 - 11:59 AM

Thanks.
I'll try it.

Edited by xdxder, 19 November 2013 - 10:45 AM.


#5 Agoldfish

  • Members
  • 451 posts
  • LocationSome Fish Bowl in Ohio.

Posted 20 November 2013 - 12:17 PM

View Postxdxder, on 18 November 2013 - 11:59 AM, said:

Thanks.
I'll try it.
Did it work?





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users