非标
此特征是非标准的,且不在标准轨道中。不要在面向 Web 的生产站点中使用它:它不适用于每个用户。实现之间可能存在大的不兼容性,且行为将来可能改变。
FileSystemEntrySync
interface of the File and Directory Entries API represents an entry in a file system; it can be either a
FileEntrySync
or
DirectoryEntry
.
It includes methods for working with files—including copying, moving, removing, and reading files—as well as information about the file it points to—including the file name and its path from the root to the entry.
警告 : This API was never accepted and never became standardized. Various browsers implement pieces of the 文件和目录条目 API (otherwise known as the File System API) but you should try to avoid using it.
FileSystemEntrySync
interface includes methods that you would expect for manipulating files and directories, but it also include a really handy method for getting a URL of the entry:
toURL()
. It also introduces a new URL scheme:
filesystem:
.
可以使用
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://ww.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.
元数据
getMetadata
() raises (
FileException
);
|
FileSystemEntrySync
moveTo
(in
DirectoryEntrySync
parent
, optional DOMString
newName
) raises (
FileException
);
|
FileSystemEntrySync
copyTo
(in
DirectoryEntrySync
parent
, optional DOMString
newName
) raises (
FileException
);
|
DOMString
toURL
();
|
void
remove
() raises (
FileException
);
|
DirectoryEntrySync
getParent
();
|
| 属性 | 类型 | 描述 |
|---|---|---|
filesystem
|
readonly FileSystemSync
|
The file system where the entry resides. |
fullpath
|
readonly DOMString
|
The full absolute path from the root to the entry.
An absolute path is a relative path from the root directory, prepended with a '
|
isDirectory
|
readonly boolean
|
True if FileSystemEntrySync is a directory. |
isFile
|
readonly boolean
|
True if the FileSystemEntrySync is a file. |
名称
|
readonly DOMString
|
The name of the entry, excluding the path leading to it. |
Look up metadata about this entry. [ todo: specify what kind of metadata ]
Metadata getMetada ()
raises (FileException);
元数据
This method can raise a FileException with the following codes:
| 异常 | 描述 |
|---|---|
NOT_FOUND_ERR
|
The entry does not exist. |
INVALID_STATE_ERR
|
The FileSystemSync is no longer valid for some reason besides being deleted. |
Move an entry to a different location on the file system. Moving a file over an existing file replaces that existing file. Moving a directory over an existing empty directory replaces that directory. [todo: What if the directory is not empty? ]
[todo: Verify ] This is the same method for renaming files. You can keep it in the same location and then define the
newName
参数。
You cannot do the following:
FileSystemEntrySync moveTo ( in DirectoryEntrySync parent, optional DOMString newName ) raises (FileException);
The directory to which to move the entry.
The new name of the entry. If you do not specify a name, the browser preserves the entry's current name.
FileSystemEntrySync
An object that represents an entry in the file system.
This method can raise a FileException with the following codes:
| 异常 | 描述 |
|---|---|
ENCODING_ERR
|
The name supplied is invalid, because at least one of the characters is reserved or illegal. Examples include a backslash (\), dot (.), and two dots (..). |
NOT_FOUND_ERR
|
The target directory does not exist. |
INVALID_MODIFICATION_ERR
|
You tried one of the following disallowed operations:
|
NO_MODIFICATION_ALLOWED_ERR
|
One of the following is not writable: the source entry, its parent directory, and the target directory. |
Copy an entry to a different location on the file system. You cannot copy an entry inside itself if it is a directory, nor can you copy it into its parent without providing a new name. Directory copies are always recursive—that is, all contents of the directory are copied. You cannot change this behavior. Files are simply duplicated.
void copyTo ( in DirectoryEntrySync parent, optional DOMString newName ) raises (FileException);
The directory where you want the entry to move to.
The new name of the entry. If you do not specify a name, the browser preserves the FileSystemEntrySync's current name.
FileSystemEntrySync
An object that represents an entry in the file system.
This method can raise a FileException with the following codes:
| 异常 | 描述 |
|---|---|
ENCODING_ERR
|
The name supplied is invalid, because at least one of the characters is reserved or illegal. Examples include a backslash (\), dot (.), and two dots (..). |
NOT_FOUND_ERR
|
The target directory does not exist. |
INVALID_MODIFICATION_ERR
|
You tried one of the following disallowed operations:
|
NO_MODIFICATION_ALLOWED_ERR
|
One of the following is not writable: the source entry, its parent directory, and the target directory. |
QUOTA_EXCEEDED_ERR
|
The operation would cause the application to exceed its storage quota. You can ask for a larger persistent storage, which your user must explicitly grant. For more information, see the article on basic concepts . |
Returns a URL that can be used to identify this entry. It exposes a new URL scheme—
filesystem:
—that you can use to fill
src
or
href
attributes. For example, if you wanted to display an image and have its
fileEntry
,调用
toURL()
gives you the image file's file system URL. You get something like:
filesystem:
http://example.com/temporary/lolcat.png
.
The file system URL does not expire. Because the method describes a location on disk, the URL is valid for as long as that location exists. You can delete the file and recreate it, and it's all good.
You can supply the
mimeType
to simulate the optional MIME type header associated with HTTP downloads.
DOMString toURL ();
DOMString
None
Deletes a file or directory. You cannot delete an empty directory or the root directory of a file system. If you want to remove an empty directory, use
removeRecursively()
代替。
void remove ( ) raises (FileException);
None
void
This method can raise a FileException with the following codes:
| 异常 | 描述 |
|---|---|
NOT_FOUND_ERR
|
The target directory does not exist. |
INVALID_MODIFICATION_ERR
|
You tried to remove a directory that is not empty. If you want to remove an empty directory, use
removeRecursively()
代替。
|
NO_MODIFICATION_ALLOWED_ERR
|
One of the following is not writable: the source entry, its parent directory, and the target directory. |
Look up the parent
DirectoryEntrySync
containing the entry. If this entry is the root of its file system, then the parent is itself.
void getParent ();
None
DirectoryEntrySync
An object that represents a directory in the file system.
None.
No compatibility data found. Please contribute data for "api.FileSystemEntrySync" (depth: 1) to the MDN 兼容性数据存储库 .
规范: File API: Directories and System Specification WD
参考: 文件系统 API
介绍: Basic Concepts About the File System API
FileSystemEntrySync
FileError
FileException
FileHandle
FileRequest
FileSystem
FileSystemDirectoryEntry
FileSystemDirectoryEntrySync
FileSystemDirectoryReader
FileSystemDirectoryReaderSync
FileSystemEntry
FileSystemFileEntry
FileSystemFileEntrySync
FileSystemFlags
FileSystemSync
HTMLInputElement
LocalFileSystem
LocalFileSystemSync
LockedFile
元数据
Window.requestFileSystem()
Window.resolveLocalFileSystemURL()
WorkerGlobalScope.requestFileSystemSync()