1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
|
---
title: File and Directory Entries API
slug: Web/API/File_and_Directory_Entries_API
translation_of: Web/API/File_and_Directory_Entries_API
---
<p>{{DefaultAPISidebar("File System API")}}{{Non-standard_header}}</p>
<p>The File and Directory Entries API는 탐색 및 파일 접근이 가능한 로컬 파일 시스템을 웹상에 시뮬레이션합니다. 이 API를 통해 당신은 읽고, 쓰고, 파일과 디렉토리를 생성할 수 있는 가상의 파일 시스템을 가진 앱을 개발할 수 있을 것입니다.</p>
<div class="note">
<p>이 API는 아직 표준이 아니기 때문에, 모든 브라우저가 이를 지원하지 않는 다는 점을 유념하십시오. 지원하더라도 일부 기능만을 지원할 수도 있습니다. 자세한 내용은 브라우저 호환성({{anch("Browser compatibility")}}) 항목을 참조하십시오.</p>
</div>
<p>동기적 혹은 비동기적인 동작 중 어느 쪽을 필요로 하냐에 따라 만들어진 매우 유사한 두 개의 API가 있습니다. 동기식 API는 {{domxref("Worker")}} 내에서 사용될 수 있도록 확장되어 왔으며 당신이 원하는 값을 반환합니다. 비동기식 API는 브라우저의 동작을 방해하지 않지만 함수와 API가 값을 반환하지 않습니다; 그 대신, 당신은 콜백 함수를 이용해 언제든 응답을 처리할 수 있습니다.</p>
<div class="warning">
<p>Firefox에 내장된 File and Directory Entries API는 매우 제한적입니다; 해당 환경에서는 파일 생성을 사용할 수 없습니다. {{HTMLElement("input")}}이나 ({{domxref("HTMLInputElement")}} 도 확인하십시오) 앱이나 웹사이트에서 드래그 앤 드롭(<a href="/en-US/docs/Web/API/HTML_Drag_and_Drop_API">drag and drop</a>)을 통해 유저가 직접 선택한 파일에만 액세스 가능합니다. 또한 Firefox는 동기식 API 역시 지원하지 않습니다. API의 어떤 부분을 사용하려고 하든 반드시 브라우저 호환성을 확인하시고, Firefox에 대한 이 API의 호환성(<a href="/en-US/docs/Web/API/File_and_Directory_Entries_API/Firefox_support">File and Directory Entries API support in Firefox</a>)을 통해 더 자세하게 알아보도록 하십시오.</p>
</div>
<h2 id="파일_시스템에_접근하기">파일 시스템에 접근하기</h2>
<p>현재로서 정의된 파일 시스템에 대한 접근 방법은 두 가지입니다:</p>
<ul>
<li>드래그 앤 드롭({{event("drop")}}) 이벤트를 제어함으로써, 당신은 {{domxref("DataTransferItem.webkitGetAsEntry()")}} 를 통해{{domxref("FileSystemEntry")}}에 드롭한 파일을 전달할 수 있습니다. 만일 결과가 <code>null</code>이 아니라면, 드롭한 파일 혹은 디렉토리를 파일 시스템에서 사용할 수 있을 것입니다.</li>
<li>{{domxref("HTMLInputElement.webkitEntries")}} 속성은 당신이 {{domxref("FileSystemFileEntry")}} 객체에 현재 선택된 파일을 접근시킬 수 있게 하지만, 파일 선택기(File chooser)로 직접 드래그 앤 드롭한 경우에만 가능합니다. ({{bug(1326031)}}). 만일 {{domxref("HTMLInputElement.webkitdirectory")}}의 값을 <code>true</code>로 두었다면, 디렉토리 선택자(Directory picker) 대신 {{HTMLElement("input")}} 를 사용할 수 있고, 선택된 각 디렉토리에 대해 {{domxref("FileSystemDirectoryEntry")}} 객체로 만들 수 있습니다.</li>
</ul>
<h2 id="비동기식_API">비동기식 API</h2>
<p>파일 시스템 액세스가 메인 스레드에서 사용될 경우 전체 브라우저를 차단하지 않도록 대부분의 작업은 비동기 API를 이용하여야 합니다. 다음과 같은 인터페이스를 포함하고 있습니다:</p>
<dl>
<dt>{{domxref("FileSystem")}}</dt>
<dd>파일 시스템을 나타냅니다.</dd>
<dt>{{domxref("FileSystemEntry")}}</dt>
<dd>파일 시스템의 단일 엔트리를 의미하는 기본적인 인터페이스입니다. 이것은 파일이나 디렉토리 등을 나타내는 다른 인터페이스들에 의해 구현됩니다.</dd>
<dt>{{domxref("FileSystemFileEntry")}}</dt>
<dd>파일 시스템 내의 단일 파일을 나타냅니다.</dd>
<dt>{{domxref("FileSystemDirectoryEntry")}}</dt>
<dd>파일 시스템 내의 단일 디렉토리를 나타냅니다.</dd>
<dt>{{domxref("FileSystemDirectoryReader")}}</dt>
<dd>{{domxref("FileSystemDirectoryEntry.createReader()")}}를 호출함으로써 만들어지는 인터페이스이며, 디렉토리의 내용물을 읽을 수 있는 기능을 제공합니다.</dd>
<dt>{{domxref("FileSystemFlags")}}</dt>
<dd><a href="https://developer.mozilla.org/en-US/docs/Web/API/File_and_Directory_Entries_API">File and Directory Entries API</a>에서 특정 메소드를 호출할 때 옵션 플래그로 사용되는 값들의 집합을 정의합니다.</dd>
<dt>{{DOMxRef("FileError")}} {{Obsolete_Inline}}</dt>
<dd>비동기 파일 시스템 호출에 의해 발생한 에러를 나타냅니다.</dd>
</dl>
<p>또한 두 개의 전역 함수가 있습니다(현재로선 명세화되지 않아 Google Chrome에만 내장되어 있습니다). {{domxref("Window")}} 객체 위에서 사용 가능하며 {{domxref("LocalFileSystem")}}에 구현되어 있습니다: 각각 <code>requestFileSystem()</code> 과 <code>resolveLocalFileSystemURL()</code>.</p>
<h2 id="동기식_API">동기식 API</h2>
<p>동기식 API는 반드시 {{domxref("Worker")}}s 안에서만 사용되어야 합니다; 이 호출들은 그들이 실행이 완료될 때 까지 브라우저의 동작을 멈추며, 콜백을 보내는 대신 단순히 결과값을 반환합니다. 이 함수들을 메인 스레드에서 사용하는 것은 브라우저의 동작을 멈출 것이며, 그것은 너무 난잡한 방식입니다. 아래의 인터페이스들은 비동기식 API와 기능적으로 거의 유사합니다.</p>
<dl>
<dt>{{domxref("FileSystemSync")}}</dt>
<dd>파일 시스템을 나타냅니다.</dd>
<dt>{{domxref("FileSystemEntrySync")}}</dt>
<dd>파일 시스템의 단일 엔트리를 의미하는 기본적인 인터페이스입니다. 이것은 파일이나 디렉토리 등을 나타내는 다른 인터페이스들에 의해 구현됩니다.</dd>
<dt>{{domxref("FileSystemFileEntrySync")}}</dt>
<dd>파일 시스템 내의 단일 파일을 나타냅니다.</dd>
<dt>{{domxref("FileSystemDirectoryEntrySync")}}</dt>
<dd>파일 시스템 내의 단일 디렉토리를 나타냅니다.</dd>
<dt>{{domxref("FileSystemDirectoryReaderSync")}}</dt>
<dd>{{domxref("FileSystemDirectoryEntrySync.createReader()")}}를 호출함으로써 만들어지는 인터페이스이며, 디렉토리의 내용물을 읽을 수 있는 기능을 제공합니다.</dd>
<dt>{{DOMxRef("FileException")}} {{Obsolete_Inline}}</dt>
<dd>동기 파일 시스템 호출에 의해 발생한 에러를 나타냅니다.</dd>
</dl>
<p>또한 두 개의 전역 함수가 있습니다(현재로선 명세화되지 않아 Google Chrome에만 내장되어 있습니다). {{domxref("Worker")}} 객체 위에서 사용 가능하며 {{domxref("LocalFileSystemSync")}}에 구현되어 있습니다: 각각 <code>requestFileSystemSync()</code> 과 <code>resolveLocalFileSystemSyncURL()</code>.</p>
<h2 id="기타_인터페이스">기타 인터페이스</h2>
<dl>
<dt>{{domxref("LocalFileSystem")}}</dt>
<dd>샌드박스 파일 시스템에 접근할 수 있습니다.</dd>
<dt>{{domxref("LocalFileSystemSync")}}</dt>
<dt></dt>
<dt>{{domxref("LockedFile")}}</dt>
<dd>필요한 모든 잠금을 사용하여 주어진 파일을 처리할 수 있는 도구를 제공합니다.</dd>
<dt>{{domxref("Metadata")}}{{experimental_inline}}</dt>
</dl>
<h2 id="명세">명세</h2>
<table class="standard-table">
<thead>
<tr>
<th scope="col">Specification</th>
<th scope="col">Status</th>
<th scope="col">Comment</th>
</tr>
</thead>
<tbody>
<tr>
<td>{{SpecName('File System API')}}</td>
<td>{{Spec2('File System API')}}</td>
<td>API 초안</td>
</tr>
</tbody>
</table>
<p>이 API는 공식 W3C나 WHATWG명세를 가지고 있지 않습니다.</p>
<h2 id="브라우저_호환성">브라우저 호환성</h2>
<div>
<h3 id="FileSystem"><code>FileSystem</code></h3>
<div>
<p>{{Compat("api.FileSystem", 0)}}</p>
<h3 id="FileSystemSync_속성"><code>FileSystemSync</code> 속성</h3>
<div>
<p>{{Compat("api.FileSystemSync", 0)}}</p>
</div>
</div>
</div>
<h2 id="같이_보기">같이 보기</h2>
<ul>
<li>File and Directory Entries API 소개(<a href="/en-US/docs/Web/API/File_and_Directory_Entries_API/Introduction">Introduction to the File and Directory Entries API</a>)</li>
<li>Firefox에 대한 File and Directory Etnries API의 호환성(<a href="/en-US/docs/Web/API/File_and_Directory_Entries_API/Firefox_support">File and Directory Entries API support in Firefox</a>)</li>
</ul>
|