--- title: FileSystemEntry slug: Web/API/FileSystemEntry translation_of: Web/API/FileSystemEntry --- <div>{{APIRef("File System API")}} {{non-standard_header}}</div> <p>The <strong><code>FileSystemEntry</code></strong> 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.</p> <div class="note"> <p>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.</p> </div> <h2 id="basic" name="basic">Basic concepts</h2> <p>You don't create <code>FileSystemEntry</code> 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.</p> <p>The <code>FileSystemEntry</code> 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: <code><a href="#toURL">toURL()</a></code>. It also introduces a new URL scheme: <code>filesystem:</code>.</p> <p>You can use the <code>filesystem:</code> scheme on Google Chrome to see all the files and folders that are stored in the origin of your app. Just use <code>filesystem:</code> scheme for the root directory of the origin of the app. For example, if your app is in <code><a href="http://www.html5rocks.com" rel="freelink">http://www.html5rocks.com</a></code>, open<code> filesystem:<a href="http://www.html5rocks.com/temporary/" rel="freelink">http://www.html5rocks.com/temporary/</a></code> in a tab. Chrome shows a read-only list of all the files and folders stored the origin of your app.</p> <h3 id="example" name="example">Example</h3> <p>To see an example of how <code>toURL()</code> works, see the <a href="#toURL">method description</a>. The snippet below shows you how you can remove a file by name.</p> <pre class="brush: js">// 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); </pre> <h2 id="Properties">Properties</h2> <p><em>This interface provides the following properties.</em></p> <dl> <dt>{{domxref("FileSystemEntry.filesystem", "filesystem")}} {{ReadOnlyInline}}</dt> <dd>A {{domxref("FileSystem")}} object representing the file system in which the entry is located.</dd> <dt>{{domxref("FileSystemEntry.fullPath", "fullPath")}} {{ReadOnlyInline}}</dt> <dd>A {{domxref("USVString")}} object which provides the full, absolute path from the file system's root to the entry; it can also be thought of as a path which is relative to the root directory, prepended with a "/" character.</dd> <dt>{{domxref("FileSystemEntry.isDirectory", "isDirectory")}} {{ReadOnlyInline}}</dt> <dd>A {{jsxref("Boolean")}} which is <code>true</code> if the entry represents a directory; otherwise, it's <code>false</code>.</dd> <dt>{{domxref("FileSystemEntry.isFile", "isFile")}} {{ReadOnlyInline}}</dt> <dd>A Boolean which is <code>true</code> if the entry represents a file. If it's not a file, this value is <code>false</code>.</dd> <dt>{{domxref("FileSystemEntry.name", "name")}} {{ReadOnlyInline}}</dt> <dd>A {{domxref("USVString")}} containing the name of the entry (the final part of the path, after the last "/" character).</dd> </dl> <h2 id="Methods">Methods</h2> <p><em>This interface defines the following methods.</em></p> <dl> <dt>{{domxref("FileSystemEntry.copyTo", "copyTo()")}}</dt> <dd>Copies the file or directory to a new location on the file system.</dd> <dt>{{domxref("FileSystemEntry.getMetadata", "getMetadata()")}}</dt> <dd>Obtains metadata about the file, such as its modification date and size.</dd> <dt>{{domxref("FileSystemEntry.getParent", "getParent()")}}</dt> <dd>Returns a {{domxref("FileSystemDirectoryEntry")}} representing the entry's parent directory.</dd> <dt>{{domxref("FileSystemEntry.moveTo", "moveTo()")}}</dt> <dd>Moves the file or directory to a new location on the file system, or renames the file or directory.</dd> <dt>{{domxref("FileSystemEntry.remove", "remove()")}}</dt> <dd>Removes the specified file or directory. You can only remove directories which are empty.</dd> <dt>{{domxref("FileSystemEntry.toURL", "toURL()")}}</dt> <dd>Creates and returns a URL which identifies the entry. This URL uses the URL scheme <code>"filesystem:"</code>.</dd> </dl> <h2 id="Specifications">Specifications</h2> <table class="standard-table"> <thead> <tr> <th scope="col">Specification</th> <th scope="col">Status</th> <th scope="col">Comment</th> </tr> </thead> <tbody> <tr> <td>{{SpecName('File System API')}}</td> <td>{{Spec2('File System API')}}</td> <td>Draft of proposed API</td> </tr> </tbody> </table> <p>This API has no official W3C or WHATWG specification.</p> <h2 id="Browser_compatibility" name="Browser_compatibility">Browser compatibility</h2> <div> <p>{{Compat("api.FileSystemEntry")}}</p> </div> <h2 id="See_also">See also</h2> <ul> <li><a href="/en-US/docs/Web/API/File_and_Directory_Entries_API">File and Directory Entries API</a></li> <li><a href="/en-US/docs/Web/API/File_and_Directory_Entries_API/Introduction">Introduction to the File System API</a></li> <li>{{domxref("FileSystemFileEntry")}} and {{domxref("FileSystemDirectoryEntry")}} are based on <code>FileSystemEntry</code>.</li> </ul>