8 posts
Posted 05 March 2016 - 02:33 PM
Can Someone help me
how can i delete all files from the default directory?
767 posts
Posted 05 March 2016 - 05:04 PM
Can Someone help me
how can i delete all files from the default directory?
What do you mean?
The default directory of a CC computer is /.
To remove all files type
rm * when the computer is opened.The rom directory is readOnly, which means that it is not possible to remove it.I hope that helped
Edited on 05 March 2016 - 04:06 PM
339 posts
Location
Computer, Base, SwitchCraft, Cube-earth, Blockiverse, Computer
Posted 05 March 2016 - 06:18 PM
or do fs.delete("*") within a Lua interpreter or a program.
fs.delete("*")
756 posts
Posted 05 March 2016 - 06:50 PM
or do fs.delete("*") within a Lua interpreter or a program.
That will only delete the file named
*.
FS doesn't deal with wildcards, the shell does.
Edited on 05 March 2016 - 05:51 PM
339 posts
Location
Computer, Base, SwitchCraft, Cube-earth, Blockiverse, Computer
Posted 05 March 2016 - 07:57 PM
Oh. Didn't know that.
353 posts
Location
Orewa, New Zealand
Posted 06 March 2016 - 09:17 AM
If you want to delete all files in the root directory of your computer (excluding rom and other read only directories) from within a program you could try something along these lines (untested as am on phone)
for _, file in ipairs( fs.list("") ) do --# loop every file and subdirectory
if not fs.isReadyOnly( file ) and not fs.isDir( file ) then --# your question said 'all files'. If you want to delete all subdirectories too remove the 'and not fs.isDir( file )' from that if statement. The rest of the IF statement makes sure we don't try to delete the rom or other protected directories (causes crash).
fs.delete( file ) --# delete the file
end
end
Apologies if this doesn't work 100% as I mentioned I am on my phone and cannot test.
Edited on 06 March 2016 - 08:18 AM