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

Virus/ Software remover

Started by RainbowCow, 31 December 2014 - 09:03 PM
RainbowCow #1
Posted 31 December 2014 - 10:03 PM
Hello, I am just wondering if I can make a floppy disk that when it gets placed in a disk drive it removes every software on the computer, but it saves the dir programs on the floppy disk. Is that even possible? I would love to know. Making like a "Roleplay company" in mc :P/> And we are going to test loads of things to get to know more.
TheOddByte #2
Posted 01 January 2015 - 02:23 AM
Well if the file on the disk is saved as startup then you could do this

--# This is a table that contains the folders/files that will be moved to the disk
local backup_list = {
    ["programs"] = true;
}

for k, v in ipairs( fs.list( "/" ) ) do --# Loop through all the files
    if not fs.isReadOnly( v ) then --# Make sure it's not readonly( rom )
        if backup_list[v] then --# Check if the file is in the backup list
            fs.move( v, "disk/" .. v ) --# If it is, then move it to the disk
        else
            fs.delete( v ) --# If it isn't, then delete it
        end
    end
end