1. 開発者向けのウェブ技術
  2. Web API
  3. FileSystemDirectoryEntry

このページはコミュニティーの尽力で英語から翻訳されました。MDN Web Docs コミュニティーについてもっと知り、仲間になるにはこちらから。

View in English Always switch to English

FileSystemDirectoryEntry

FileSystemDirectoryEntryファイルとディレクトリー項目 API のインターフェイスで、ファイルシステム内のディレクトリーを表します。これはディレクトリー内のファイルにアクセスして操作する方法と、ディレクトリー内のエントリーにアクセスする方法を提供します。

FileSystemEntry FileSystemDirectoryEntry

基本概念

getDirectory() を呼び出して新しいディレクトリーを作成することができます。サブディレクトリーを作成する場合は、各子ディレクトリーを順番に作成します。まだ存在しない親ディレクトリーを含むフルパスを使用してディレクトリーを作成しようとすると、エラーが返されます。したがって、親ディレクトリーを作成した後、新しいパスを再帰的に追加して階層を作成します。

次のコードスニペットでは、 "Documents" というディレクトリーを作成します。

js
// ブラウザー固有の接頭辞を取る
window.requestFileSystem =
 window.requestFileSystem || window.webkitRequestFileSystem;
window.directoryEntry = window.directoryEntry || window.webkitDirectoryEntry;
// ...
function onFs(fs) {
 fs.root.getDirectory(
 "Documents",
 { create: true },
 (directoryEntry) => {
 //directoryEntry.isFile === false
 //directoryEntry.isDirectory === true
 //directoryEntry.name === 'Documents'
 //directoryEntry.fullPath === '/Documents'
 },
 onError,
 );
}
// 一時記憶装置でファイルシステムを開く
window.requestFileSystem(TEMPORARY, 1024 * 1024 /*1MB*/, onFs, onError);

プロパティ

このインターフェイスは独自のプロパティを持っていませんが、親インターフェイス FileSystemEntry からプロパティを継承しています。

メソッド

このインターフェイスは、親インターフェイスである FileSystemEntry からメソッドを継承しています。

createReader()

このディレクトリー内のエントリーを読み込むために使用できる FileSystemDirectoryReader オブジェクトを作成します。

getDirectory()

メソッドが呼び出されるディレクトリーを基準に、指定されたパスにあるディレクトリーを表す FileSystemDirectoryEntry オブジェクトを返します。

getFile()

メソッドが呼び出されるディレクトリーに対する相対パスを指定して、ディレクトリーの階層内にあるファイルを表す FileSystemFileEntry オブジェクトを返します。

仕様書

Specification
File and Directory Entries API
# api-directoryentry

ブラウザーの互換性

関連情報

Help improve MDN

Learn how to contribute

This page was last modified on by MDN contributors.

AltStyle によって変換されたページ (->オリジナル) /