这是
实验性技术
检查
浏览器兼容性表格
要小心谨慎在生产中使用这之前。
FileSystemDirectoryEntry
接口方法
createReader
()
返回
FileSystemDirectoryReader
object which can be used to read the entries in the directory.
directoryReader = FileSystemDirectoryEntry.createReader();
None.
A
FileSystemDirectoryReader
object which can be used to read the directory's entries.
This example creates a method called
readDirectory()
, which fetches all of the entries in the specified
FileSystemDirectoryEntry
and returns them in an array.
function readDirectory(directory) {
let dirReader = directory.createReader();
let entries = [];
let getEntries = function() {
dirReader.readEntries(function(results) {
if (results.length) {
entries = entries.concat(toArray(results));
getEntries();
}
}, function(error) {
/* handle error -- error is a FileError object */
});
};
getEntries();
return entries;
}
This works by creating an internal function,
getEntries()
, which calls itself recursively to get all the entries in the directory, concatenating each batch to the array. Each iteration,
readEntries()
is called to get more entries. When it returns an empty array, the end of the directory has beenr reached, and the recursion ends. Once control is returned to
readDirectory()
, the array is returned to the caller.
| 规范 | 状态 | 注释 |
|---|---|---|
|
文件和目录条目 API
The definition of 'createReader()' in that specification. |
草案 | 最初的规范。 |
| 桌面 | 移动 | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
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 |
完整支持
不支持
实验。期望将来行为有所改变。
FileSystemDirectoryReader
FileSystemDirectoryEntry
FileSystemFileEntry
FileSystemEntry
FileSystemDirectoryEntry
createReader()
getDirectory()
getFile()
removeRecursively()
FileError
FileException
FileHandle
FileRequest
FileSystem
FileSystemDirectoryEntrySync
FileSystemDirectoryReader
FileSystemDirectoryReaderSync
FileSystemEntry
FileSystemEntrySync
FileSystemFileEntry
FileSystemFileEntrySync
FileSystemFlags
FileSystemSync
HTMLInputElement
LocalFileSystem
LocalFileSystemSync
LockedFile
元数据
Window.requestFileSystem()
Window.resolveLocalFileSystemURL()
WorkerGlobalScope.requestFileSystemSync()