Home Contents | # os.scandir | OS | Core4 Lua Commands

## SYNOPSIS

entries = os.scandir(path[, flags | nil[, name_filters]])

## DESCRIPTION

Provides a quick and easy way to read a full directory into a list. The parameter path selects the directory.

Each character in the string flags modifies the behaviour of the directory scan:

- 'D': List directories
- 'F': List normal files
- 'S': List special files
- 'L': List symbolic links
- '.': Also list the special entries "." and ".."
- 'c': Filter is not case sensitive
- 'P': Return full path for each entry, not just the filename.

If neither 'D', 'F', 'S' nor 'L' is given, defaults to "DFSL".

name_filters can be a string or a list containing common wildcard filters (e.g. "*.txt")

## RETURN VALUE

os.opendir() returns a list containing all results on success. On error, three values are returned: nil, a string describing the error (The result of the C library call strerror() on the errno code) and the errno number from the standard C library.

## EXAMPLE

> > > >
dirs = os.scandir("/media") if (dirs) then print(table.tostring(dirs, 2)) end
OUTPUT

## SEE ALSO

os.chdir, os.cwd, os.mkdir, os.remove, os.opendir, table.tostring