--- title: FileSystemEntry slug: Web/API/FileSystemEntry translation_of: Web/API/FileSystemEntry ---
The FileSystemEntry
interface of the File and Directory Entries API represents a single in a file system. The entry can be a file or a directory (directories are represented by the {{domxref("DirectoryEntry")}} interface). It includes methods for working with files—including copying, moving, removing, and reading files—as well as information about a file it points to—including the file name and its path from the root to the entry.
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 {{anch("Browser compatibility")}} section for details.
You don't create FileSystemEntry
objects directly. Instead, you will receive an object based on this interface through other APIs. This interface serves as a base class for the {{domxref("FileSystemFileEntry")}} and {{domxref("FileSystemDirectoryEntry")}} interfaces, which provide features specific to file system entries representing files and directories, respectively.
The FileSystemEntry
interface includes methods that you would expect for manipulating files and directories, but it also includes a convenient method for obtaining the URL of the entry: toURL()
. It also introduces a new URL scheme: filesystem:
.
You can use the filesystem:
scheme on Google Chrome to see all the files and folders that are stored in the origin of your app. Just use filesystem:
scheme for the root directory of the origin of the app. For example, if your app is in http://www.html5rocks.com
, open filesystem:http://www.html5rocks.com/temporary/
in a tab. Chrome shows a read-only list of all the files and folders stored the origin of your app.
To see an example of how toURL()
works, see the method description. The snippet below shows you how you can remove a file by name.
// Taking care of the browser-specific prefixes. window.requestFileSystem = window.requestFileSystem || window.webkitRequestFileSystem; ... // Opening a file system with temporary storage window.requestFileSystem(TEMPORARY, 1024*1024 /*1MB*/, function(fs) { fs.root.getFile('log.txt', {}, function(fileEntry) { fileEntry.remove(function() { console.log('File removed.'); }, onError); }, onError); }, onError);
This interface provides the following properties.
true
if the entry represents a directory; otherwise, it's false
.true
if the entry represents a file. If it's not a file, this value is false
.This interface defines the following methods.
"filesystem:"
.Specification | Status | Comment |
---|---|---|
{{SpecName('File System API')}} | {{Spec2('File System API')}} | Draft of proposed API |
This API has no official W3C or WHATWG specification.
{{Compat("api.FileSystemEntry")}}
FileSystemEntry
.