fs.delete

Deletes the file or directory at the path path. If path is a directory, it will delete the directory as well as all the files inside.

Warning: This function is irreversible! Make sure you enter the arguments carefully so that you do not delete anything important.
ExampleDelete a file
Creates and deletes the file foo.lua, checking if it exists after each.
Code
<nowiki>
print("Making foo.lua")
local f = fs.open("foo.lua", "w")
f.close()
print("Foo exists:", fs.exists("foo.lua"))
print("Deleting foo.lua")
fs.delete("foo.lua")
print("Foo exists:", fs.exists("foo.lua"))
    </nowiki>
Output
<nowiki>
Making foo
Foo exists: true
Deleting foo
Foo exists: false
</nowiki>
ExampleDelete a directory
Creates and deletes the directory foo, checking if it exists after each.
Code
<nowiki>
print("Making foo")
fs.makeDir("foo")
print("Foo exists:", fs.exists("foo"))
print("Deleting foo")
fs.delete("foo")
print("Foo exists:", fs.exists("foo"))
    </nowiki>
Output
<nowiki>
Making foo
Foo exists: true
Deleting foo
Foo exists: false
</nowiki>

fs.delete
Function
Syntax
fs.delete(
  • path : string
)

Returns nil
API fs
Source CC:Tweaked (source)
This article is issued from Computercraft. The text is licensed under Creative Commons - Attribution - Sharealike. Additional terms may apply for the media files.