FileSystemHandle:isSameEntry() 方法

Baseline 2023
Newly available

Since March 2023, this feature works across the latest devices and browser versions. This feature might not work in older devices or browsers.

安全上下文: 此项功能仅在一些支持的浏览器安全上下文(HTTPS)中可用。

备注: 此特性在 Web Worker 中可用。

FileSystemHandle 接口的 isSameEntry() 方法用于比对两个句柄以查看两者关联的条目(文件或目录)是否相符。

语法

js
isSameEntry(fileSystemHandle)

参数

FileSystemHandle

需要与调用此方法的句柄进行匹配的 FileSystemHandle

返回值

一个兑现布尔值的 Promise。

示例

以下函数将单个条目与条目数组进行比对,并返回一个 Promise,其会兑现包含不相符条目的新数组。

js
async function removeMatches(fileEntry, entriesArr) {
  const newArr = [];
  for (const entry of entriesArr) {
    if (!(await fileEntry.isSameEntry(entry))) {
      newArr.push(entry);
    }
  }
  return newArr;
}

规范

Specification
File System
# api-filesystemhandle-issameentry

浏览器兼容性

Report problems with this compatibility data on GitHub
desktopmobile
Chrome
Edge
Firefox
Opera
Safari
Chrome Android
Firefox for Android
Opera Android
Safari on iOS
Samsung Internet
WebView Android
WebView on iOS
isSameEntry

Legend

Tip: you can click/tap on a cell for more information.

Full support
Full support
No support
No support

参见