FileSystemFlags

Our volunteers haven't translated this article into Türkçe yet. Join us and help get the job done!
You can also read the article in English (US).

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 FileSystemFlags dictionary defines a set of values which are used when specifying option flags when calling certain methods in the File and Directory Entries API. Methods which accept an options parameter of this type may specify zero or more of these flags as fields in an object, like this:

dataDirectoryEntry.getDirectory("Workspace", { create: true }, function(entry) {
});

Here, we see that the create property is provided, with a value of true, indicating that the directory should be created if it's not already there.

Note that these option flags currently don't have any useful meaning when used in the scope of Web content, where security precautions prevent the creation of new files or the replacement of existing ones.

Properties

create Optional
If this property is true, and the requested file or directory doesn't exist, the user agent should create it. The default is false. The parent directory must already exist.
exclusive Optional
If true, and the create option is also true, the file must not exist prior to issuing the call. Instead, it must be possible for it to be created newly at call time. The default is false.

Values and results

The table below describes the result of each possible combination of these flags depending on whether or not the target file or directory path already exists.

Option values File/directory condition Result
create exclusive
false n/a[1] Path exists and matches the desired type (depending on whether the function called is getFile() or getDirectory() The successCallback is called with a FileSystemFileEntry if getFile() was called or a FileSystemDirectoryEntry if getDirectory() was called.
false n/a[1] Path exists but doesn't match the desired type The errorCallback is called with an appropriate error code (if the callback was provided).
true false Path exists The existing file or directory is removed and replaced with a new one, then the successCallback is called with a FileSystemFileEntry or a FileSystemDirectoryEntry, as appropriate.
true false Path doesn't exist The file or directory is created, then a FileSystemFileEntry or a FileSystemDirectoryEntry is passed to the successCallback, as appropriate.
true true Path exists The errorCallback is called with an appropriate error, such as FileError.PATH_EXISTS_ERR.
true true Path doesn't exist The file or directory is created, then a FileSystemFileEntry or a FileSystemDirectoryEntry is passed to the successCallback, as appropriate.

[1] When create is false, the value of exclusive is irrelevant and ignored.

Specifications

Specification Status Comment
File and Directory Entries API
The definition of 'FileSystemFlags' in that specification.
Draft Initial specification.

This API has no official W3C or WHATWG specification.

Browser compatibility

Update compatibility data on GitHub
DesktopMobile
ChromeEdgeFirefoxInternet ExplorerOperaSafariAndroid webviewChrome for AndroidEdge MobileFirefox for AndroidOpera for AndroidSafari on iOSSamsung Internet
Basic support
ExperimentalNon-standard
Chrome Full support 13
Prefixed
Full support 13
Prefixed
Prefixed Implemented with the vendor prefix: webkit
Edge ? Firefox Full support 50IE No support NoOpera No support NoSafari No support NoWebView Android Full support Yes
Prefixed
Full support Yes
Prefixed
Prefixed Implemented with the vendor prefix: webkit
Chrome Android Full support Yes
Prefixed
Full support Yes
Prefixed
Prefixed Implemented with the vendor prefix: webkit
Edge Mobile ? Firefox Android Full support 50Opera Android No support NoSafari iOS No support NoSamsung Internet Android ?
create
ExperimentalNon-standard
Chrome Full support 13
Prefixed
Full support 13
Prefixed
Prefixed Implemented with the vendor prefix: webkit
Edge ? Firefox Partial support 50
Notes
Partial support 50
Notes
Notes For security reasons, Firefox does not support creating files. This option has no effect.
IE No support NoOpera No support NoSafari No support NoWebView Android Full support Yes
Prefixed
Full support Yes
Prefixed
Prefixed Implemented with the vendor prefix: webkit
Chrome Android Full support Yes
Prefixed
Full support Yes
Prefixed
Prefixed Implemented with the vendor prefix: webkit
Edge Mobile ? Firefox Android Partial support 50
Notes
Partial support 50
Notes
Notes For security reasons, Firefox does not support creating files. This option has no effect.
Opera Android No support NoSafari iOS No support NoSamsung Internet Android ?
exclusive
ExperimentalNon-standard
Chrome Full support 13
Prefixed
Full support 13
Prefixed
Prefixed Implemented with the vendor prefix: webkit
Edge ? Firefox Partial support 50
Notes
Partial support 50
Notes
Notes For security reasons, Firefox does not support creating files. This option has no effect.
IE No support NoOpera No support NoSafari No support NoWebView Android Full support Yes
Prefixed
Full support Yes
Prefixed
Prefixed Implemented with the vendor prefix: webkit
Chrome Android Full support Yes
Prefixed
Full support Yes
Prefixed
Prefixed Implemented with the vendor prefix: webkit
Edge Mobile ? Firefox Android Partial support 50
Notes
Partial support 50
Notes
Notes For security reasons, Firefox does not support creating files. This option has no effect.
Opera Android No support NoSafari iOS No support NoSamsung Internet Android ?

Legend

Full support  
Full support
Partial support  
Partial 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.
See implementation notes.
See implementation notes.
Requires a vendor prefix or different name for use.
Requires a vendor prefix or different name for use.

See also

Document Tags and Contributors

Contributors to this page: fscholz, tocretpa, Sheppy
Last updated by: fscholz,