这是
实验性技术
检查
浏览器兼容性表格
要小心谨慎在生产中使用这之前。
FileSystemDirectoryEntry
接口在
文件和目录条目 API
represents a directory in a file system. It provides methods which make it possible to access and manipulate the files in a directory, as well as to access the entries within the directory.
You can create a new directory by calling
getDirectory()
. If you want to create subdirectories, create each child directory in sequence. If you try creating a directory using a full path that includes parent directories that do not exist yet, an error is returned. So create the hierarchy by recursively adding a new path after creating the parent directory.
In the following code snippet, we create a directory called "Documents."
// Taking care of the browser-specific prefixes.
window.requestFileSystem = window.requestFileSystem || window.webkitRequestFileSystem;
window.directoryEntry = window.directoryEntry || window.webkitDirectoryEntry;
...
function onFs(fs){
fs.root.getDirectory('Documents', {create:true}, function(directoryEntry){
//directoryEntry.isFile === false
//directoryEntry.isDirectory === true
//directoryEntry.name === 'Documents'
//directoryEntry.fullPath === '/Documents'
}, onError);
}
// Opening a file system with temporary storage
window.requestFileSystem(TEMPORARY, 1024*1024 /*1MB*/, onFs, onError);
This interface has no properties of its own, but inherits properties from its parent interface,
FileSystemEntry
.
This interface inherits methods from its parent interface,
FileSystemEntry
.
createReader()
FileSystemDirectoryReader
object which can be used to read the entries in this directory.
getDirectory()
FileSystemDirectoryEntry
object representing a directory located at a given path, relative to the directory on which the method is called.
getFile()
FileSystemFileEntry
object representing a file located within the directory's hierarchy, given a path relative to the directory on which the method is called.
removeRecursively()
Deletes a directory and all of its contents, including the contents of subdirectories. This has been removed from the spec.
| 规范 | 状态 | 注释 |
|---|---|---|
|
文件和目录条目 API
The definition of 'FileSystemDirectoryEntry' in that specification. |
草案 |
| 桌面 | 移动 | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
FileSystemDirectoryEntry
|
Chrome
8
Alternate Name
|
Edge
79
Prefixed
|
Firefox 50 | IE No |
Opera
Yes
Prefixed
|
Safari 11.1 |
WebView Android
≤37
Alternate Name
|
Chrome Android
18
Alternate Name
|
Firefox Android 50 | Opera Android No | Safari iOS 11.3 |
Samsung Internet Android
Yes
Prefixed
|
createReader
|
Chrome 13 | Edge 79 | Firefox 50 | IE No | Opera No | Safari 11.1 | WebView Android ≤37 | Chrome Android 18 | Firefox Android 50 | Opera Android No | Safari iOS 11.3 | Samsung Internet Android Yes |
getDirectory
|
Chrome 8 | Edge 79 |
Firefox
50
|
IE No | Opera No | Safari 11.1 | WebView Android ≤37 | Chrome Android 18 |
Firefox Android
50
|
Opera Android No | Safari iOS 11.3 | Samsung Internet Android Yes |
getFile
|
Chrome 8 | Edge 79 |
Firefox
50
|
IE No | Opera No | Safari 11.1 | WebView Android ≤37 | Chrome Android 18 |
Firefox Android
50
|
Opera Android No | Safari iOS 11.3 | Samsung Internet Android Yes |
removeRecursively
弃用
非标
|
Chrome 8 | Edge 79 |
Firefox
50 — 52
|
IE No | Opera No | Safari No | WebView Android ≤37 | Chrome Android 18 |
Firefox Android
50 — 52
|
Opera Android No | Safari iOS No | Samsung Internet Android Yes |
完整支持
不支持
实验。期望将来行为有所改变。
非标。预期跨浏览器支持较差。
弃用。不要用于新网站。
见实现注意事项。
使用非标名称。
要求使用供应商前缀或不同名称。
FileSystemDirectoryEntry
FileError
FileException
FileHandle
FileRequest
FileSystem
FileSystemDirectoryEntrySync
FileSystemDirectoryReader
FileSystemDirectoryReaderSync
FileSystemEntry
FileSystemEntrySync
FileSystemFileEntry
FileSystemFileEntrySync
FileSystemFlags
FileSystemSync
HTMLInputElement
LocalFileSystem
LocalFileSystemSync
LockedFile
元数据
Window.requestFileSystem()
Window.resolveLocalFileSystemURL()
WorkerGlobalScope.requestFileSystemSync()