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

Formatting / System Restore

Started by boudragon, 29 September 2013 - 07:48 AM
boudragon #1
Posted 29 September 2013 - 09:48 AM
I'm curious if there is a command or set of commands that can be added to a program to basically return the system to its original state as in having no additional files on it. Just the ones the system starts with. I want to make a system restore program on a disk that cleans the system and then places files back on. Is there an easy way to do this or do I have to tell the system to delete single files and folders at a time?
MKlegoman357 #2
Posted 29 September 2013 - 11:18 AM
There is no system restore program implemented into computercraft. You would have to make it yourself.
boudragon #3
Posted 29 September 2013 - 11:23 AM
… That's what I intend to do… but in order to do that I need to know if there is a simple way to delete ALL non-protected files on the system… I have made one before but it didn't delete anything but the files it tried to replace…
Engineer #4
Posted 29 September 2013 - 11:35 AM
You want to delete all folders and files in the main directory:

local files = fs.list( "/" ) --# all the files and folders in the directory '/' --> main
for i = 1, #files do
    if files[i] ~= "rom" then --# You cannot delete rom
       fs.delete( files[i] )
    end
end
MKlegoman357 #5
Posted 29 September 2013 - 11:45 AM
You want to delete all folders and files in the main directory:

local files = fs.list( "/" ) --# all the files and folders in the directory '/' --> main
for i = 1, #files do
    if files[i] ~= "rom" then --# You cannot delete rom
       fs.delete( files[i] )
    end
end

Actually it would try to delete disk's folders too. Instead, you should check if file/folder is read only:


for _, f in pairs(fs.list("/")) do
  if not fs.isReadOnly(f) then
    fs.delete(f)
  end
end
Edited on 29 September 2013 - 09:46 AM
boudragon #6
Posted 29 September 2013 - 11:53 AM
The system restore program will be on a disk anyways… I just need it to remove everything that is not read only. I will try this out and let you know how it works. Thank you! :)/>
boudragon #7
Posted 29 September 2013 - 12:01 PM
Keep getting unexpected symbol on line three…

::EDIT::

Nevermind I got it to work. It deletes everything on the system and not on the disk. Works great thank you!
0099 #8
Posted 08 October 2013 - 12:10 AM
You can store all original-state files in special directory, and simply reset the system by deleting all except this directory. That is, you create your own ROM folder and deny access to it for all programs. If some programs requires "replacing" of this files, you make OTHER folder named "updates" and run files in there instead of running original files. To reset, delete all user data and all updates.
boudragon #9
Posted 08 October 2013 - 06:28 AM
You can store all original-state files in special directory, and simply reset the system by deleting all except this directory. That is, you create your own ROM folder and deny access to it for all programs. If some programs requires "replacing" of this files, you make OTHER folder named "updates" and run files in there instead of running original files. To reset, delete all user data and all updates.

That almost sounds like you want a system to have partition with a system restore on it like a Dell or other pre-built system is that correct? If this is the case it sounds like a decent plan for the future, however the reason I didn't do it like that this time is because it boils down to this… all it takes is an act of griefing and regardless of what is on the system they pop your computer and everything is gone anyways. With an external system restore file at least you can download the restore or have a backup disk somewhere and setup any computer in seconds.