@doubao-apps/create 0.0.30 → 0.0.31
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/template-empty/AGENTS.md +12 -0
- package/dist/template-empty/package.json +2 -2
- package/dist/template-empty/references/reference/open-api/09-/345/274/200/346/224/276/350/203/275/345/212/233-/344/270/232/345/212/241/350/203/275/345/212/233.md +309 -0
- package/dist/template-empty/references/reference/open-api/12-/350/256/276/345/244/207-wi-fi.md +38 -4
- package/dist/template-empty/references/reference/open-api/31-/346/226/207/344/273/266/347/263/273/347/273/237.md +1043 -0
- package/dist/template-empty/references/reference/open-api/README.md +3 -2
- package/dist/template-empty/references/reference/open-api.md +1487 -67
- package/dist/template-starter/AGENTS.md +12 -0
- package/dist/template-starter/package.json +2 -2
- package/dist/template-starter/references/reference/open-api/09-/345/274/200/346/224/276/350/203/275/345/212/233-/344/270/232/345/212/241/350/203/275/345/212/233.md +309 -0
- package/dist/template-starter/references/reference/open-api/12-/350/256/276/345/244/207-wi-fi.md +38 -4
- package/dist/template-starter/references/reference/open-api/31-/346/226/207/344/273/266/347/263/273/347/273/237.md +1043 -0
- package/dist/template-starter/references/reference/open-api/README.md +3 -2
- package/dist/template-starter/references/reference/open-api.md +1487 -67
- package/package.json +1 -1
|
@@ -0,0 +1,1043 @@
|
|
|
1
|
+
# Open API: 文件系统
|
|
2
|
+
|
|
3
|
+
文件读写、目录管理和文件信息操作。
|
|
4
|
+
|
|
5
|
+
[返回目录](./README.md) | [返回速查](../open-api.md)
|
|
6
|
+
|
|
7
|
+
## 速查
|
|
8
|
+
|
|
9
|
+
| API | 说明 |
|
|
10
|
+
| --- | --- |
|
|
11
|
+
| [getFileSystemManager](#getfilesystemmanager) | 获取文件系统管理器。 |
|
|
12
|
+
|
|
13
|
+
## API 详情
|
|
14
|
+
|
|
15
|
+
<a id="getfilesystemmanager"></a>
|
|
16
|
+
### getFileSystemManager()
|
|
17
|
+
|
|
18
|
+
> **getFileSystemManager**(): [`FileSystemManager`](#filesystemmanager)
|
|
19
|
+
|
|
20
|
+
获取文件系统管理器
|
|
21
|
+
|
|
22
|
+
#### Returns
|
|
23
|
+
|
|
24
|
+
[`FileSystemManager`](#filesystemmanager)
|
|
25
|
+
|
|
26
|
+
## 相关类型
|
|
27
|
+
|
|
28
|
+
<a id="filesystemmanager"></a>
|
|
29
|
+
<a id="access"></a>
|
|
30
|
+
<a id="appendfile"></a>
|
|
31
|
+
<a id="copyfile"></a>
|
|
32
|
+
<a id="savefile"></a>
|
|
33
|
+
<a id="getfileinfo"></a>
|
|
34
|
+
<a id="getsavedfilelist"></a>
|
|
35
|
+
<a id="mkdir"></a>
|
|
36
|
+
<a id="readfile"></a>
|
|
37
|
+
<a id="readdir"></a>
|
|
38
|
+
<a id="removesavedfile"></a>
|
|
39
|
+
<a id="rename"></a>
|
|
40
|
+
<a id="rmdir"></a>
|
|
41
|
+
<a id="stat"></a>
|
|
42
|
+
<a id="truncate"></a>
|
|
43
|
+
<a id="unlink"></a>
|
|
44
|
+
<a id="unzip"></a>
|
|
45
|
+
<a id="writefile"></a>
|
|
46
|
+
### FileSystemManager
|
|
47
|
+
|
|
48
|
+
文件系统管理器,提供对本地文件系统的完整读写能力。
|
|
49
|
+
|
|
50
|
+
通过 [getFileSystemManager](#getfilesystemmanager) 获取实例后,可使用该接口上的方法执行文件和目录操作。
|
|
51
|
+
大多数方法同时提供异步(返回 `Promise`)和同步(`Sync` 后缀)两种调用方式。
|
|
52
|
+
|
|
53
|
+
#### Remarks
|
|
54
|
+
|
|
55
|
+
- 所有路径参数均为本地文件路径,不支持网络路径。
|
|
56
|
+
- 同步方法会阻塞当前 JS 线程直到操作完成;对于大文件操作建议使用异步方法以避免卡顿。
|
|
57
|
+
- 文件操作失败时(如路径不存在、权限不足),Promise 会被 reject 或同步方法会抛出异常。
|
|
58
|
+
|
|
59
|
+
#### Methods
|
|
60
|
+
|
|
61
|
+
##### access()
|
|
62
|
+
|
|
63
|
+
> **access**(`params`): `Promise`\<`void`\>
|
|
64
|
+
|
|
65
|
+
判断文件或目录是否存在(异步)。
|
|
66
|
+
|
|
67
|
+
路径存在时 Promise resolve;路径不存在时 Promise reject。
|
|
68
|
+
|
|
69
|
+
###### Parameters
|
|
70
|
+
|
|
71
|
+
• **params**: [`AccessParams`](#accessparams)
|
|
72
|
+
|
|
73
|
+
参见 [AccessParams](#accessparams)。
|
|
74
|
+
|
|
75
|
+
###### Returns
|
|
76
|
+
|
|
77
|
+
`Promise`\<`void`\>
|
|
78
|
+
|
|
79
|
+
##### accessSync()
|
|
80
|
+
|
|
81
|
+
> **accessSync**(`params`): `void`
|
|
82
|
+
|
|
83
|
+
判断文件或目录是否存在(同步)。
|
|
84
|
+
|
|
85
|
+
路径不存在时会抛出异常。
|
|
86
|
+
|
|
87
|
+
###### Parameters
|
|
88
|
+
|
|
89
|
+
• **params**: [`AccessParams`](#accessparams)
|
|
90
|
+
|
|
91
|
+
参见 [AccessParams](#accessparams)。
|
|
92
|
+
|
|
93
|
+
###### Returns
|
|
94
|
+
|
|
95
|
+
`void`
|
|
96
|
+
|
|
97
|
+
##### appendFile()
|
|
98
|
+
|
|
99
|
+
> **appendFile**(`params`): `Promise`\<`void`\>
|
|
100
|
+
|
|
101
|
+
在文件末尾追加内容(异步)。如果文件不存在则创建。
|
|
102
|
+
|
|
103
|
+
###### Parameters
|
|
104
|
+
|
|
105
|
+
• **params**: [`AppendFileParams`](#appendfileparams)
|
|
106
|
+
|
|
107
|
+
追加参数,参见 [AppendFileParams](#appendfileparams)。
|
|
108
|
+
|
|
109
|
+
###### Returns
|
|
110
|
+
|
|
111
|
+
`Promise`\<`void`\>
|
|
112
|
+
|
|
113
|
+
##### appendFileSync()
|
|
114
|
+
|
|
115
|
+
> **appendFileSync**(`params`): `void`
|
|
116
|
+
|
|
117
|
+
在文件末尾追加内容(同步)。如果文件不存在则创建。
|
|
118
|
+
|
|
119
|
+
###### Parameters
|
|
120
|
+
|
|
121
|
+
• **params**: [`AppendFileParams`](#appendfileparams)
|
|
122
|
+
|
|
123
|
+
追加参数,参见 [AppendFileParams](#appendfileparams)。
|
|
124
|
+
|
|
125
|
+
###### Returns
|
|
126
|
+
|
|
127
|
+
`void`
|
|
128
|
+
|
|
129
|
+
##### copyFile()
|
|
130
|
+
|
|
131
|
+
> **copyFile**(`params`): `Promise`\<`void`\>
|
|
132
|
+
|
|
133
|
+
复制文件(异步)。不支持复制目录。
|
|
134
|
+
|
|
135
|
+
###### Parameters
|
|
136
|
+
|
|
137
|
+
• **params**: [`CopyFileParams`](#copyfileparams)
|
|
138
|
+
|
|
139
|
+
参见 [CopyFileParams](#copyfileparams)。
|
|
140
|
+
|
|
141
|
+
###### Returns
|
|
142
|
+
|
|
143
|
+
`Promise`\<`void`\>
|
|
144
|
+
|
|
145
|
+
##### copyFileSync()
|
|
146
|
+
|
|
147
|
+
> **copyFileSync**(`params`): `void`
|
|
148
|
+
|
|
149
|
+
复制文件(同步)。不支持复制目录。
|
|
150
|
+
|
|
151
|
+
###### Parameters
|
|
152
|
+
|
|
153
|
+
• **params**: [`CopyFileParams`](#copyfileparams)
|
|
154
|
+
|
|
155
|
+
参见 [CopyFileParams](#copyfileparams)。
|
|
156
|
+
|
|
157
|
+
###### Returns
|
|
158
|
+
|
|
159
|
+
`void`
|
|
160
|
+
|
|
161
|
+
##### getFileInfo()
|
|
162
|
+
|
|
163
|
+
> **getFileInfo**(`params`): `Promise`\<[`GetFileInfoResult`](#getfileinforesult)\>
|
|
164
|
+
|
|
165
|
+
获取文件信息,可选计算文件摘要(异步)。
|
|
166
|
+
|
|
167
|
+
###### Parameters
|
|
168
|
+
|
|
169
|
+
• **params**: [`GetFileInfoParams`](#getfileinfoparams)
|
|
170
|
+
|
|
171
|
+
参见 [GetFileInfoParams](#getfileinfoparams)。
|
|
172
|
+
|
|
173
|
+
###### Returns
|
|
174
|
+
|
|
175
|
+
`Promise`\<[`GetFileInfoResult`](#getfileinforesult)\>
|
|
176
|
+
|
|
177
|
+
返回一个 Promise,解析为 [GetFileInfoResult](#getfileinforesult)。
|
|
178
|
+
|
|
179
|
+
##### getSavedFileList()
|
|
180
|
+
|
|
181
|
+
> **getSavedFileList**(): `Promise`\<[`GetSavedFileListResult`](#getsavedfilelistresult)\>
|
|
182
|
+
|
|
183
|
+
获取已保存的本地文件列表(异步)。
|
|
184
|
+
|
|
185
|
+
###### Returns
|
|
186
|
+
|
|
187
|
+
`Promise`\<[`GetSavedFileListResult`](#getsavedfilelistresult)\>
|
|
188
|
+
|
|
189
|
+
返回一个 Promise,解析为 [GetSavedFileListResult](#getsavedfilelistresult)。
|
|
190
|
+
|
|
191
|
+
##### mkdir()
|
|
192
|
+
|
|
193
|
+
> **mkdir**(`params`): `Promise`\<`void`\>
|
|
194
|
+
|
|
195
|
+
创建目录(异步)。
|
|
196
|
+
|
|
197
|
+
###### Parameters
|
|
198
|
+
|
|
199
|
+
• **params**: [`MkdirParams`](#mkdirparams)
|
|
200
|
+
|
|
201
|
+
参见 [MkdirParams](#mkdirparams)。
|
|
202
|
+
|
|
203
|
+
###### Returns
|
|
204
|
+
|
|
205
|
+
`Promise`\<`void`\>
|
|
206
|
+
|
|
207
|
+
##### mkdirSync()
|
|
208
|
+
|
|
209
|
+
> **mkdirSync**(`params`): `void`
|
|
210
|
+
|
|
211
|
+
创建目录(同步)。
|
|
212
|
+
|
|
213
|
+
###### Parameters
|
|
214
|
+
|
|
215
|
+
• **params**: [`MkdirParams`](#mkdirparams)
|
|
216
|
+
|
|
217
|
+
参见 [MkdirParams](#mkdirparams)。
|
|
218
|
+
|
|
219
|
+
###### Returns
|
|
220
|
+
|
|
221
|
+
`void`
|
|
222
|
+
|
|
223
|
+
##### readFile()
|
|
224
|
+
|
|
225
|
+
> **readFile**(`params`): `Promise`\<[`ReadFileResult`](#readfileresult)\>
|
|
226
|
+
|
|
227
|
+
读取文件内容(异步)。
|
|
228
|
+
|
|
229
|
+
###### Parameters
|
|
230
|
+
|
|
231
|
+
• **params**: [`ReadFileParams`](#readfileparams)
|
|
232
|
+
|
|
233
|
+
读取参数,参见 [ReadFileParams](#readfileparams)。
|
|
234
|
+
|
|
235
|
+
###### Returns
|
|
236
|
+
|
|
237
|
+
`Promise`\<[`ReadFileResult`](#readfileresult)\>
|
|
238
|
+
|
|
239
|
+
返回一个 Promise,解析为 [ReadFileResult](#readfileresult)。
|
|
240
|
+
|
|
241
|
+
##### readFileSync()
|
|
242
|
+
|
|
243
|
+
> **readFileSync**(`params`): [`ReadFileResult`](#readfileresult)
|
|
244
|
+
|
|
245
|
+
读取文件内容(同步)。
|
|
246
|
+
|
|
247
|
+
###### Parameters
|
|
248
|
+
|
|
249
|
+
• **params**: [`ReadFileParams`](#readfileparams)
|
|
250
|
+
|
|
251
|
+
读取参数,参见 [ReadFileParams](#readfileparams)。
|
|
252
|
+
|
|
253
|
+
###### Returns
|
|
254
|
+
|
|
255
|
+
[`ReadFileResult`](#readfileresult)
|
|
256
|
+
|
|
257
|
+
返回 [ReadFileResult](#readfileresult)。
|
|
258
|
+
|
|
259
|
+
##### readdir()
|
|
260
|
+
|
|
261
|
+
> **readdir**(`params`): `Promise`\<[`ReaddirResult`](#readdirresult)\>
|
|
262
|
+
|
|
263
|
+
读取目录下的文件和子目录列表(异步)。
|
|
264
|
+
|
|
265
|
+
###### Parameters
|
|
266
|
+
|
|
267
|
+
• **params**: [`ReaddirParams`](#readdirparams)
|
|
268
|
+
|
|
269
|
+
参见 [ReaddirParams](#readdirparams)。
|
|
270
|
+
|
|
271
|
+
###### Returns
|
|
272
|
+
|
|
273
|
+
`Promise`\<[`ReaddirResult`](#readdirresult)\>
|
|
274
|
+
|
|
275
|
+
返回一个 Promise,解析为 [ReaddirResult](#readdirresult)。
|
|
276
|
+
|
|
277
|
+
##### readdirSync()
|
|
278
|
+
|
|
279
|
+
> **readdirSync**(`params`): [`ReaddirResult`](#readdirresult)
|
|
280
|
+
|
|
281
|
+
读取目录下的文件和子目录列表(同步)。
|
|
282
|
+
|
|
283
|
+
###### Parameters
|
|
284
|
+
|
|
285
|
+
• **params**: [`ReaddirParams`](#readdirparams)
|
|
286
|
+
|
|
287
|
+
参见 [ReaddirParams](#readdirparams)。
|
|
288
|
+
|
|
289
|
+
###### Returns
|
|
290
|
+
|
|
291
|
+
[`ReaddirResult`](#readdirresult)
|
|
292
|
+
|
|
293
|
+
返回 [ReaddirResult](#readdirresult)。
|
|
294
|
+
|
|
295
|
+
##### removeSavedFile()
|
|
296
|
+
|
|
297
|
+
> **removeSavedFile**(`params`): `Promise`\<`void`\>
|
|
298
|
+
|
|
299
|
+
删除通过 [FileSystemManager.saveFile](#savefile) 保存的本地文件(异步)。
|
|
300
|
+
|
|
301
|
+
###### Parameters
|
|
302
|
+
|
|
303
|
+
• **params**: [`RemoveSavedFileParams`](#removesavedfileparams)
|
|
304
|
+
|
|
305
|
+
参见 [RemoveSavedFileParams](#removesavedfileparams)。
|
|
306
|
+
|
|
307
|
+
###### Returns
|
|
308
|
+
|
|
309
|
+
`Promise`\<`void`\>
|
|
310
|
+
|
|
311
|
+
##### rename()
|
|
312
|
+
|
|
313
|
+
> **rename**(`params`): `Promise`\<`void`\>
|
|
314
|
+
|
|
315
|
+
重命名或移动文件(异步)。
|
|
316
|
+
|
|
317
|
+
###### Parameters
|
|
318
|
+
|
|
319
|
+
• **params**: [`RenameParams`](#renameparams)
|
|
320
|
+
|
|
321
|
+
参见 [RenameParams](#renameparams)。
|
|
322
|
+
|
|
323
|
+
###### Returns
|
|
324
|
+
|
|
325
|
+
`Promise`\<`void`\>
|
|
326
|
+
|
|
327
|
+
##### renameSync()
|
|
328
|
+
|
|
329
|
+
> **renameSync**(`params`): `void`
|
|
330
|
+
|
|
331
|
+
重命名或移动文件(同步)。
|
|
332
|
+
|
|
333
|
+
###### Parameters
|
|
334
|
+
|
|
335
|
+
• **params**: [`RenameParams`](#renameparams)
|
|
336
|
+
|
|
337
|
+
参见 [RenameParams](#renameparams)。
|
|
338
|
+
|
|
339
|
+
###### Returns
|
|
340
|
+
|
|
341
|
+
`void`
|
|
342
|
+
|
|
343
|
+
##### rmdir()
|
|
344
|
+
|
|
345
|
+
> **rmdir**(`params`): `Promise`\<`void`\>
|
|
346
|
+
|
|
347
|
+
删除目录(异步)。
|
|
348
|
+
|
|
349
|
+
###### Parameters
|
|
350
|
+
|
|
351
|
+
• **params**: [`RmdirParams`](#rmdirparams)
|
|
352
|
+
|
|
353
|
+
参见 [RmdirParams](#rmdirparams)。
|
|
354
|
+
|
|
355
|
+
###### Returns
|
|
356
|
+
|
|
357
|
+
`Promise`\<`void`\>
|
|
358
|
+
|
|
359
|
+
##### rmdirSync()
|
|
360
|
+
|
|
361
|
+
> **rmdirSync**(`params`): `void`
|
|
362
|
+
|
|
363
|
+
删除目录(同步)。
|
|
364
|
+
|
|
365
|
+
###### Parameters
|
|
366
|
+
|
|
367
|
+
• **params**: [`RmdirParams`](#rmdirparams)
|
|
368
|
+
|
|
369
|
+
参见 [RmdirParams](#rmdirparams)。
|
|
370
|
+
|
|
371
|
+
###### Returns
|
|
372
|
+
|
|
373
|
+
`void`
|
|
374
|
+
|
|
375
|
+
##### saveFile()
|
|
376
|
+
|
|
377
|
+
> **saveFile**(`params`): `Promise`\<[`SaveFileResult`](#savefileresult)\>
|
|
378
|
+
|
|
379
|
+
将临时文件保存到本地持久化存储(异步)。
|
|
380
|
+
|
|
381
|
+
###### Parameters
|
|
382
|
+
|
|
383
|
+
• **params**: [`SaveFileParams`](#savefileparams)
|
|
384
|
+
|
|
385
|
+
参见 [SaveFileParams](#savefileparams)。
|
|
386
|
+
|
|
387
|
+
###### Returns
|
|
388
|
+
|
|
389
|
+
`Promise`\<[`SaveFileResult`](#savefileresult)\>
|
|
390
|
+
|
|
391
|
+
返回一个 Promise,解析为 [SaveFileResult](#savefileresult)。
|
|
392
|
+
|
|
393
|
+
##### saveFileSync()
|
|
394
|
+
|
|
395
|
+
> **saveFileSync**(`params`): [`SaveFileResult`](#savefileresult)
|
|
396
|
+
|
|
397
|
+
将临时文件保存到本地持久化存储(同步)。
|
|
398
|
+
|
|
399
|
+
###### Parameters
|
|
400
|
+
|
|
401
|
+
• **params**: [`SaveFileParams`](#savefileparams)
|
|
402
|
+
|
|
403
|
+
参见 [SaveFileParams](#savefileparams)。
|
|
404
|
+
|
|
405
|
+
###### Returns
|
|
406
|
+
|
|
407
|
+
[`SaveFileResult`](#savefileresult)
|
|
408
|
+
|
|
409
|
+
返回 [SaveFileResult](#savefileresult)。
|
|
410
|
+
|
|
411
|
+
##### stat()
|
|
412
|
+
|
|
413
|
+
> **stat**(`params`): `Promise`\<[`StatResult`](#statresult)\>
|
|
414
|
+
|
|
415
|
+
获取文件或目录的状态信息(异步)。
|
|
416
|
+
|
|
417
|
+
###### Parameters
|
|
418
|
+
|
|
419
|
+
• **params**: [`StatParams`](#statparams)
|
|
420
|
+
|
|
421
|
+
参见 [StatParams](#statparams)。
|
|
422
|
+
|
|
423
|
+
###### Returns
|
|
424
|
+
|
|
425
|
+
`Promise`\<[`StatResult`](#statresult)\>
|
|
426
|
+
|
|
427
|
+
返回一个 Promise,解析为 [StatResult](#statresult)。
|
|
428
|
+
|
|
429
|
+
##### statSync()
|
|
430
|
+
|
|
431
|
+
> **statSync**(`params`): [`StatResult`](#statresult)
|
|
432
|
+
|
|
433
|
+
获取文件或目录的状态信息(同步)。
|
|
434
|
+
|
|
435
|
+
###### Parameters
|
|
436
|
+
|
|
437
|
+
• **params**: [`StatParams`](#statparams)
|
|
438
|
+
|
|
439
|
+
参见 [StatParams](#statparams)。
|
|
440
|
+
|
|
441
|
+
###### Returns
|
|
442
|
+
|
|
443
|
+
[`StatResult`](#statresult)
|
|
444
|
+
|
|
445
|
+
返回 [StatResult](#statresult)。
|
|
446
|
+
|
|
447
|
+
##### truncate()
|
|
448
|
+
|
|
449
|
+
> **truncate**(`params`): `Promise`\<`void`\>
|
|
450
|
+
|
|
451
|
+
截断文件到指定长度(异步)。
|
|
452
|
+
|
|
453
|
+
###### Parameters
|
|
454
|
+
|
|
455
|
+
• **params**: [`TruncateParams`](#truncateparams)
|
|
456
|
+
|
|
457
|
+
参见 [TruncateParams](#truncateparams)。
|
|
458
|
+
|
|
459
|
+
###### Returns
|
|
460
|
+
|
|
461
|
+
`Promise`\<`void`\>
|
|
462
|
+
|
|
463
|
+
##### truncateSync()
|
|
464
|
+
|
|
465
|
+
> **truncateSync**(`params`): `void`
|
|
466
|
+
|
|
467
|
+
截断文件到指定长度(同步)。
|
|
468
|
+
|
|
469
|
+
###### Parameters
|
|
470
|
+
|
|
471
|
+
• **params**: [`TruncateParams`](#truncateparams)
|
|
472
|
+
|
|
473
|
+
参见 [TruncateParams](#truncateparams)。
|
|
474
|
+
|
|
475
|
+
###### Returns
|
|
476
|
+
|
|
477
|
+
`void`
|
|
478
|
+
|
|
479
|
+
##### unlink()
|
|
480
|
+
|
|
481
|
+
> **unlink**(`params`): `Promise`\<`void`\>
|
|
482
|
+
|
|
483
|
+
删除文件(异步)。不能用于删除目录。
|
|
484
|
+
|
|
485
|
+
###### Parameters
|
|
486
|
+
|
|
487
|
+
• **params**: [`UnlinkParams`](#unlinkparams)
|
|
488
|
+
|
|
489
|
+
参见 [UnlinkParams](#unlinkparams)。
|
|
490
|
+
|
|
491
|
+
###### Returns
|
|
492
|
+
|
|
493
|
+
`Promise`\<`void`\>
|
|
494
|
+
|
|
495
|
+
##### unlinkSync()
|
|
496
|
+
|
|
497
|
+
> **unlinkSync**(`params`): `void`
|
|
498
|
+
|
|
499
|
+
删除文件(同步)。不能用于删除目录。
|
|
500
|
+
|
|
501
|
+
###### Parameters
|
|
502
|
+
|
|
503
|
+
• **params**: [`UnlinkParams`](#unlinkparams)
|
|
504
|
+
|
|
505
|
+
参见 [UnlinkParams](#unlinkparams)。
|
|
506
|
+
|
|
507
|
+
###### Returns
|
|
508
|
+
|
|
509
|
+
`void`
|
|
510
|
+
|
|
511
|
+
##### unzip()
|
|
512
|
+
|
|
513
|
+
> **unzip**(`params`): `Promise`\<`void`\>
|
|
514
|
+
|
|
515
|
+
解压 zip 文件到指定目录(异步)。
|
|
516
|
+
|
|
517
|
+
###### Parameters
|
|
518
|
+
|
|
519
|
+
• **params**: [`UnzipParams`](#unzipparams)
|
|
520
|
+
|
|
521
|
+
参见 [UnzipParams](#unzipparams)。
|
|
522
|
+
|
|
523
|
+
###### Returns
|
|
524
|
+
|
|
525
|
+
`Promise`\<`void`\>
|
|
526
|
+
|
|
527
|
+
##### writeFile()
|
|
528
|
+
|
|
529
|
+
> **writeFile**(`params`): `Promise`\<`void`\>
|
|
530
|
+
|
|
531
|
+
写入文件内容(异步)。如果文件不存在则创建,已存在则覆盖。
|
|
532
|
+
|
|
533
|
+
###### Parameters
|
|
534
|
+
|
|
535
|
+
• **params**: [`WriteFileParams`](#writefileparams)
|
|
536
|
+
|
|
537
|
+
写入参数,参见 [WriteFileParams](#writefileparams)。
|
|
538
|
+
|
|
539
|
+
###### Returns
|
|
540
|
+
|
|
541
|
+
`Promise`\<`void`\>
|
|
542
|
+
|
|
543
|
+
##### writeFileSync()
|
|
544
|
+
|
|
545
|
+
> **writeFileSync**(`params`): `void`
|
|
546
|
+
|
|
547
|
+
写入文件内容(同步)。如果文件不存在则创建,已存在则覆盖。
|
|
548
|
+
|
|
549
|
+
###### Parameters
|
|
550
|
+
|
|
551
|
+
• **params**: [`WriteFileParams`](#writefileparams)
|
|
552
|
+
|
|
553
|
+
写入参数,参见 [WriteFileParams](#writefileparams)。
|
|
554
|
+
|
|
555
|
+
###### Returns
|
|
556
|
+
|
|
557
|
+
`void`
|
|
558
|
+
|
|
559
|
+
<a id="accessparams"></a>
|
|
560
|
+
### AccessParams
|
|
561
|
+
|
|
562
|
+
[FileSystemManager.access](#access) 的参数。
|
|
563
|
+
|
|
564
|
+
#### Properties
|
|
565
|
+
|
|
566
|
+
##### path
|
|
567
|
+
|
|
568
|
+
> **path**: `string`
|
|
569
|
+
|
|
570
|
+
要判断是否存在的文件或目录路径。
|
|
571
|
+
|
|
572
|
+
<a id="appendfileparams"></a>
|
|
573
|
+
### AppendFileParams
|
|
574
|
+
|
|
575
|
+
[FileSystemManager.appendFile](#appendfile) 的参数。
|
|
576
|
+
|
|
577
|
+
#### Remarks
|
|
578
|
+
|
|
579
|
+
- 如果文件不存在会自动创建。
|
|
580
|
+
- 与 [WriteFileParams](#writefileparams) 不同,追加写入不会覆盖文件已有内容,而是在末尾追加。
|
|
581
|
+
|
|
582
|
+
#### Properties
|
|
583
|
+
|
|
584
|
+
##### data
|
|
585
|
+
|
|
586
|
+
> **data**: `string`
|
|
587
|
+
|
|
588
|
+
要追加的内容。
|
|
589
|
+
|
|
590
|
+
- 当 `encoding` 为 `'utf-8'` 时,直接追加该字符串;
|
|
591
|
+
- 当 `encoding` 为 `'base64'` 时,将该字符串先进行 Base64 解码再追加到文件末尾。
|
|
592
|
+
|
|
593
|
+
##### encoding?
|
|
594
|
+
|
|
595
|
+
> `optional` **encoding**: `"base64"` \| `"utf-8"`
|
|
596
|
+
|
|
597
|
+
指定写入文件的字符编码。
|
|
598
|
+
|
|
599
|
+
###### Default
|
|
600
|
+
|
|
601
|
+
```ts
|
|
602
|
+
'utf-8'
|
|
603
|
+
```
|
|
604
|
+
|
|
605
|
+
##### filePath
|
|
606
|
+
|
|
607
|
+
> **filePath**: `string`
|
|
608
|
+
|
|
609
|
+
要追加内容的文件路径(本地路径)。
|
|
610
|
+
|
|
611
|
+
<a id="copyfileparams"></a>
|
|
612
|
+
### CopyFileParams
|
|
613
|
+
|
|
614
|
+
[FileSystemManager.copyFile](#copyfile) 的参数。
|
|
615
|
+
|
|
616
|
+
#### Remarks
|
|
617
|
+
|
|
618
|
+
- 不支持复制目录,仅支持复制文件。
|
|
619
|
+
- 如果目标路径已存在同名文件,会被覆盖。
|
|
620
|
+
|
|
621
|
+
#### Properties
|
|
622
|
+
|
|
623
|
+
##### destPath
|
|
624
|
+
|
|
625
|
+
> **destPath**: `string`
|
|
626
|
+
|
|
627
|
+
目标文件路径(复制后生成的文件)。
|
|
628
|
+
|
|
629
|
+
##### srcPath
|
|
630
|
+
|
|
631
|
+
> **srcPath**: `string`
|
|
632
|
+
|
|
633
|
+
源文件路径(被复制的文件)。
|
|
634
|
+
|
|
635
|
+
<a id="getfileinfoparams"></a>
|
|
636
|
+
<a id="digestalgorithm"></a>
|
|
637
|
+
### GetFileInfoParams
|
|
638
|
+
|
|
639
|
+
[FileSystemManager.getFileInfo](#getfileinfo) 的参数。
|
|
640
|
+
|
|
641
|
+
#### Properties
|
|
642
|
+
|
|
643
|
+
##### digestAlgorithm?
|
|
644
|
+
|
|
645
|
+
> `optional` **digestAlgorithm**: `"md5"` \| `"sha1"`
|
|
646
|
+
|
|
647
|
+
用于计算文件摘要的哈希算法。
|
|
648
|
+
|
|
649
|
+
- `'md5'`:使用 MD5 算法计算文件摘要。
|
|
650
|
+
- `'sha1'`:使用 SHA-1 算法计算文件摘要。
|
|
651
|
+
|
|
652
|
+
不传时不计算摘要,返回结果中 [GetFileInfoResult.digest](#digest) 为 `undefined`。
|
|
653
|
+
|
|
654
|
+
##### filePath
|
|
655
|
+
|
|
656
|
+
> **filePath**: `string`
|
|
657
|
+
|
|
658
|
+
要获取信息的文件路径。
|
|
659
|
+
|
|
660
|
+
<a id="getfileinforesult"></a>
|
|
661
|
+
<a id="digest"></a>
|
|
662
|
+
### GetFileInfoResult
|
|
663
|
+
|
|
664
|
+
[FileSystemManager.getFileInfo](#getfileinfo) 的返回结果。
|
|
665
|
+
|
|
666
|
+
#### Properties
|
|
667
|
+
|
|
668
|
+
##### digest?
|
|
669
|
+
|
|
670
|
+
> `optional` **digest**: `string`
|
|
671
|
+
|
|
672
|
+
按照 [GetFileInfoParams.digestAlgorithm](#digestalgorithm) 计算得到的文件摘要(十六进制字符串)。
|
|
673
|
+
|
|
674
|
+
仅当请求时指定了 `digestAlgorithm` 才会返回。
|
|
675
|
+
|
|
676
|
+
##### size
|
|
677
|
+
|
|
678
|
+
> **size**: `number`
|
|
679
|
+
|
|
680
|
+
文件大小,单位为字节(Byte)。
|
|
681
|
+
|
|
682
|
+
<a id="getsavedfilelistresult"></a>
|
|
683
|
+
### GetSavedFileListResult
|
|
684
|
+
|
|
685
|
+
[FileSystemManager.getSavedFileList](#getsavedfilelist) 的返回结果。
|
|
686
|
+
|
|
687
|
+
#### Properties
|
|
688
|
+
|
|
689
|
+
##### fileList
|
|
690
|
+
|
|
691
|
+
> **fileList**: `object`[]
|
|
692
|
+
|
|
693
|
+
已保存的本地文件列表,每项包含文件路径、大小和创建时间。
|
|
694
|
+
|
|
695
|
+
<a id="mkdirparams"></a>
|
|
696
|
+
### MkdirParams
|
|
697
|
+
|
|
698
|
+
[FileSystemManager.mkdir](#mkdir) 的参数。
|
|
699
|
+
|
|
700
|
+
#### Properties
|
|
701
|
+
|
|
702
|
+
##### dirPath
|
|
703
|
+
|
|
704
|
+
> **dirPath**: `string`
|
|
705
|
+
|
|
706
|
+
要创建的目录路径。
|
|
707
|
+
|
|
708
|
+
##### recursive?
|
|
709
|
+
|
|
710
|
+
> `optional` **recursive**: `boolean`
|
|
711
|
+
|
|
712
|
+
是否递归创建该目录的上级目录。
|
|
713
|
+
|
|
714
|
+
设为 `true` 时,即使中间路径不存在也会一并创建(类似 `mkdir -p`)。
|
|
715
|
+
|
|
716
|
+
###### Default
|
|
717
|
+
|
|
718
|
+
```ts
|
|
719
|
+
false
|
|
720
|
+
```
|
|
721
|
+
|
|
722
|
+
<a id="readfileparams"></a>
|
|
723
|
+
<a id="encoding-1"></a>
|
|
724
|
+
### ReadFileParams
|
|
725
|
+
|
|
726
|
+
[FileSystemManager.readFile](#readfile) 的参数。
|
|
727
|
+
|
|
728
|
+
#### Properties
|
|
729
|
+
|
|
730
|
+
##### encoding?
|
|
731
|
+
|
|
732
|
+
> `optional` **encoding**: `"base64"` \| `"utf-8"`
|
|
733
|
+
|
|
734
|
+
指定读取文件的字符编码。
|
|
735
|
+
|
|
736
|
+
- `'utf-8'`:以 UTF-8 字符串形式返回文件内容。
|
|
737
|
+
- `'base64'`:以 Base64 编码字符串形式返回文件内容,适用于二进制文件。
|
|
738
|
+
|
|
739
|
+
###### Default
|
|
740
|
+
|
|
741
|
+
```ts
|
|
742
|
+
'utf-8'
|
|
743
|
+
```
|
|
744
|
+
|
|
745
|
+
##### filePath
|
|
746
|
+
|
|
747
|
+
> **filePath**: `string`
|
|
748
|
+
|
|
749
|
+
要读取的文件路径(本地路径)。
|
|
750
|
+
|
|
751
|
+
<a id="readfileresult"></a>
|
|
752
|
+
### ReadFileResult
|
|
753
|
+
|
|
754
|
+
[FileSystemManager.readFile](#readfile) 的返回结果。
|
|
755
|
+
|
|
756
|
+
#### Properties
|
|
757
|
+
|
|
758
|
+
##### data
|
|
759
|
+
|
|
760
|
+
> **data**: `string`
|
|
761
|
+
|
|
762
|
+
文件内容。
|
|
763
|
+
|
|
764
|
+
具体格式由 [ReadFileParams.encoding](#encoding-1) 决定:
|
|
765
|
+
- 编码为 `'utf-8'` 时返回 UTF-8 字符串;
|
|
766
|
+
- 编码为 `'base64'` 时返回 Base64 编码后的字符串。
|
|
767
|
+
|
|
768
|
+
<a id="readdirparams"></a>
|
|
769
|
+
### ReaddirParams
|
|
770
|
+
|
|
771
|
+
[FileSystemManager.readdir](#readdir) 的参数。
|
|
772
|
+
|
|
773
|
+
#### Properties
|
|
774
|
+
|
|
775
|
+
##### dirPath
|
|
776
|
+
|
|
777
|
+
> **dirPath**: `string`
|
|
778
|
+
|
|
779
|
+
要读取的目录路径。
|
|
780
|
+
|
|
781
|
+
<a id="readdirresult"></a>
|
|
782
|
+
### ReaddirResult
|
|
783
|
+
|
|
784
|
+
[FileSystemManager.readdir](#readdir) 的返回结果。
|
|
785
|
+
|
|
786
|
+
#### Properties
|
|
787
|
+
|
|
788
|
+
##### files
|
|
789
|
+
|
|
790
|
+
> **files**: `string`[]
|
|
791
|
+
|
|
792
|
+
目录下的文件和子目录名称列表(不含 `.` 和 `..`)。
|
|
793
|
+
|
|
794
|
+
<a id="removesavedfileparams"></a>
|
|
795
|
+
### RemoveSavedFileParams
|
|
796
|
+
|
|
797
|
+
[FileSystemManager.removeSavedFile](#removesavedfile) 的参数。
|
|
798
|
+
|
|
799
|
+
#### Remarks
|
|
800
|
+
|
|
801
|
+
- 该接口用于删除通过 [FileSystemManager.saveFile](#savefile) 保存的本地文件。
|
|
802
|
+
- 对非已保存文件调用该接口可能会失败。
|
|
803
|
+
|
|
804
|
+
#### Properties
|
|
805
|
+
|
|
806
|
+
##### filePath
|
|
807
|
+
|
|
808
|
+
> **filePath**: `string`
|
|
809
|
+
|
|
810
|
+
需要删除的已保存文件路径(应为 [SaveFileResult.savedFilePath](#savedfilepath) 返回的路径)。
|
|
811
|
+
|
|
812
|
+
<a id="renameparams"></a>
|
|
813
|
+
### RenameParams
|
|
814
|
+
|
|
815
|
+
[FileSystemManager.rename](#rename) 的参数。
|
|
816
|
+
|
|
817
|
+
#### Remarks
|
|
818
|
+
|
|
819
|
+
- 可用于重命名文件或将文件移动到同一文件系统中的其他路径。
|
|
820
|
+
- 如果目标路径已存在同名文件,行为取决于宿主实现(通常会覆盖)。
|
|
821
|
+
|
|
822
|
+
#### Properties
|
|
823
|
+
|
|
824
|
+
##### newPath
|
|
825
|
+
|
|
826
|
+
> **newPath**: `string`
|
|
827
|
+
|
|
828
|
+
新文件路径(即重命名或移动后的目标路径)。
|
|
829
|
+
|
|
830
|
+
##### oldPath
|
|
831
|
+
|
|
832
|
+
> **oldPath**: `string`
|
|
833
|
+
|
|
834
|
+
源文件路径(即当前文件路径)。
|
|
835
|
+
|
|
836
|
+
<a id="rmdirparams"></a>
|
|
837
|
+
### RmdirParams
|
|
838
|
+
|
|
839
|
+
[FileSystemManager.rmdir](#rmdir) 的参数。
|
|
840
|
+
|
|
841
|
+
#### Properties
|
|
842
|
+
|
|
843
|
+
##### dirPath
|
|
844
|
+
|
|
845
|
+
> **dirPath**: `string`
|
|
846
|
+
|
|
847
|
+
要删除的目录路径。
|
|
848
|
+
|
|
849
|
+
##### recursive?
|
|
850
|
+
|
|
851
|
+
> `optional` **recursive**: `boolean`
|
|
852
|
+
|
|
853
|
+
是否递归删除目录下的所有子文件和子目录。
|
|
854
|
+
|
|
855
|
+
设为 `false` 时,仅当目录为空才能删除成功;设为 `true` 时会递归删除所有内容。
|
|
856
|
+
|
|
857
|
+
###### Default
|
|
858
|
+
|
|
859
|
+
```ts
|
|
860
|
+
false
|
|
861
|
+
```
|
|
862
|
+
|
|
863
|
+
<a id="savefileparams"></a>
|
|
864
|
+
### SaveFileParams
|
|
865
|
+
|
|
866
|
+
[FileSystemManager.saveFile](#savefile) 的参数。
|
|
867
|
+
|
|
868
|
+
#### Remarks
|
|
869
|
+
|
|
870
|
+
- 该接口用于将临时文件保存到本地持久化存储。临时文件在应用退出后可能被系统清理,
|
|
871
|
+
通过 `saveFile` 保存后的文件将不会被自动清理。
|
|
872
|
+
- 保存成功后原临时文件会被移除。
|
|
873
|
+
|
|
874
|
+
#### Properties
|
|
875
|
+
|
|
876
|
+
##### filePath?
|
|
877
|
+
|
|
878
|
+
> `optional` **filePath**: `string`
|
|
879
|
+
|
|
880
|
+
保存到的目标文件路径。
|
|
881
|
+
|
|
882
|
+
若不指定,则由宿主决定存储位置并通过 [SaveFileResult.savedFilePath](#savedfilepath) 返回。
|
|
883
|
+
|
|
884
|
+
##### tempFilePath
|
|
885
|
+
|
|
886
|
+
> **tempFilePath**: `string`
|
|
887
|
+
|
|
888
|
+
临时文件路径(需先通过下载或其他方式获得的临时文件路径)。
|
|
889
|
+
|
|
890
|
+
<a id="savefileresult"></a>
|
|
891
|
+
<a id="savedfilepath"></a>
|
|
892
|
+
### SaveFileResult
|
|
893
|
+
|
|
894
|
+
[FileSystemManager.saveFile](#savefile) 的返回结果。
|
|
895
|
+
|
|
896
|
+
#### Properties
|
|
897
|
+
|
|
898
|
+
##### savedFilePath
|
|
899
|
+
|
|
900
|
+
> **savedFilePath**: `string`
|
|
901
|
+
|
|
902
|
+
文件保存后的实际存储路径。
|
|
903
|
+
|
|
904
|
+
<a id="statparams"></a>
|
|
905
|
+
### StatParams
|
|
906
|
+
|
|
907
|
+
[FileSystemManager.stat](#stat) 的参数。
|
|
908
|
+
|
|
909
|
+
#### Properties
|
|
910
|
+
|
|
911
|
+
##### path
|
|
912
|
+
|
|
913
|
+
> **path**: `string`
|
|
914
|
+
|
|
915
|
+
要获取状态信息的文件或目录路径。
|
|
916
|
+
|
|
917
|
+
<a id="statresult"></a>
|
|
918
|
+
### StatResult
|
|
919
|
+
|
|
920
|
+
[FileSystemManager.stat](#stat) 的返回结果。
|
|
921
|
+
|
|
922
|
+
#### Properties
|
|
923
|
+
|
|
924
|
+
##### isDirectory
|
|
925
|
+
|
|
926
|
+
> **isDirectory**: `boolean`
|
|
927
|
+
|
|
928
|
+
判断当前路径是否是一个目录。
|
|
929
|
+
|
|
930
|
+
##### lastModifiedTime
|
|
931
|
+
|
|
932
|
+
> **lastModifiedTime**: `number`
|
|
933
|
+
|
|
934
|
+
文件最近一次被修改的时间戳,单位为毫秒。
|
|
935
|
+
|
|
936
|
+
##### size
|
|
937
|
+
|
|
938
|
+
> **size**: `number`
|
|
939
|
+
|
|
940
|
+
文件大小,单位为字节(Byte)。
|
|
941
|
+
|
|
942
|
+
<a id="truncateparams"></a>
|
|
943
|
+
### TruncateParams
|
|
944
|
+
|
|
945
|
+
[FileSystemManager.truncate](#truncate) 的参数。
|
|
946
|
+
|
|
947
|
+
#### Properties
|
|
948
|
+
|
|
949
|
+
##### filePath
|
|
950
|
+
|
|
951
|
+
> **filePath**: `string`
|
|
952
|
+
|
|
953
|
+
要截断的文件路径。
|
|
954
|
+
|
|
955
|
+
##### length?
|
|
956
|
+
|
|
957
|
+
> `optional` **length**: `number`
|
|
958
|
+
|
|
959
|
+
截断后的文件字节长度。
|
|
960
|
+
|
|
961
|
+
- 若 `length` 小于文件原始长度,文件将被截取到指定长度,多余部分丢弃。
|
|
962
|
+
- 若 `length` 大于文件原始长度,文件将被扩展到指定长度,扩展部分用 `\0` 填充。
|
|
963
|
+
|
|
964
|
+
###### Default
|
|
965
|
+
|
|
966
|
+
```ts
|
|
967
|
+
0
|
|
968
|
+
```
|
|
969
|
+
|
|
970
|
+
<a id="unlinkparams"></a>
|
|
971
|
+
### UnlinkParams
|
|
972
|
+
|
|
973
|
+
[FileSystemManager.unlink](#unlink) 的参数。
|
|
974
|
+
|
|
975
|
+
#### Properties
|
|
976
|
+
|
|
977
|
+
##### filePath
|
|
978
|
+
|
|
979
|
+
> **filePath**: `string`
|
|
980
|
+
|
|
981
|
+
要删除的文件路径。
|
|
982
|
+
|
|
983
|
+
该接口只能删除文件,不能删除目录;删除目录应使用 [FileSystemManager.rmdir](#rmdir)。
|
|
984
|
+
|
|
985
|
+
<a id="unzipparams"></a>
|
|
986
|
+
### UnzipParams
|
|
987
|
+
|
|
988
|
+
[FileSystemManager.unzip](#unzip) 的参数。
|
|
989
|
+
|
|
990
|
+
#### Properties
|
|
991
|
+
|
|
992
|
+
##### targetPath
|
|
993
|
+
|
|
994
|
+
> **targetPath**: `string`
|
|
995
|
+
|
|
996
|
+
解压后的目标目录路径。
|
|
997
|
+
|
|
998
|
+
目标目录须已存在,否则解压会失败。
|
|
999
|
+
|
|
1000
|
+
##### zipFilePath
|
|
1001
|
+
|
|
1002
|
+
> **zipFilePath**: `string`
|
|
1003
|
+
|
|
1004
|
+
要解压的 zip 文件路径。
|
|
1005
|
+
|
|
1006
|
+
<a id="writefileparams"></a>
|
|
1007
|
+
### WriteFileParams
|
|
1008
|
+
|
|
1009
|
+
[FileSystemManager.writeFile](#writefile) 的参数。
|
|
1010
|
+
|
|
1011
|
+
#### Remarks
|
|
1012
|
+
|
|
1013
|
+
- 如果文件不存在会自动创建;如果文件已存在则会覆盖原有内容。
|
|
1014
|
+
- 父目录不存在时写入会失败,需先通过 [FileSystemManager.mkdir](#mkdir) 创建目录。
|
|
1015
|
+
|
|
1016
|
+
#### Properties
|
|
1017
|
+
|
|
1018
|
+
##### data
|
|
1019
|
+
|
|
1020
|
+
> **data**: `string`
|
|
1021
|
+
|
|
1022
|
+
要写入的内容。
|
|
1023
|
+
|
|
1024
|
+
- 当 `encoding` 为 `'utf-8'` 时,直接写入该字符串;
|
|
1025
|
+
- 当 `encoding` 为 `'base64'` 时,将该字符串先进行 Base64 解码再写入文件。
|
|
1026
|
+
|
|
1027
|
+
##### encoding?
|
|
1028
|
+
|
|
1029
|
+
> `optional` **encoding**: `"base64"` \| `"utf-8"`
|
|
1030
|
+
|
|
1031
|
+
指定写入文件的字符编码。
|
|
1032
|
+
|
|
1033
|
+
###### Default
|
|
1034
|
+
|
|
1035
|
+
```ts
|
|
1036
|
+
'utf-8'
|
|
1037
|
+
```
|
|
1038
|
+
|
|
1039
|
+
##### filePath
|
|
1040
|
+
|
|
1041
|
+
> **filePath**: `string`
|
|
1042
|
+
|
|
1043
|
+
要写入的文件路径(本地路径)。
|