FileSystemDirectoryReader.readEntries()

Deprecated

This feature is no longer recommended. Though some browsers might still support it, it may have already been removed from the relevant web standards, may be in the process of being dropped, or may only be kept for compatibility purposes. Avoid using it, and update existing code if possible; see the compatibility table at the bottom of this page to guide your decision. Be aware that this feature may cease to work at any time.

Experimental

This is an experimental technology
Check the Browser compatibility table carefully before using this in production.

Non-standard

This feature is non-standard and is not on a standards track. Do not use it on production sites facing the Web: it will not work for every user. There may also be large incompatibilities between implementations and the behavior may change in the future.

The FileSystemDirectoryReader interface's readEntries() method retrieves the directory entries within the directory being read and delivers them in an array to a provided callback function.

The objects in the array are all based upon FileSystemEntry. Generally, they are either FileSystemFileEntry objects, which represent standard files, or FileSystemDirectoryEntry objects, which represent directories.

Syntax

readEntries(successCallback);
readEntries(successCallback, errorCallback);

Parameters

successCallback
A function which is called when the directory's contents have been retrieved. The function receives a single input parameter: an array of file system entry objects, each based on FileSystemEntry. Generally, they are either FileSystemFileEntry objects, which represent standard files, or FileSystemDirectoryEntry objects, which represent directories. If there are no files left, or you've already called readEntries() on this FileSystemDirectoryReader, the array is empty.
errorCallback Optional
A callback function which is called if an error occurs while reading from the directory. It receives one input parameter: a FileError object describing the error which occurred.

Return value

undefined.

Example

See DataTransferItem.webkitGetAsEntry() for example code that uses this method.

Specifications

Specification
File and Directory Entries API
# dom-filesystemdirectoryreader-readentries

This API has no official W3C or WHATWG specification.

Browser compatibility

BCD tables only load in the browser

On Chrome 77, readEntries() will only return the first 100 FileSystemEntry instances. In order to obtain all of the instances, readEntries() must be called multiple times.

See also