File.delete

From MiniScript Wiki
Revision as of 01:09, 28 September 2021 by JoeStrout (talk | contribs) (added bug note)
Jump to navigation Jump to search

The file.delete method deletes a file or empty directory from disk.

Arguments

Parameter Name Default Value Meaning
path "" file name, partial path, or absolute path to file or directory to be deleted

If given a file name or partial path, it will be interpreted relative to the current working directory (see file.curdir).

Result

If the file was successfully deleted, this method returns true (1). Otherwise, it returns false (0). This can happen if the specified file does not exist, if it is a directory that is not empty, or if some other low-level issue occurs (for example, the file is locked).

Known Issue

In version 1.0 of Mini Micro, `file.delete` fails on a directory (even if empty), returning "Error: file not found".

Example

The following attempts to delete a file called "test.txt" in the current directory.

file.delete "test.txt"