File.children

From MiniScript Wiki
Revision as of 23:15, 11 July 2021 by JoeStrout (talk | contribs) (Created page with "In Mini Micro and command-line MiniScript, the <c>file.children</c> function returns a list of all the file names within the given directory. See also: file...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

In Mini Micro and command-line MiniScript, the file.children function returns a list of all the file names within the given directory.

See also: file.child

Arguments

Parameter Name Meaning
path absolute or relative path to a directory (defaults to file.curdir)

Usage Notes

This method returns a list of all the files and directories within the directory specified by the given path (or if no path is given, then within the current directory). This list does not include the special "." and ".." files some platforms use to represent the current and parent directory.

The file names are returned in the default order for the platform; this is alphabetical in Mini Micro, but not necessarily on desktop platforms.

If given an invalid path, this returns null. Note that this is different from an empty directory, which returns an empty list.

Example

This prints the a list of all the file and directory names within the current directory.

print file.children

The following lists the contents of a directory at the absolute path /usr, one name per line. (Note that this will generate an error if run on a platform where no /usr directory exists.)

for name in file.children("/usr")
    print name
end for