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 FileSystemDirectoryEntry interface of the File and Directory Entries API represents a directory in a file system. It provides methods which make it possible to access and manipulate the files in a directory, as well as to access the entries within the directory.
Because this is a non-standard API, whose specification is not currently on a standards track, it's important to keep in mind that not all browsers implement it, and those that do may implement only small portions of it. Check the Browser compatibility section for details.
Basic concepts
You can create a new directory by calling getDirectory(). If you want to create subdirectories, create each child directory in sequence. If you try creating a directory using a full path that includes parent directories that do not exist yet, an error is returned. So create the hierarchy by recursively adding a new path after creating the parent directory.
Example
In the following code snippet, we create a directory called "Documents."
// Taking care of the browser-specific prefixes.
window.requestFileSystem = window.requestFileSystem || window.webkitRequestFileSystem;
window.directoryEntry = window.directoryEntry || window.webkitDirectoryEntry;
...
function onFs(fs){
fs.root.getDirectory('Documents', {create:true}, function(directoryEntry){
//directoryEntry.isFile === false
//directoryEntry.isDirectory === true
//directoryEntry.name === 'Documents'
//directoryEntry.fullPath === '/Documents'
}, onError);
}
// Opening a file system with temporary storage
window.requestFileSystem(TEMPORARY, 1024*1024 /*1MB*/, onFs, onError);
Properties
This interface has no properties of its own, but inherits properties from its parent interface, FileSystemEntry.
Methods
This interface inherits methods from its parent interface, FileSystemEntry.
createReader()- Creates a
FileSystemDirectoryReaderobject which can be used to read the entries in this directory. getDirectory()- Returns a
FileSystemDirectoryEntryobject representing a directory located at a given path, relative to the directory on which the method is called. getFile()- Returns a
FileSystemFileEntryobject representing a file located within the directory's hierarchy, given a path relative to the directory on which the method is called.
Obsolete methods
removeRecursively()- Deletes a directory and all of its contents, including the contents of subdirectories. This has been removed from the spec.
Specifications
| Specification | Status | Comment |
|---|---|---|
| File and Directory Entries API | Draft | Draft of proposed API |
This API has no official W3C or WHATWG specification.
Browser compatibility
| Desktop | Mobile | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
FileSystemDirectoryEntry | Chrome
Full support
13
| Edge
No support
No
| Firefox Full support 50 | IE No support No | Opera
Full support
Yes
| Safari No support No | WebView Android
Full support
Yes
| Chrome Android
Full support
Yes
| Edge Mobile Full support Yes | Firefox Android Full support 50 | Opera Android No support No | Safari iOS No support No | Samsung Internet Android ? |
createReader | Chrome Full support 13 | Edge No support No | Firefox Full support 50 | IE No support No | Opera No support No | Safari No support No | WebView Android Full support Yes | Chrome Android Full support Yes | Edge Mobile ? | Firefox Android Full support 50 | Opera Android No support No | Safari iOS No support No | Samsung Internet Android ? |
getDirectory | Chrome Full support 13 | Edge No support No | Firefox
Full support
50
| IE No support No | Opera No support No | Safari No support No | WebView Android Full support Yes | Chrome Android Full support Yes | Edge Mobile ? | Firefox Android
Full support
50
| Opera Android No support No | Safari iOS No support No | Samsung Internet Android ? |
getFile | Chrome Full support 13 | Edge No support No | Firefox
Full support
50
| IE No support No | Opera No support No | Safari No support No | WebView Android Full support Yes | Chrome Android Full support Yes | Edge Mobile ? | Firefox Android
Full support
50
| Opera Android No support No | Safari iOS No support No | Samsung Internet Android ? |
removeRecursively | Chrome Full support 13 | Edge No support No | Firefox
No support
50 — 52
| IE No support No | Opera No support No | Safari No support No | WebView Android Full support Yes | Chrome Android Full support Yes | Edge Mobile ? | Firefox Android
No support
50 — 52
| Opera Android No support No | Safari iOS No support No | Samsung Internet Android ? |
Legend
- Full support
- Full support
- No support
- No support
- Compatibility unknown
- Compatibility unknown
- Experimental. Expect behavior to change in the future.
- Experimental. Expect behavior to change in the future.
- Non-standard. Expect poor cross-browser support.
- Non-standard. Expect poor cross-browser support.
- Deprecated. Not for use in new websites.
- Deprecated. Not for use in new websites.
- See implementation notes.
- See implementation notes.
- Requires a vendor prefix or different name for use.
- Requires a vendor prefix or different name for use.