Movatterモバイル変換


[0]ホーム

URL:


  1. Web
  2. Web APIs
  3. FileSystemEntry

FileSystemEntry

TheFileSystemEntry interface of the File and Directory Entries API represents a single entry in a file system. The entry can be a file or a directory (directories are represented by theFileSystemDirectoryEntry 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.

Basic concepts

You don't createFileSystemEntry objects directly. Instead, you will receive an object based on this interface through other APIs. This interface serves as a base class for theFileSystemFileEntry andFileSystemDirectoryEntry interfaces, which provide features specific to file system entries representing files and directories, respectively.

TheFileSystemEntry 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 thefilesystem: scheme on Google Chrome to see all the files and folders that are stored in the origin of your app. Just usefilesystem: scheme for the root directory of the origin of the app. For example, if your app is inhttp://www.example.com, openfilesystem:http://www.example.com/temporary/ in a tab. Chrome shows a read-only list of all the files and folders stored the origin of your app.

Example

To see an example of howtoURL() works, see themethod description. The snippet below shows you how you can remove a file by name.

js
// Taking care of the browser-specific prefixes.window.requestFileSystem =  window.requestFileSystem || window.webkitRequestFileSystem;// …// Opening a file system with temporary storagewindow.requestFileSystem(  TEMPORARY,  1024 * 1024 /* 1MB */,  (fs) => {    fs.root.getFile(      "log.txt",      {},      (fileEntry) => {        fileEntry.remove(() => {          console.log("File removed.");        }, onError);      },      onError,    );  },  onError,);

Instance properties

This interface provides the following properties.

filesystemRead only

AFileSystem object representing the file system in which the entry is located.

fullPathRead only

A string 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.

isDirectoryRead only

A boolean value which istrue if the entry represents a directory; otherwise, it'sfalse.

isFileRead only

A Boolean which istrue if the entry represents a file. If it's not a file, this value isfalse.

nameRead only

A string containing the name of the entry (the final part of the path, after the last "/" character).

Instance methods

This interface defines the following methods.

copyTo()DeprecatedNon-standard

Copies the file or directory to a new location on the file system.

getMetadata()DeprecatedNon-standard

Obtains metadata about the file, such as its modification date and size.

getParent()

Returns aFileSystemDirectoryEntry representing the entry's parent directory.

moveTo()DeprecatedNon-standard

Moves the file or directory to a new location on the file system, or renames the file or directory.

remove()DeprecatedNon-standard

Removes the specified file or directory. You can only remove directories which are empty.

toURL()DeprecatedNon-standard

Creates and returns a URL which identifies the entry. This URL uses the URL scheme"filesystem:".

Specifications

Specification
File and Directory Entries API
# api-entry

Browser compatibility

See also

Help improve MDN

Learn how to contribute

This page was last modified on byMDN contributors.


[8]ページ先頭

©2009-2025 Movatter.jp