FileSystemDirectoryHandle.removeEntry()

Limited availability

This feature is not Baseline because it does not work in some of the most widely-used browsers.

安全なコンテキスト用: この機能は一部またはすべての対応しているブラウザーにおいて、安全なコンテキスト (HTTPS) でのみ利用できます。

FileSystemDirectoryHandle インターフェイスの removeEntry() メソッドは、指定の名前のファイルまたはディレクトリーがディレクトリーハンドル内に存在する場合、エントリーを削除しようとします。

構文

js
removeEntry(name)
removeEntry(name, options)

引数

name

削除したいエントリーの FileSystemHandle.name を表す文字列です。

options 省略可

オプションを持つオブジェクトで、省略可能です。以下のオプションがあります。

recursive

boolean 値で、デフォルトは false です。true に設定すると、エントリーが再帰的に削除されます。

返値

undefined で解決する Promise を返します。

例外

TypeError

名前が有効な文字列ではないか、ファイルシステムで許可されていない文字を含むとき投げられます。

NotAllowedError DOMException

PermissionStatus'granted' でないとき投げられます。

InvalidModificationError DOMException

recursivefalse に設定されており、削除するエントリーが子を持つとき投げられます。

NotFoundError DOMException

エントリー名が見つからないか一致しないとき投げられます。

以下の例では、ディレクトリーハンドル内のエントリーを削除します。

js
const entryName = "entryToRemove";

// ディレクトリーハンドル 'currentDirHandle' があると仮定
currentDirHandle.removeEntry(entryName).then(() => {
  // 削除に成功したとき実行するコード
});

仕様書

Specification
File System Standard
# api-filesystemdirectoryhandle-removeentry

ブラウザーの互換性

BCD tables only load in the browser

関連情報