This is a read-only snapshot of the ComputerCraft forums, taken in April 2020.
Scoptile's profile picture

Computer Cleaner

Started by Scoptile, 21 July 2015 - 07:34 AM
Scoptile #1
Posted 21 July 2015 - 09:34 AM
DISCLAIMER: I don't know if this counts as malicious! If it does please tell me! I do clearly say it deletes all files, because that's its purpose. If I'm right, malicious would be deleting all programs without making it clear that that's what it's doing, and giving the user a choice weather or not they want to do it. I'm going to make it clear that that's what it does:

THIS PROGRAM DELETES ALL THE FILES ON THE COMPUTER!!!! DON'T RUN IT IF YOU DON'T WANT ALL THE FILES ON THE COMPUTER YOU RUN IT ON TO BE DELETED PERMANENTLY!!!!

There.

If you are ever just testing stuff out on a computer, like I often do, then you might like this program! It will delete all the files on your computer except for itself. It's good for cleaning up programs that create a lot of files. I hope you enjoy :)/>

Run this program to install it on your computer:
pastebin get 8iDT0DLJ reset
MUST BE NAMED 'reset' OR IT WILL DELETE ITSELF

Run this program to run it once:
pastebin run 8iDT0DLJ
Note that if you have a program that is named 'reset', it will not be deleted.
PokeAcer #2
Posted 22 July 2015 - 03:19 PM
do you know what else does this? rm *
biggest yikes #3
Posted 22 July 2015 - 03:23 PM
As of CC 1.6, computers have implemented wildcards, so typing "delete *" in the computer would attempt to delete all the files.
flaghacker #4
Posted 22 July 2015 - 03:50 PM
You might want to check out shell.getRunningProgram to get the name of your program automatically so you don't have to name it 'reset'.

Don't worry about the fact it's already possible, keep learning!
Edited on 22 July 2015 - 01:50 PM
LewisTehMinerz #5
Posted 22 July 2015 - 03:50 PM
@​Scoptile,

Just a word of notice,

(file ~= "reset")
could be changed to

(file ~= shell.getRunningProgram())

This will make it so that you don't need to have the file's name as "reset".
MKlegoman357 #6
Posted 22 July 2015 - 04:39 PM
Instead of checking for certain file names you can check if the file is read-only before deleting.
hteee #7
Posted 22 July 2015 - 06:22 PM
Instead of checking for certain file names you can check if the file is read-only before deleting.
It would still do the exact same thing so there's no point?
MKlegoman357 #8
Posted 22 July 2015 - 06:54 PM
It would still do the exact same thing so there's no point?

No it would not. First off, it would not depend on certain files or folders. In custom filesystem environments the 'rom' folder might actually be removable. Also, something you might encounter more often are folders of disks in disk drives. Plus, other mods might add their own disk-like folders.
Scoptile #9
Posted 22 July 2015 - 08:15 PM
Well it still says 'Poof!' so thats a plus
Zenon #10
Posted 06 August 2015 - 12:10 AM
Well it still says 'Poof!' so thats a plus

Gotta have that "Poof!" in there :P/>