• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1/*
2 * Copyright (c) 2025 Huawei Device Co., Ltd.
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at
6 *
7 *     http://www.apache.org/licenses/LICENSE-2.0
8 *
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
14 */
15
16/**
17 * @file
18 * @kit CoreFileKit
19 * @arkts 1.2
20 */
21
22import { AsyncCallback } from './@ohos.base';
23
24/**
25 * FileIO
26 *
27 * @namespace fileIo
28 * @syscap SystemCapability.FileManagement.File.FileIO
29 * @since 20
30 */
31declare namespace fileIo {
32
33   /**
34   * Mode Indicates the open flags.
35   *
36   * @namespace OpenMode
37   * @syscap SystemCapability.FileManagement.File.FileIO
38   * @since 20
39   */
40  namespace OpenMode {
41  /**
42   * Read only Permission.
43   *
44   * @constant
45   * @syscap SystemCapability.FileManagement.File.FileIO
46   * @since 20
47   */
48    const READ_ONLY = 0o0;
49  /**
50   * Write only Permission.
51   *
52   * @constant
53   * @syscap SystemCapability.FileManagement.File.FileIO
54   * @since 20
55   */
56    const WRITE_ONLY = 0o1;
57  /**
58   * Write and Read Permission.
59   *
60   * @constant
61   * @syscap SystemCapability.FileManagement.File.FileIO
62   * @since 20
63   */
64    const READ_WRITE = 0o2;
65  /**
66   * If not exist, create file.
67   *
68   * @constant
69   * @syscap SystemCapability.FileManagement.File.FileIO
70   * @since 20
71   */
72    const CREATE = 0o100;
73  /**
74   * File truncate len 0.
75   *
76   * @constant
77   * @syscap SystemCapability.FileManagement.File.FileIO
78   * @since 20
79   */
80    const TRUNC = 0o1000;
81  /**
82   * File append write.
83   *
84   * @constant
85   * @syscap SystemCapability.FileManagement.File.FileIO
86   * @since 20
87   */
88    const APPEND = 0o2000;
89  /**
90   * File open in nonblocking mode.
91   *
92   * @constant
93   * @syscap SystemCapability.FileManagement.File.FileIO
94   * @since 20
95   */
96    const NONBLOCK = 0o4000;
97  /**
98   * File is Dir.
99   *
100   * @constant
101   * @syscap SystemCapability.FileManagement.File.FileIO
102   * @since 20
103   */
104    const DIR = 0o200000;
105  /**
106   * File is not symbolic link.
107   *
108   * @constant
109   * @syscap SystemCapability.FileManagement.File.FileIO
110   * @since 20
111   */
112    const NOFOLLOW = 0o400000;
113  /**
114   * SYNC IO.
115   *
116   * @constant
117   * @syscap SystemCapability.FileManagement.File.FileIO
118   * @since 20
119   */
120    const SYNC = 0o4010000;
121  }
122
123/**
124 * Access file.
125 *
126 * @param { string } path - path.
127 * @param { AccessModeType } [mode = fs.AccessModeType.EXIST] - accessibility mode.
128 * @returns { Promise<boolean> } Returns the file is accessible or not in promise mode.
129 * @throws { BusinessError } 13900002 - No such file or directory
130 * @throws { BusinessError } 13900005 - I/O error
131 * @throws { BusinessError } 13900008 - Bad file descriptor
132 * @throws { BusinessError } 13900011 - Out of memory
133 * @throws { BusinessError } 13900012 - Permission denied
134 * @throws { BusinessError } 13900013 - Bad address
135 * @throws { BusinessError } 13900018 - Not a directory
136 * @throws { BusinessError } 13900020 - Invalid argument
137 * @throws { BusinessError } 13900023 - Text file busy
138 * @throws { BusinessError } 13900030 - File name too long
139 * @throws { BusinessError } 13900033 - Too many symbolic links encountered
140 * @throws { BusinessError } 13900042 - Unknown error
141 * @syscap SystemCapability.FileManagement.File.FileIO
142 * @since 20
143 */
144function access(path: string, mode?: AccessModeType): Promise<boolean>;
145
146/**
147 * Access file.
148 *
149 * @param { string } path - path.
150 * @param { AsyncCallback<boolean> } callback - The callback is used to return the file is accessible or not.
151 * @throws { BusinessError } 13900002 - No such file or directory
152 * @throws { BusinessError } 13900005 - I/O error
153 * @throws { BusinessError } 13900008 - Bad file descriptor
154 * @throws { BusinessError } 13900011 - Out of memory
155 * @throws { BusinessError } 13900012 - Permission denied
156 * @throws { BusinessError } 13900013 - Bad address
157 * @throws { BusinessError } 13900018 - Not a directory
158 * @throws { BusinessError } 13900020 - Invalid argument
159 * @throws { BusinessError } 13900023 - Text file busy
160 * @throws { BusinessError } 13900030 - File name too long
161 * @throws { BusinessError } 13900033 - Too many symbolic links encountered
162 * @throws { BusinessError } 13900042 - Unknown error
163 * @syscap SystemCapability.FileManagement.File.FileIO
164 * @since 20
165 */
166function access(path: string, callback: AsyncCallback<boolean>): void;
167
168/**
169 * Access file.
170 *
171 * @param { string } path - file path that needs to be checked whether the calling process can access.
172 * @param { AccessModeType } mode - accessibility mode.
173 * @param { AccessFlagType } flag - accessibility flag.
174 * @returns { Promise<boolean> } Returns the file is accessible or not in promise mode.
175 * @throws { BusinessError } 401 - Parameter error.Possible causes:1.Mandatory parameters are left unspecified;
176 * <br>2.Incorrect parameter types.
177 * @throws { BusinessError } 13900005 - I/O error
178 * @throws { BusinessError } 13900011 - Out of memory
179 * @throws { BusinessError } 13900012 - Permission denied
180 * @throws { BusinessError } 13900013 - Bad address
181 * @throws { BusinessError } 13900018 - Not a directory
182 * @throws { BusinessError } 13900020 - Invalid argument
183 * @throws { BusinessError } 13900023 - Text file busy
184 * @throws { BusinessError } 13900030 - File name too long
185 * @throws { BusinessError } 13900033 - Too many symbolic links encountered
186 * @syscap SystemCapability.FileManagement.File.FileIO
187 * @since 20
188 */
189function access(path: string, mode: AccessModeType, flag: AccessFlagType): Promise<boolean>;
190
191/**
192 *
193 * Access file with sync interface.
194 *
195 * @param { string } path - path.
196 * @param { AccessModeType } [mode = fs.AccessModeType.EXIST] - accessibility mode.
197 * @returns { boolean } Returns the file is accessible or not.
198 * @throws { BusinessError } 13900002 - No such file or directory
199 * @throws { BusinessError } 13900005 - I/O error
200 * @throws { BusinessError } 13900008 - Bad file descriptor
201 * @throws { BusinessError } 13900011 - Out of memory
202 * @throws { BusinessError } 13900012 - Permission denied
203 * @throws { BusinessError } 13900013 - Bad address
204 * @throws { BusinessError } 13900018 - Not a directory
205 * @throws { BusinessError } 13900020 - Invalid argument
206 * @throws { BusinessError } 13900023 - Text file busy
207 * @throws { BusinessError } 13900030 - File name too long
208 * @throws { BusinessError } 13900033 - Too many symbolic links encountered
209 * @throws { BusinessError } 13900042 - Unknown error
210 * @syscap SystemCapability.FileManagement.File.FileIO
211 * @since 20
212 */
213function accessSync(path: string, mode?: AccessModeType): boolean;
214
215/**
216 * Access file with sync interface.
217 *
218 * @param { string } path - file path that needs to be checked whether the calling process can access.
219 * @param { AccessModeType } mode - accessibility mode.
220 * @param { AccessFlagType } flag - accessibility flag.
221 * @returns { boolean } Returns the file is accessible or not.
222 * @throws { BusinessError } 401 - Parameter error.Possible causes:1.Mandatory parameters are left unspecified;
223 * <br>2.Incorrect parameter types.
224 * @throws { BusinessError } 13900005 - I/O error
225 * @throws { BusinessError } 13900011 - Out of memory
226 * @throws { BusinessError } 13900012 - Permission denied
227 * @throws { BusinessError } 13900013 - Bad address
228 * @throws { BusinessError } 13900018 - Not a directory
229 * @throws { BusinessError } 13900020 - Invalid argument
230 * @throws { BusinessError } 13900023 - Text file busy
231 * @throws { BusinessError } 13900030 - File name too long
232 * @throws { BusinessError } 13900033 - Too many symbolic links encountered
233 * @syscap SystemCapability.FileManagement.File.FileIO
234 * @since 20
235 */
236function accessSync(path: string, mode: AccessModeType, flag: AccessFlagType): boolean;
237
238/**
239 * Close file or fd.
240 *
241 * @param { number | File } file - file object or fd.
242 * @returns { Promise<void> } The promise returned by the function.
243 * @throws { BusinessError } 13900004 - Interrupted system call
244 * @throws { BusinessError } 13900005 - I/O error
245 * @throws { BusinessError } 13900008 - Bad file descriptor
246 * @throws { BusinessError } 13900025 - No space left on device
247 * @throws { BusinessError } 13900041 - Quota exceeded
248 * @throws { BusinessError } 13900042 - Unknown error
249 * @syscap SystemCapability.FileManagement.File.FileIO
250 * @since 20
251 */
252function close(file: number | File): Promise<void>;
253
254/**
255 * Close file or fd.
256 *
257 * @param { number | File } file - file object or fd.
258 * @param { AsyncCallback<void> } callback - Return the callback function.
259 * @throws { BusinessError } 13900004 - Interrupted system call
260 * @throws { BusinessError } 13900005 - I/O error
261 * @throws { BusinessError } 13900008 - Bad file descriptor
262 * @throws { BusinessError } 13900025 - No space left on device
263 * @throws { BusinessError } 13900041 - Quota exceeded
264 * @throws { BusinessError } 13900042 - Unknown error
265 * @syscap SystemCapability.FileManagement.File.FileIO
266 * @since 20
267 */
268function close(file: number | File, callback: AsyncCallback<void>): void;
269
270/**
271 * Close file or fd with sync interface.
272 *
273 * @param { number | File } file - file object or fd.
274 * @throws { BusinessError } 13900004 - Interrupted system call
275 * @throws { BusinessError } 13900005 - I/O error
276 * @throws { BusinessError } 13900008 - Bad file descriptor
277 * @throws { BusinessError } 13900025 - No space left on device
278 * @throws { BusinessError } 13900041 - Quota exceeded
279 * @throws { BusinessError } 13900042 - Unknown error
280 * @syscap SystemCapability.FileManagement.File.FileIO
281 * @since 20
282 */
283function closeSync(file: number | File): void;
284
285/**
286 * Copy file or directory.
287 *
288 * @param { string } srcUri - src uri.
289 * @param { string } destUri - dest uri.
290 * @param { CopyOptions } [options] - options.
291 * @returns { Promise<void> } The promise returned by the function.
292 * @throws { BusinessError } 401 - Parameter error.Possible causes:1.Mandatory parameters are left unspecified;
293 * <br>2.Incorrect parameter types.
294 * @throws { BusinessError } 13900001 - Operation not permitted
295 * @throws { BusinessError } 13900002 - No such file or directory
296 * @throws { BusinessError } 13900004 - Interrupted system call
297 * @throws { BusinessError } 13900005 - I/O error
298 * @throws { BusinessError } 13900008 - Bad file descriptor
299 * @throws { BusinessError } 13900010 - Try again
300 * @throws { BusinessError } 13900011 - Out of memory
301 * @throws { BusinessError } 13900012 - Permission denied by the file system
302 * @throws { BusinessError } 13900015 - File exists
303 * @throws { BusinessError } 13900018 - Not a directory
304 * @throws { BusinessError } 13900019 - Is a directory
305 * @throws { BusinessError } 13900020 - Invalid argument
306 * @throws { BusinessError } 13900021 - File table overflow
307 * @throws { BusinessError } 13900022 - Too many open files
308 * @throws { BusinessError } 13900024 - File too large
309 * @throws { BusinessError } 13900025 - No space left on device
310 * @throws { BusinessError } 13900027 - Read-only file system
311 * @throws { BusinessError } 13900028 - Too many links
312 * @throws { BusinessError } 13900030 - File name too long
313 * @throws { BusinessError } 13900031 - Function not implemented
314 * @throws { BusinessError } 13900034 - Operation would block
315 * @throws { BusinessError } 13900038 - Value too large for defined data type
316 * @throws { BusinessError } 13900041 - Quota exceeded
317 * @throws { BusinessError } 13900042 - Unknown error
318 * @throws { BusinessError } 13900044 - Network is unreachable
319 * @syscap SystemCapability.FileManagement.File.FileIO
320 * @since 20
321 */
322function copy(srcUri: string, destUri: string, options?: CopyOptions): Promise<void>;
323
324/**
325 * Copy file or directory.
326 *
327 * @param { string } srcUri - src uri.
328 * @param { string } destUri - dest uri.
329 * @param { AsyncCallback<void> } callback - Return the callback function.
330 * @throws { BusinessError } 401 - Parameter error.Possible causes:1.Mandatory parameters are left unspecified;
331 * <br>2.Incorrect parameter types.
332 * @throws { BusinessError } 13900001 - Operation not permitted
333 * @throws { BusinessError } 13900002 - No such file or directory
334 * @throws { BusinessError } 13900004 - Interrupted system call
335 * @throws { BusinessError } 13900005 - I/O error
336 * @throws { BusinessError } 13900008 - Bad file descriptor
337 * @throws { BusinessError } 13900010 - Try again
338 * @throws { BusinessError } 13900011 - Out of memory
339 * @throws { BusinessError } 13900012 - Permission denied by the file system
340 * @throws { BusinessError } 13900015 - File exists
341 * @throws { BusinessError } 13900018 - Not a directory
342 * @throws { BusinessError } 13900019 - Is a directory
343 * @throws { BusinessError } 13900020 - Invalid argument
344 * @throws { BusinessError } 13900021 - File table overflow
345 * @throws { BusinessError } 13900022 - Too many open files
346 * @throws { BusinessError } 13900024 - File too large
347 * @throws { BusinessError } 13900025 - No space left on device
348 * @throws { BusinessError } 13900027 - Read-only file system
349 * @throws { BusinessError } 13900028 - Too many links
350 * @throws { BusinessError } 13900030 - File name too long
351 * @throws { BusinessError } 13900031 - Function not implemented
352 * @throws { BusinessError } 13900034 - Operation would block
353 * @throws { BusinessError } 13900038 - Value too large for defined data type
354 * @throws { BusinessError } 13900041 - Quota exceeded
355 * @throws { BusinessError } 13900042 - Unknown error
356 * @syscap SystemCapability.FileManagement.File.FileIO
357 * @since 20
358 */
359function copy(srcUri: string, destUri: string, callback: AsyncCallback<void>): void;
360
361/**
362 * Copy file or directory.
363 *
364 * @param { string } srcUri - src uri.
365 * @param { string } destUri - dest uri.
366 * @param { CopyOptions } options - options.
367 * @param { AsyncCallback<void> } callback - Return the callback function.
368 * @throws { BusinessError } 401 - Parameter error.Possible causes:1.Mandatory parameters are left unspecified;
369 * <br>2.Incorrect parameter types.
370 * @throws { BusinessError } 13900001 - Operation not permitted
371 * @throws { BusinessError } 13900002 - No such file or directory
372 * @throws { BusinessError } 13900004 - Interrupted system call
373 * @throws { BusinessError } 13900005 - I/O error
374 * @throws { BusinessError } 13900008 - Bad file descriptor
375 * @throws { BusinessError } 13900010 - Try again
376 * @throws { BusinessError } 13900011 - Out of memory
377 * @throws { BusinessError } 13900012 - Permission denied by the file system
378 * @throws { BusinessError } 13900015 - File exists
379 * @throws { BusinessError } 13900018 - Not a directory
380 * @throws { BusinessError } 13900019 - Is a directory
381 * @throws { BusinessError } 13900020 - Invalid argument
382 * @throws { BusinessError } 13900021 - File table overflow
383 * @throws { BusinessError } 13900022 - Too many open files
384 * @throws { BusinessError } 13900024 - File too large
385 * @throws { BusinessError } 13900025 - No space left on device
386 * @throws { BusinessError } 13900027 - Read-only file system
387 * @throws { BusinessError } 13900028 - Too many links
388 * @throws { BusinessError } 13900030 - File name too long
389 * @throws { BusinessError } 13900031 - Function not implemented
390 * @throws { BusinessError } 13900034 - Operation would block
391 * @throws { BusinessError } 13900038 - Value too large for defined data type
392 * @throws { BusinessError } 13900041 - Quota exceeded
393 * @throws { BusinessError } 13900042 - Unknown error
394 * @syscap SystemCapability.FileManagement.File.FileIO
395 * @since 20
396 */
397function copy(srcUri: string, destUri: string, options: CopyOptions, callback: AsyncCallback<void>): void;
398
399/**
400 * Copy directory.
401 *
402 * @param { string } src - source path.
403 * @param { string } dest - destination path.
404 * @param { number } [mode = 0] - mode.
405 * @returns { Promise<void> } The promise returned by the function.
406 * @throws { BusinessError } 13900002 - No such file or directory
407 * @throws { BusinessError } 13900004 - Interrupted system call
408 * @throws { BusinessError } 13900005 - I/O error
409 * @throws { BusinessError } 13900008 - Bad file descriptor
410 * @throws { BusinessError } 13900010 - Try again
411 * @throws { BusinessError } 13900011 - Out of memory
412 * @throws { BusinessError } 13900012 - Permission denied
413 * @throws { BusinessError } 13900013 - Bad address
414 * @throws { BusinessError } 13900018 - Not a directory
415 * @throws { BusinessError } 13900019 - Is a directory
416 * @throws { BusinessError } 13900020 - Invalid argument
417 * @throws { BusinessError } 13900030 - File name too long
418 * @throws { BusinessError } 13900031 - Function not implemented
419 * @throws { BusinessError } 13900033 - Too many symbolic links encountered
420 * @throws { BusinessError } 13900034 - Operation would block
421 * @throws { BusinessError } 13900038 - Value too large for defined data type
422 * @throws { BusinessError } 13900042 - Unknown error
423 * @throws { BusinessError } 13900044 - Network is unreachable
424 * @syscap SystemCapability.FileManagement.File.FileIO
425 * @since 20
426 */
427function copyDir(src: string, dest: string, mode?: number): Promise<void>;
428
429/**
430 * Copy directory.
431 *
432 * @param { string } src - source path.
433 * @param { string } dest - destination path.
434 * @param { AsyncCallback<void> } callback - Return the callback function.
435 * @throws { BusinessError } 13900002 - No such file or directory
436 * @throws { BusinessError } 13900004 - Interrupted system call
437 * @throws { BusinessError } 13900005 - I/O error
438 * @throws { BusinessError } 13900008 - Bad file descriptor
439 * @throws { BusinessError } 13900010 - Try again
440 * @throws { BusinessError } 13900011 - Out of memory
441 * @throws { BusinessError } 13900012 - Permission denied
442 * @throws { BusinessError } 13900013 - Bad address
443 * @throws { BusinessError } 13900018 - Not a directory
444 * @throws { BusinessError } 13900019 - Is a directory
445 * @throws { BusinessError } 13900020 - Invalid argument
446 * @throws { BusinessError } 13900030 - File name too long
447 * @throws { BusinessError } 13900031 - Function not implemented
448 * @throws { BusinessError } 13900033 - Too many symbolic links encountered
449 * @throws { BusinessError } 13900034 - Operation would block
450 * @throws { BusinessError } 13900038 - Value too large for defined data type
451 * @throws { BusinessError } 13900042 - Unknown error
452 * @syscap SystemCapability.FileManagement.File.FileIO
453 * @since 20
454 */
455function copyDir(src: string, dest: string, callback: AsyncCallback<void>): void;
456
457/**
458 * Copy directory.
459 *
460 * @param { string } src - source path.
461 * @param { string } dest - destination path.
462 * @param { number } mode - mode.
463 * @param { AsyncCallback<void> } callback - Return the callback function.
464 * @throws { BusinessError } 13900002 - No such file or directory
465 * @throws { BusinessError } 13900004 - Interrupted system call
466 * @throws { BusinessError } 13900005 - I/O error
467 * @throws { BusinessError } 13900008 - Bad file descriptor
468 * @throws { BusinessError } 13900010 - Try again
469 * @throws { BusinessError } 13900011 - Out of memory
470 * @throws { BusinessError } 13900012 - Permission denied
471 * @throws { BusinessError } 13900013 - Bad address
472 * @throws { BusinessError } 13900018 - Not a directory
473 * @throws { BusinessError } 13900019 - Is a directory
474 * @throws { BusinessError } 13900020 - Invalid argument
475 * @throws { BusinessError } 13900030 - File name too long
476 * @throws { BusinessError } 13900031 - Function not implemented
477 * @throws { BusinessError } 13900033 - Too many symbolic links encountered
478 * @throws { BusinessError } 13900034 - Operation would block
479 * @throws { BusinessError } 13900038 - Value too large for defined data type
480 * @throws { BusinessError } 13900042 - Unknown error
481 * @syscap SystemCapability.FileManagement.File.FileIO
482 * @since 20
483 */
484function copyDir(src: string, dest: string, mode: number, callback: AsyncCallback<void>): void;
485
486/**
487 * Copy directory with sync interface.
488 *
489 * @param { string } src - source path.
490 * @param { string } dest - destination path.
491 * @param { number } [mode = 0] - mode.
492 * @throws { BusinessError } 13900002 - No such file or directory
493 * @throws { BusinessError } 13900004 - Interrupted system call
494 * @throws { BusinessError } 13900005 - I/O error
495 * @throws { BusinessError } 13900008 - Bad file descriptor
496 * @throws { BusinessError } 13900010 - Try again
497 * @throws { BusinessError } 13900011 - Out of memory
498 * @throws { BusinessError } 13900012 - Permission denied
499 * @throws { BusinessError } 13900013 - Bad address
500 * @throws { BusinessError } 13900015 - File exists
501 * @throws { BusinessError } 13900018 - Not a directory
502 * @throws { BusinessError } 13900019 - Is a directory
503 * @throws { BusinessError } 13900020 - Invalid argument
504 * @throws { BusinessError } 13900030 - File name too long
505 * @throws { BusinessError } 13900031 - Function not implemented
506 * @throws { BusinessError } 13900033 - Too many symbolic links encountered
507 * @throws { BusinessError } 13900034 - Operation would block
508 * @throws { BusinessError } 13900038 - Value too large for defined data type
509 * @throws { BusinessError } 13900042 - Unknown error
510 * @throws { BusinessError } 13900044 - Network is unreachable
511 * @syscap SystemCapability.FileManagement.File.FileIO
512 * @since 20
513 */
514function copyDirSync(src: string, dest: string, mode?: number): void;
515
516/**
517 * Copy file.
518 *
519 * @param { string | number } src - src.
520 * @param { string | number } dest - dest.
521 * @param { number } [mode = 0] - mode.
522 * @returns { Promise<void> } The promise returned by the function.
523 * @throws { BusinessError } 13900002 - No such file or directory
524 * @throws { BusinessError } 13900004 - Interrupted system call
525 * @throws { BusinessError } 13900005 - I/O error
526 * @throws { BusinessError } 13900008 - Bad file descriptor
527 * @throws { BusinessError } 13900010 - Try again
528 * @throws { BusinessError } 13900011 - Out of memory
529 * @throws { BusinessError } 13900012 - Permission denied
530 * @throws { BusinessError } 13900013 - Bad address
531 * @throws { BusinessError } 13900018 - Not a directory
532 * @throws { BusinessError } 13900019 - Is a directory
533 * @throws { BusinessError } 13900020 - Invalid argument
534 * @throws { BusinessError } 13900030 - File name too long
535 * @throws { BusinessError } 13900031 - Function not implemented
536 * @throws { BusinessError } 13900033 - Too many symbolic links encountered
537 * @throws { BusinessError } 13900034 - Operation would block
538 * @throws { BusinessError } 13900038 - Value too large for defined data type
539 * @throws { BusinessError } 13900042 - Unknown error
540 * @throws { BusinessError } 13900044 - Network is unreachable
541 * @syscap SystemCapability.FileManagement.File.FileIO
542 * @since 20
543 */
544function copyFile(src: string | number, dest: string | number, mode?: number): Promise<void>;
545
546/**
547 * Copy file.
548 *
549 * @param { string | number } src - src.
550 * @param { string | number } dest - dest.
551 * @param { AsyncCallback<void> } callback - Return the callback function.
552 * @throws { BusinessError } 13900002 - No such file or directory
553 * @throws { BusinessError } 13900004 - Interrupted system call
554 * @throws { BusinessError } 13900005 - I/O error
555 * @throws { BusinessError } 13900008 - Bad file descriptor
556 * @throws { BusinessError } 13900010 - Try again
557 * @throws { BusinessError } 13900011 - Out of memory
558 * @throws { BusinessError } 13900012 - Permission denied
559 * @throws { BusinessError } 13900013 - Bad address
560 * @throws { BusinessError } 13900018 - Not a directory
561 * @throws { BusinessError } 13900019 - Is a directory
562 * @throws { BusinessError } 13900020 - Invalid argument
563 * @throws { BusinessError } 13900030 - File name too long
564 * @throws { BusinessError } 13900031 - Function not implemented
565 * @throws { BusinessError } 13900033 - Too many symbolic links encountered
566 * @throws { BusinessError } 13900034 - Operation would block
567 * @throws { BusinessError } 13900038 - Value too large for defined data type
568 * @throws { BusinessError } 13900042 - Unknown error
569 * @syscap SystemCapability.FileManagement.File.FileIO
570 * @since 20
571 */
572function copyFile(src: string | number, dest: string | number, callback: AsyncCallback<void>): void;
573
574/**
575 * Copy file.
576 *
577 * @param { string | number } src - src.
578 * @param { string | number } dest - dest.
579 * @param { number } [mode = 0] - mode.
580 * @param { AsyncCallback<void> } callback - Return the callback function.
581 * @throws { BusinessError } 13900002 - No such file or directory
582 * @throws { BusinessError } 13900004 - Interrupted system call
583 * @throws { BusinessError } 13900005 - I/O error
584 * @throws { BusinessError } 13900008 - Bad file descriptor
585 * @throws { BusinessError } 13900010 - Try again
586 * @throws { BusinessError } 13900011 - Out of memory
587 * @throws { BusinessError } 13900012 - Permission denied
588 * @throws { BusinessError } 13900013 - Bad address
589 * @throws { BusinessError } 13900018 - Not a directory
590 * @throws { BusinessError } 13900019 - Is a directory
591 * @throws { BusinessError } 13900020 - Invalid argument
592 * @throws { BusinessError } 13900030 - File name too long
593 * @throws { BusinessError } 13900031 - Function not implemented
594 * @throws { BusinessError } 13900033 - Too many symbolic links encountered
595 * @throws { BusinessError } 13900034 - Operation would block
596 * @throws { BusinessError } 13900038 - Value too large for defined data type
597 * @throws { BusinessError } 13900042 - Unknown error
598 * @syscap SystemCapability.FileManagement.File.FileIO
599 * @since 20
600 */
601function copyFile(
602  src: string | number,
603  dest: string | number,
604  mode: number,
605  callback: AsyncCallback<void>
606): void;
607
608/**
609 * Copy file with sync interface.
610 *
611 * @param { string | number } src - src.
612 * @param { string | number } dest - dest.
613 * @param { number } [mode = 0] - mode.
614 * @throws { BusinessError } 13900002 - No such file or directory
615 * @throws { BusinessError } 13900004 - Interrupted system call
616 * @throws { BusinessError } 13900005 - I/O error
617 * @throws { BusinessError } 13900008 - Bad file descriptor
618 * @throws { BusinessError } 13900010 - Try again
619 * @throws { BusinessError } 13900011 - Out of memory
620 * @throws { BusinessError } 13900012 - Permission denied
621 * @throws { BusinessError } 13900013 - Bad address
622 * @throws { BusinessError } 13900018 - Not a directory
623 * @throws { BusinessError } 13900019 - Is a directory
624 * @throws { BusinessError } 13900020 - Invalid argument
625 * @throws { BusinessError } 13900030 - File name too long
626 * @throws { BusinessError } 13900031 - Function not implemented
627 * @throws { BusinessError } 13900033 - Too many symbolic links encountered
628 * @throws { BusinessError } 13900034 - Operation would block
629 * @throws { BusinessError } 13900038 - Value too large for defined data type
630 * @throws { BusinessError } 13900042 - Unknown error
631 * @throws { BusinessError } 13900044 - Network is unreachable
632 * @syscap SystemCapability.FileManagement.File.FileIO
633 * @since 20
634 */
635function copyFileSync(src: string | number, dest: string | number, mode?: number): void;
636
637/**
638 * Create class Stream.
639 *
640 * @param { string } path - path.
641 * @param { string } mode - mode.
642 * @returns { Promise<Stream> } return Promise
643 * @throws { BusinessError } 13900001 - Operation not permitted
644 * @throws { BusinessError } 13900002 - No such file or directory
645 * @throws { BusinessError } 13900004 - Interrupted system call
646 * @throws { BusinessError } 13900006 - No such device or address
647 * @throws { BusinessError } 13900008 - Bad file descriptor
648 * @throws { BusinessError } 13900011 - Out of memory
649 * @throws { BusinessError } 13900012 - Permission denied
650 * @throws { BusinessError } 13900013 - Bad address
651 * @throws { BusinessError } 13900014 - Device or resource busy
652 * @throws { BusinessError } 13900015 - File exists
653 * @throws { BusinessError } 13900017 - No such device
654 * @throws { BusinessError } 13900018 - Not a directory
655 * @throws { BusinessError } 13900019 - Is a directory
656 * @throws { BusinessError } 13900020 - Invalid argument
657 * @throws { BusinessError } 13900022 - Too many open files
658 * @throws { BusinessError } 13900023 - Text file busy
659 * @throws { BusinessError } 13900024 - File too large
660 * @throws { BusinessError } 13900025 - No space left on device
661 * @throws { BusinessError } 13900027 - Read-only file system
662 * @throws { BusinessError } 13900029 - Resource deadlock would occur
663 * @throws { BusinessError } 13900030 - File name too long
664 * @throws { BusinessError } 13900033 - Too many symbolic links encountered
665 * @throws { BusinessError } 13900034 - Operation would block
666 * @throws { BusinessError } 13900038 - Value too large for defined data type
667 * @throws { BusinessError } 13900041 - Quota exceeded
668 * @throws { BusinessError } 13900042 - Unknown error
669 * @throws { BusinessError } 13900044 - Network is unreachable
670 * @syscap SystemCapability.FileManagement.File.FileIO
671 * @since 20
672 */
673function createStream(path: string, mode: string): Promise<Stream>;
674
675/**
676 * Create class Stream.
677 *
678 * @param { string } path - path.
679 * @param { string } mode - mode.
680 * @param { AsyncCallback<Stream> } callback - callback.
681 * @throws { BusinessError } 13900001 - Operation not permitted
682 * @throws { BusinessError } 13900002 - No such file or directory
683 * @throws { BusinessError } 13900004 - Interrupted system call
684 * @throws { BusinessError } 13900006 - No such device or address
685 * @throws { BusinessError } 13900008 - Bad file descriptor
686 * @throws { BusinessError } 13900011 - Out of memory
687 * @throws { BusinessError } 13900012 - Permission denied
688 * @throws { BusinessError } 13900013 - Bad address
689 * @throws { BusinessError } 13900014 - Device or resource busy
690 * @throws { BusinessError } 13900015 - File exists
691 * @throws { BusinessError } 13900017 - No such device
692 * @throws { BusinessError } 13900018 - Not a directory
693 * @throws { BusinessError } 13900019 - Is a directory
694 * @throws { BusinessError } 13900020 - Invalid argument
695 * @throws { BusinessError } 13900022 - Too many open files
696 * @throws { BusinessError } 13900023 - Text file busy
697 * @throws { BusinessError } 13900024 - File too large
698 * @throws { BusinessError } 13900025 - No space left on device
699 * @throws { BusinessError } 13900027 - Read-only file system
700 * @throws { BusinessError } 13900029 - Resource deadlock would occur
701 * @throws { BusinessError } 13900030 - File name too long
702 * @throws { BusinessError } 13900033 - Too many symbolic links encountered
703 * @throws { BusinessError } 13900034 - Operation would block
704 * @throws { BusinessError } 13900038 - Value too large for defined data type
705 * @throws { BusinessError } 13900041 - Quota exceeded
706 * @throws { BusinessError } 13900042 - Unknown error
707 * @syscap SystemCapability.FileManagement.File.FileIO
708 * @since 20
709 */
710function createStream(path: string, mode: string, callback: AsyncCallback<Stream>): void;
711
712/**
713 * Create class Stream with sync interface.
714 *
715 * @param { string } path - path.
716 * @param { string } mode - mode.
717 * @returns { Stream } createStream
718 * @throws { BusinessError } 13900001 - Operation not permitted
719 * @throws { BusinessError } 13900002 - No such file or directory
720 * @throws { BusinessError } 13900004 - Interrupted system call
721 * @throws { BusinessError } 13900006 - No such device or address
722 * @throws { BusinessError } 13900008 - Bad file descriptor
723 * @throws { BusinessError } 13900011 - Out of memory
724 * @throws { BusinessError } 13900012 - Permission denied
725 * @throws { BusinessError } 13900013 - Bad address
726 * @throws { BusinessError } 13900014 - Device or resource busy
727 * @throws { BusinessError } 13900015 - File exists
728 * @throws { BusinessError } 13900017 - No such device
729 * @throws { BusinessError } 13900018 - Not a directory
730 * @throws { BusinessError } 13900019 - Is a directory
731 * @throws { BusinessError } 13900020 - Invalid argument
732 * @throws { BusinessError } 13900022 - Too many open files
733 * @throws { BusinessError } 13900023 - Text file busy
734 * @throws { BusinessError } 13900024 - File too large
735 * @throws { BusinessError } 13900025 - No space left on device
736 * @throws { BusinessError } 13900027 - Read-only file system
737 * @throws { BusinessError } 13900029 - Resource deadlock would occur
738 * @throws { BusinessError } 13900030 - File name too long
739 * @throws { BusinessError } 13900033 - Too many symbolic links encountered
740 * @throws { BusinessError } 13900034 - Operation would block
741 * @throws { BusinessError } 13900038 - Value too large for defined data type
742 * @throws { BusinessError } 13900041 - Quota exceeded
743 * @throws { BusinessError } 13900042 - Unknown error
744 * @throws { BusinessError } 13900044 - Network is unreachable
745 * @syscap SystemCapability.FileManagement.File.FileIO
746 * @since 20
747 */
748function createStreamSync(path: string, mode: string): Stream;
749
750/**
751 * Create class RandomAccessFile.
752 *
753 * @param { string | File } file - file path, object.
754 * @param { number } [mode = OpenMode.READ_ONLY] - mode.
755 * @param { RandomAccessFileOptions } [options] - RandomAccessFile options
756 * @returns { Promise<RandomAccessFile> } Returns the RandomAccessFile object which has been created in promise mode.
757 * @throws { BusinessError } 13900001 - Operation not permitted
758 * @throws { BusinessError } 13900002 - No such file or directory
759 * @throws { BusinessError } 13900004 - Interrupted system call
760 * @throws { BusinessError } 13900006 - No such device or address
761 * @throws { BusinessError } 13900008 - Bad file descriptor
762 * @throws { BusinessError } 13900011 - Out of memory
763 * @throws { BusinessError } 13900012 - Permission denied
764 * @throws { BusinessError } 13900013 - Bad address
765 * @throws { BusinessError } 13900014 - Device or resource busy
766 * @throws { BusinessError } 13900015 - File exists
767 * @throws { BusinessError } 13900017 - No such device
768 * @throws { BusinessError } 13900018 - Not a directory
769 * @throws { BusinessError } 13900019 - Is a directory
770 * @throws { BusinessError } 13900020 - Invalid argument
771 * @throws { BusinessError } 13900022 - Too many open files
772 * @throws { BusinessError } 13900023 - Text file busy
773 * @throws { BusinessError } 13900024 - File too large
774 * @throws { BusinessError } 13900025 - No space left on device
775 * @throws { BusinessError } 13900027 - Read-only file system
776 * @throws { BusinessError } 13900029 - Resource deadlock would occur
777 * @throws { BusinessError } 13900030 - File name too long
778 * @throws { BusinessError } 13900033 - Too many symbolic links encountered
779 * @throws { BusinessError } 13900034 - Operation would block
780 * @throws { BusinessError } 13900038 - Value too large for defined data type
781 * @throws { BusinessError } 13900041 - Quota exceeded
782 * @throws { BusinessError } 13900042 - Unknown error
783 * @throws { BusinessError } 13900044 - Network is unreachable
784 * @syscap SystemCapability.FileManagement.File.FileIO
785 * @since 20
786 */
787function createRandomAccessFile(file: string | File, mode?: number,
788  options?: RandomAccessFileOptions): Promise<RandomAccessFile>;
789
790/**
791 * Create class RandomAccessFile.
792 *
793 * @param { string | File } file - file path, object.
794 * @param { AsyncCallback<RandomAccessFile> } callback - The callback is used to return the RandomAccessFile object which has been created.
795 * @throws { BusinessError } 13900001 - Operation not permitted
796 * @throws { BusinessError } 13900002 - No such file or directory
797 * @throws { BusinessError } 13900004 - Interrupted system call
798 * @throws { BusinessError } 13900006 - No such device or address
799 * @throws { BusinessError } 13900008 - Bad file descriptor
800 * @throws { BusinessError } 13900011 - Out of memory
801 * @throws { BusinessError } 13900012 - Permission denied
802 * @throws { BusinessError } 13900013 - Bad address
803 * @throws { BusinessError } 13900014 - Device or resource busy
804 * @throws { BusinessError } 13900015 - File exists
805 * @throws { BusinessError } 13900017 - No such device
806 * @throws { BusinessError } 13900018 - Not a directory
807 * @throws { BusinessError } 13900019 - Is a directory
808 * @throws { BusinessError } 13900020 - Invalid argument
809 * @throws { BusinessError } 13900022 - Too many open files
810 * @throws { BusinessError } 13900023 - Text file busy
811 * @throws { BusinessError } 13900024 - File too large
812 * @throws { BusinessError } 13900025 - No space left on device
813 * @throws { BusinessError } 13900027 - Read-only file system
814 * @throws { BusinessError } 13900029 - Resource deadlock would occur
815 * @throws { BusinessError } 13900030 - File name too long
816 * @throws { BusinessError } 13900033 - Too many symbolic links encountered
817 * @throws { BusinessError } 13900034 - Operation would block
818 * @throws { BusinessError } 13900038 - Value too large for defined data type
819 * @throws { BusinessError } 13900041 - Quota exceeded
820 * @throws { BusinessError } 13900042 - Unknown error
821 * @syscap SystemCapability.FileManagement.File.FileIO
822 * @since 20
823 */
824function createRandomAccessFile(file: string | File, callback: AsyncCallback<RandomAccessFile>): void;
825
826/**
827 * Create class RandomAccessFile.
828 *
829 * @param { string | File } file - file path, object.
830 * @param { number } [mode = OpenMode.READ_ONLY] - mode.
831 * @param { AsyncCallback<RandomAccessFile> } callback - The callback is used to return the RandomAccessFile object which has been created.
832 * @throws { BusinessError } 13900001 - Operation not permitted
833 * @throws { BusinessError } 13900002 - No such file or directory
834 * @throws { BusinessError } 13900004 - Interrupted system call
835 * @throws { BusinessError } 13900006 - No such device or address
836 * @throws { BusinessError } 13900008 - Bad file descriptor
837 * @throws { BusinessError } 13900011 - Out of memory
838 * @throws { BusinessError } 13900012 - Permission denied
839 * @throws { BusinessError } 13900013 - Bad address
840 * @throws { BusinessError } 13900014 - Device or resource busy
841 * @throws { BusinessError } 13900015 - File exists
842 * @throws { BusinessError } 13900017 - No such device
843 * @throws { BusinessError } 13900018 - Not a directory
844 * @throws { BusinessError } 13900019 - Is a directory
845 * @throws { BusinessError } 13900020 - Invalid argument
846 * @throws { BusinessError } 13900022 - Too many open files
847 * @throws { BusinessError } 13900023 - Text file busy
848 * @throws { BusinessError } 13900024 - File too large
849 * @throws { BusinessError } 13900025 - No space left on device
850 * @throws { BusinessError } 13900027 - Read-only file system
851 * @throws { BusinessError } 13900029 - Resource deadlock would occur
852 * @throws { BusinessError } 13900030 - File name too long
853 * @throws { BusinessError } 13900033 - Too many symbolic links encountered
854 * @throws { BusinessError } 13900034 - Operation would block
855 * @throws { BusinessError } 13900038 - Value too large for defined data type
856 * @throws { BusinessError } 13900041 - Quota exceeded
857 * @throws { BusinessError } 13900042 - Unknown error
858 * @syscap SystemCapability.FileManagement.File.FileIO
859 * @since 20
860 */
861function createRandomAccessFile(file: string | File, mode: number, callback: AsyncCallback<RandomAccessFile>): void;
862
863/**
864 * Create class RandomAccessFile with sync interface.
865 *
866 * @param { string | File } file - file path, object.
867 * @param { number } [mode = OpenMode.READ_ONLY] - mode.
868 * @param { RandomAccessFileOptions } [options] - RandomAccessFile options
869 * @returns { RandomAccessFile } Returns the RandomAccessFile object which has been created.
870 * @throws { BusinessError } 13900001 - Operation not permitted
871 * @throws { BusinessError } 13900002 - No such file or directory
872 * @throws { BusinessError } 13900004 - Interrupted system call
873 * @throws { BusinessError } 13900006 - No such device or address
874 * @throws { BusinessError } 13900008 - Bad file descriptor
875 * @throws { BusinessError } 13900011 - Out of memory
876 * @throws { BusinessError } 13900012 - Permission denied
877 * @throws { BusinessError } 13900013 - Bad address
878 * @throws { BusinessError } 13900014 - Device or resource busy
879 * @throws { BusinessError } 13900015 - File exists
880 * @throws { BusinessError } 13900017 - No such device
881 * @throws { BusinessError } 13900018 - Not a directory
882 * @throws { BusinessError } 13900019 - Is a directory
883 * @throws { BusinessError } 13900020 - Invalid argument
884 * @throws { BusinessError } 13900022 - Too many open files
885 * @throws { BusinessError } 13900023 - Text file busy
886 * @throws { BusinessError } 13900024 - File too large
887 * @throws { BusinessError } 13900025 - No space left on device
888 * @throws { BusinessError } 13900027 - Read-only file system
889 * @throws { BusinessError } 13900029 - Resource deadlock would occur
890 * @throws { BusinessError } 13900030 - File name too long
891 * @throws { BusinessError } 13900033 - Too many symbolic links encountered
892 * @throws { BusinessError } 13900034 - Operation would block
893 * @throws { BusinessError } 13900038 - Value too large for defined data type
894 * @throws { BusinessError } 13900041 - Quota exceeded
895 * @throws { BusinessError } 13900042 - Unknown error
896 * @throws { BusinessError } 13900044 - Network is unreachable
897 * @syscap SystemCapability.FileManagement.File.FileIO
898 * @since 20
899 */
900function createRandomAccessFileSync(file: string | File, mode?: number,
901  options?: RandomAccessFileOptions): RandomAccessFile;
902
903/**
904 * Create watcher to listen for file changes.
905 *
906 * @param { string } path - path.
907 * @param { number } events - listened events.
908 * @param { WatchEventListener } listener - Callback to invoke when an event of the specified type occurs.
909 * @returns { Watcher } Returns the Watcher object which has been created.
910 * @throws { BusinessError } 13900002 - No such file or directory
911 * @throws { BusinessError } 13900008 - Bad file descriptor
912 * @throws { BusinessError } 13900011 - Out of memory
913 * @throws { BusinessError } 13900012 - Permission denied
914 * @throws { BusinessError } 13900013 - Bad address
915 * @throws { BusinessError } 13900015 - File exists
916 * @throws { BusinessError } 13900018 - Not a directory
917 * @throws { BusinessError } 13900020 - Invalid argument
918 * @throws { BusinessError } 13900021 - File table overflow
919 * @throws { BusinessError } 13900022 - Too many open files
920 * @throws { BusinessError } 13900025 - No space left on device
921 * @throws { BusinessError } 13900030 - File name too long
922 * @throws { BusinessError } 13900042 - Unknown error
923 * @syscap SystemCapability.FileManagement.File.FileIO
924 * @since 20
925 */
926function createWatcher(path: string, events: number, listener: WatchEventListener): Watcher;
927
928/**
929 * Duplicate fd to File Object.
930 *
931 * @param { number } fd - fd.
932 * @returns { File } return File
933 * @throws { BusinessError } 13900004 - Interrupted system call
934 * @throws { BusinessError } 13900005 - I/O error
935 * @throws { BusinessError } 13900008 - Bad file descriptor
936 * @throws { BusinessError } 13900014 - Device or resource busy
937 * @throws { BusinessError } 13900020 - Invalid argument
938 * @throws { BusinessError } 13900022 - Too many open files
939 * @throws { BusinessError } 13900042 - Unknown error
940 * @syscap SystemCapability.FileManagement.File.FileIO
941 * @since 20
942 */
943function dup(fd: number): File;
944
945/**
946 * Synchronize file metadata.
947 *
948 * @param { number } fd - fd.
949 * @returns { Promise<void> } The promise returned by the function.
950 * @throws { BusinessError } 13900005 - I/O error
951 * @throws { BusinessError } 13900008 - Bad file descriptor
952 * @throws { BusinessError } 13900020 - Invalid argument
953 * @throws { BusinessError } 13900025 - No space left on device
954 * @throws { BusinessError } 13900027 - Read-only file system
955 * @throws { BusinessError } 13900041 - Quota exceeded
956 * @throws { BusinessError } 13900042 - Unknown error
957 * @syscap SystemCapability.FileManagement.File.FileIO
958 * @since 20
959 */
960function fdatasync(fd: number): Promise<void>;
961
962/**
963 * Synchronize file metadata.
964 *
965 * @param { number } fd - fd.
966 * @param { AsyncCallback<void> } callback - Return the callback function.
967 * @throws { BusinessError } 13900005 - I/O error
968 * @throws { BusinessError } 13900008 - Bad file descriptor
969 * @throws { BusinessError } 13900020 - Invalid argument
970 * @throws { BusinessError } 13900025 - No space left on device
971 * @throws { BusinessError } 13900027 - Read-only file system
972 * @throws { BusinessError } 13900041 - Quota exceeded
973 * @throws { BusinessError } 13900042 - Unknown error
974 * @syscap SystemCapability.FileManagement.File.FileIO
975 * @since 20
976 */
977function fdatasync(fd: number, callback: AsyncCallback<void>): void;
978
979/**
980 * Synchronize file metadata with sync interface.
981 *
982 * @param { number } fd - fd.
983 * @throws { BusinessError } 13900005 - I/O error
984 * @throws { BusinessError } 13900008 - Bad file descriptor
985 * @throws { BusinessError } 13900020 - Invalid argument
986 * @throws { BusinessError } 13900025 - No space left on device
987 * @throws { BusinessError } 13900027 - Read-only file system
988 * @throws { BusinessError } 13900041 - Quota exceeded
989 * @throws { BusinessError } 13900042 - Unknown error
990 * @syscap SystemCapability.FileManagement.File.FileIO
991 * @since 20
992 */
993function fdatasyncSync(fd: number): void;
994
995/**
996 * Create class Stream by using fd.
997 *
998 * @param { number } fd - fd.
999 * @param { string } mode - mode.
1000 * @returns { Promise<Stream> } Returns the Stream object in promise mode.
1001 * @throws { BusinessError } 13900001 - Operation not permitted
1002 * @throws { BusinessError } 13900002 - No such file or directory
1003 * @throws { BusinessError } 13900004 - Interrupted system call
1004 * @throws { BusinessError } 13900006 - No such device or address
1005 * @throws { BusinessError } 13900008 - Bad file descriptor
1006 * @throws { BusinessError } 13900010 - Try again
1007 * @throws { BusinessError } 13900011 - Out of memory
1008 * @throws { BusinessError } 13900012 - Permission denied
1009 * @throws { BusinessError } 13900013 - Bad address
1010 * @throws { BusinessError } 13900014 - Device or resource busy
1011 * @throws { BusinessError } 13900015 - File exists
1012 * @throws { BusinessError } 13900017 - No such device
1013 * @throws { BusinessError } 13900018 - Not a directory
1014 * @throws { BusinessError } 13900019 - Is a directory
1015 * @throws { BusinessError } 13900020 - Invalid argument
1016 * @throws { BusinessError } 13900022 - Too many open files
1017 * @throws { BusinessError } 13900023 - Text file busy
1018 * @throws { BusinessError } 13900024 - File too large
1019 * @throws { BusinessError } 13900025 - No space left on device
1020 * @throws { BusinessError } 13900027 - Read-only file system
1021 * @throws { BusinessError } 13900029 - Resource deadlock would occur
1022 * @throws { BusinessError } 13900030 - File name too long
1023 * @throws { BusinessError } 13900033 - Too many symbolic links encountered
1024 * @throws { BusinessError } 13900034 - Operation would block
1025 * @throws { BusinessError } 13900038 - Value too large for defined data type
1026 * @throws { BusinessError } 13900041 - Quota exceeded
1027 * @throws { BusinessError } 13900042 - Unknown error
1028 * @syscap SystemCapability.FileManagement.File.FileIO
1029 * @since 20
1030 */
1031function fdopenStream(fd: number, mode: string): Promise<Stream>;
1032
1033/**
1034 * Create class Stream by using fd.
1035 *
1036 * @param { number } fd - fd.
1037 * @param { string } mode - mode.
1038 * @param { AsyncCallback<Stream> } callback - The callback is used to return the Stream object.
1039 * @throws { BusinessError } 13900001 - Operation not permitted
1040 * @throws { BusinessError } 13900002 - No such file or directory
1041 * @throws { BusinessError } 13900004 - Interrupted system call
1042 * @throws { BusinessError } 13900006 - No such device or address
1043 * @throws { BusinessError } 13900008 - Bad file descriptor
1044 * @throws { BusinessError } 13900010 - Try again
1045 * @throws { BusinessError } 13900011 - Out of memory
1046 * @throws { BusinessError } 13900012 - Permission denied
1047 * @throws { BusinessError } 13900013 - Bad address
1048 * @throws { BusinessError } 13900014 - Device or resource busy
1049 * @throws { BusinessError } 13900015 - File exists
1050 * @throws { BusinessError } 13900017 - No such device
1051 * @throws { BusinessError } 13900018 - Not a directory
1052 * @throws { BusinessError } 13900019 - Is a directory
1053 * @throws { BusinessError } 13900020 - Invalid argument
1054 * @throws { BusinessError } 13900022 - Too many open files
1055 * @throws { BusinessError } 13900023 - Text file busy
1056 * @throws { BusinessError } 13900024 - File too large
1057 * @throws { BusinessError } 13900025 - No space left on device
1058 * @throws { BusinessError } 13900027 - Read-only file system
1059 * @throws { BusinessError } 13900029 - Resource deadlock would occur
1060 * @throws { BusinessError } 13900030 - File name too long
1061 * @throws { BusinessError } 13900033 - Too many symbolic links encountered
1062 * @throws { BusinessError } 13900034 - Operation would block
1063 * @throws { BusinessError } 13900038 - Value too large for defined data type
1064 * @throws { BusinessError } 13900041 - Quota exceeded
1065 * @throws { BusinessError } 13900042 - Unknown error
1066 * @syscap SystemCapability.FileManagement.File.FileIO
1067 * @since 20
1068 */
1069function fdopenStream(fd: number, mode: string, callback: AsyncCallback<Stream>): void;
1070
1071/**
1072 * Create class Stream by using fd with sync interface.
1073 *
1074 * @param { number } fd - fd.
1075 * @param { string } mode - mode.
1076 * @returns { Stream } Returns the Stream object.
1077 * @throws { BusinessError } 13900001 - Operation not permitted
1078 * @throws { BusinessError } 13900002 - No such file or directory
1079 * @throws { BusinessError } 13900004 - Interrupted system call
1080 * @throws { BusinessError } 13900006 - No such device or address
1081 * @throws { BusinessError } 13900008 - Bad file descriptor
1082 * @throws { BusinessError } 13900010 - Try again
1083 * @throws { BusinessError } 13900011 - Out of memory
1084 * @throws { BusinessError } 13900012 - Permission denied
1085 * @throws { BusinessError } 13900013 - Bad address
1086 * @throws { BusinessError } 13900014 - Device or resource busy
1087 * @throws { BusinessError } 13900015 - File exists
1088 * @throws { BusinessError } 13900017 - No such device
1089 * @throws { BusinessError } 13900018 - Not a directory
1090 * @throws { BusinessError } 13900019 - Is a directory
1091 * @throws { BusinessError } 13900020 - Invalid argument
1092 * @throws { BusinessError } 13900022 - Too many open files
1093 * @throws { BusinessError } 13900023 - Text file busy
1094 * @throws { BusinessError } 13900024 - File too large
1095 * @throws { BusinessError } 13900025 - No space left on device
1096 * @throws { BusinessError } 13900027 - Read-only file system
1097 * @throws { BusinessError } 13900029 - Resource deadlock would occur
1098 * @throws { BusinessError } 13900030 - File name too long
1099 * @throws { BusinessError } 13900033 - Too many symbolic links encountered
1100 * @throws { BusinessError } 13900034 - Operation would block
1101 * @throws { BusinessError } 13900038 - Value too large for defined data type
1102 * @throws { BusinessError } 13900041 - Quota exceeded
1103 * @throws { BusinessError } 13900042 - Unknown error
1104 * @syscap SystemCapability.FileManagement.File.FileIO
1105 * @since 20
1106 */
1107function fdopenStreamSync(fd: number, mode: string): Stream;
1108
1109/**
1110 * Synchronize file.
1111 *
1112 * @param { number } fd - fd.
1113 * @returns { Promise<void> } The promise returned by the function.
1114 * @throws { BusinessError } 13900005 - I/O error
1115 * @throws { BusinessError } 13900008 - Bad file descriptor
1116 * @throws { BusinessError } 13900020 - Invalid argument
1117 * @throws { BusinessError } 13900025 - No space left on device
1118 * @throws { BusinessError } 13900027 - Read-only file system
1119 * @throws { BusinessError } 13900041 - Quota exceeded
1120 * @throws { BusinessError } 13900042 - Unknown error
1121 * @syscap SystemCapability.FileManagement.File.FileIO
1122 * @since 20
1123 */
1124function fsync(fd: number): Promise<void>;
1125
1126/**
1127 * Synchronize file.
1128 *
1129 * @param { number } fd - fd.
1130 * @param { AsyncCallback<void> } callback - Return the callback function.
1131 * @throws { BusinessError } 13900005 - I/O error
1132 * @throws { BusinessError } 13900008 - Bad file descriptor
1133 * @throws { BusinessError } 13900020 - Invalid argument
1134 * @throws { BusinessError } 13900025 - No space left on device
1135 * @throws { BusinessError } 13900027 - Read-only file system
1136 * @throws { BusinessError } 13900041 - Quota exceeded
1137 * @throws { BusinessError } 13900042 - Unknown error
1138 * @syscap SystemCapability.FileManagement.File.FileIO
1139 * @since 20
1140 */
1141function fsync(fd: number, callback: AsyncCallback<void>): void;
1142
1143/**
1144 * Synchronize file with sync interface.
1145 *
1146 * @param { number } fd - fd.
1147 * @throws { BusinessError } 13900005 - I/O error
1148 * @throws { BusinessError } 13900008 - Bad file descriptor
1149 * @throws { BusinessError } 13900020 - Invalid argument
1150 * @throws { BusinessError } 13900025 - No space left on device
1151 * @throws { BusinessError } 13900027 - Read-only file system
1152 * @throws { BusinessError } 13900041 - Quota exceeded
1153 * @throws { BusinessError } 13900042 - Unknown error
1154 * @syscap SystemCapability.FileManagement.File.FileIO
1155 * @since 20
1156 */
1157function fsyncSync(fd: number): void;
1158
1159/**
1160 * List file.
1161 *
1162 * @param { string } path - path.
1163 * @param { ListFileOptions } [options] - options.
1164 * @returns { Promise<string[]> } Returns an Array containing the name of files or directories that meet the filter criteria.
1165 *      If present, Include the subdirectory structure.
1166 * @throws { BusinessError } 13900002 - No such file or directory
1167 * @throws { BusinessError } 13900008 - Bad file descriptor
1168 * @throws { BusinessError } 13900011 - Out of memory
1169 * @throws { BusinessError } 13900018 - Not a directory
1170 * @throws { BusinessError } 13900042 - Unknown error
1171 * @syscap SystemCapability.FileManagement.File.FileIO
1172 * @since 20
1173 */
1174function listFile(
1175  path: string,
1176  options?: ListFileOptions
1177): Promise<string[]>;
1178
1179/**
1180 * List file.
1181 *
1182 * @param { string } path - path.
1183 * @param { AsyncCallback<string[]> } callback - The callback is used to return an Array containing the name of files or directories
1184 *      that meet the filter criteria in promise mode. If present, Include the subdirectory structure.
1185 * @throws { BusinessError } 13900002 - No such file or directory
1186 * @throws { BusinessError } 13900008 - Bad file descriptor
1187 * @throws { BusinessError } 13900011 - Out of memory
1188 * @throws { BusinessError } 13900018 - Not a directory
1189 * @throws { BusinessError } 13900042 - Unknown error
1190 * @syscap SystemCapability.FileManagement.File.FileIO
1191 * @since 20
1192 */
1193function listFile(path: string, callback: AsyncCallback<string[]>): void;
1194
1195/**
1196 * List file.
1197 *
1198 * @param { string } path - path.
1199 * @param { ListFileOptions } [options] - options.
1200 * @param { AsyncCallback<string[]> } callback - The callback is used to return an Array containing the name of files or directories
1201 *      that meet the filter criteria in promise mode. If present, Include the subdirectory structure.
1202 * @throws { BusinessError } 13900002 - No such file or directory
1203 * @throws { BusinessError } 13900008 - Bad file descriptor
1204 * @throws { BusinessError } 13900011 - Out of memory
1205 * @throws { BusinessError } 13900018 - Not a directory
1206 * @throws { BusinessError } 13900042 - Unknown error
1207 * @syscap SystemCapability.FileManagement.File.FileIO
1208 * @since 20
1209 */
1210function listFile(
1211  path: string,
1212  options: ListFileOptions,
1213  callback: AsyncCallback<string[]>
1214): void;
1215
1216/**
1217 * List file with sync interface.
1218 *
1219 * @param { string } path - path.
1220 * @param { ListFileOptions } [options] - options.
1221 * @returns { string[] } Returns an Array containing the name of files or directories that meet the filter criteria.
1222 * @throws { BusinessError } 13900002 - No such file or directory
1223 * @throws { BusinessError } 13900008 - Bad file descriptor
1224 * @throws { BusinessError } 13900011 - Out of memory
1225 * @throws { BusinessError } 13900018 - Not a directory
1226 * @throws { BusinessError } 13900042 - Unknown error
1227 * @syscap SystemCapability.FileManagement.File.FileIO
1228 * @since 20
1229 */
1230function listFileSync(
1231  path: string,
1232  options?: ListFileOptions
1233): string[];
1234
1235/**
1236 *  Reposition file offset.
1237 *
1238 * @param { number } fd - file descriptor.
1239 * @param { number } offset - file offset.
1240 * @param { WhenceType } [whence = WhenceType.SEEK_SET] - directive whence.
1241 * @returns { number } Returns the file offset relative to starting position of file.
1242 * @throws { BusinessError } 13900008 - Bad file descriptor
1243 * @throws { BusinessError } 13900020 - Invalid argument
1244 * @throws { BusinessError } 13900026 - Illegal seek
1245 * @throws { BusinessError } 13900038 - Value too large for defined data type
1246 * @throws { BusinessError } 13900042 - Unknown error
1247 * @syscap SystemCapability.FileManagement.File.FileIO
1248 * @since 20
1249 */
1250function lseek(fd: number, offset: number, whence?: WhenceType): number;
1251
1252/**
1253 * Stat link file.
1254 *
1255 * @param { string } path - path.
1256 * @returns { Promise<Stat> } Returns the Stat object in promise mode.
1257 * @throws { BusinessError } 13900002 - No such file or directory
1258 * @throws { BusinessError } 13900008 - Bad file descriptor
1259 * @throws { BusinessError } 13900011 - Out of memory
1260 * @throws { BusinessError } 13900012 - Permission denied
1261 * @throws { BusinessError } 13900013 - Bad address
1262 * @throws { BusinessError } 13900018 - Not a directory
1263 * @throws { BusinessError } 13900030 - File name too long
1264 * @throws { BusinessError } 13900033 - Too many symbolic links encountered
1265 * @throws { BusinessError } 13900038 - Value too large for defined data type
1266 * @throws { BusinessError } 13900042 - Unknown error
1267 * @syscap SystemCapability.FileManagement.File.FileIO
1268 * @since 20
1269 */
1270function lstat(path: string): Promise<Stat>;
1271
1272/**
1273 * Stat link file.
1274 *
1275 * @param { string } path - path.
1276 * @param { AsyncCallback<Stat> } callback - The callback is used to return the Stat object.
1277 * @throws { BusinessError } 13900002 - No such file or directory
1278 * @throws { BusinessError } 13900008 - Bad file descriptor
1279 * @throws { BusinessError } 13900011 - Out of memory
1280 * @throws { BusinessError } 13900012 - Permission denied
1281 * @throws { BusinessError } 13900013 - Bad address
1282 * @throws { BusinessError } 13900018 - Not a directory
1283 * @throws { BusinessError } 13900030 - File name too long
1284 * @throws { BusinessError } 13900033 - Too many symbolic links encountered
1285 * @throws { BusinessError } 13900038 - Value too large for defined data type
1286 * @throws { BusinessError } 13900042 - Unknown error
1287 * @syscap SystemCapability.FileManagement.File.FileIO
1288 * @since 20
1289 */
1290function lstat(path: string, callback: AsyncCallback<Stat>): void;
1291
1292/**
1293 * Stat link file with sync interface.
1294 *
1295 * @param { string } path - path.
1296 * @returns { Stat } Returns the Stat object.
1297 * @throws { BusinessError } 13900002 - No such file or directory
1298 * @throws { BusinessError } 13900008 - Bad file descriptor
1299 * @throws { BusinessError } 13900011 - Out of memory
1300 * @throws { BusinessError } 13900012 - Permission denied
1301 * @throws { BusinessError } 13900013 - Bad address
1302 * @throws { BusinessError } 13900018 - Not a directory
1303 * @throws { BusinessError } 13900030 - File name too long
1304 * @throws { BusinessError } 13900033 - Too many symbolic links encountered
1305 * @throws { BusinessError } 13900038 - Value too large for defined data type
1306 * @throws { BusinessError } 13900042 - Unknown error
1307 * @syscap SystemCapability.FileManagement.File.FileIO
1308 * @since 20
1309 */
1310function lstatSync(path: string): Stat;
1311
1312/**
1313 * Make dir.
1314 *
1315 * @param { string } path - path.
1316 * @returns { Promise<void> } The promise returned by the function.
1317 * @throws { BusinessError } 13900001 - Operation not permitted
1318 * @throws { BusinessError } 13900002 - No such file or directory
1319 * @throws { BusinessError } 13900008 - Bad file descriptor
1320 * @throws { BusinessError } 13900011 - Out of memory
1321 * @throws { BusinessError } 13900012 - Permission denied
1322 * @throws { BusinessError } 13900013 - Bad address
1323 * @throws { BusinessError } 13900015 - File exists
1324 * @throws { BusinessError } 13900018 - Not a directory
1325 * @throws { BusinessError } 13900020 - Invalid argument
1326 * @throws { BusinessError } 13900025 - No space left on device
1327 * @throws { BusinessError } 13900028 - Too many links
1328 * @throws { BusinessError } 13900030 - File name too long
1329 * @throws { BusinessError } 13900033 - Too many symbolic links encountered
1330 * @throws { BusinessError } 13900041 - Quota exceeded
1331 * @throws { BusinessError } 13900042 - Unknown error
1332 * @syscap SystemCapability.FileManagement.File.FileIO
1333 * @since 20
1334 */
1335function mkdir(path: string): Promise<void>;
1336
1337/**
1338 * Make dir.
1339 *
1340 * @param { string } path - path.
1341 * @param { boolean } recursion - whether to recursively make directory.
1342 * @returns { Promise<void> } The promise returned by the function.
1343 * @throws { BusinessError } 13900001 - Operation not permitted
1344 * @throws { BusinessError } 13900002 - No such file or directory
1345 * @throws { BusinessError } 13900008 - Bad file descriptor
1346 * @throws { BusinessError } 13900011 - Out of memory
1347 * @throws { BusinessError } 13900012 - Permission denied
1348 * @throws { BusinessError } 13900013 - Bad address
1349 * @throws { BusinessError } 13900015 - File exists
1350 * @throws { BusinessError } 13900018 - Not a directory
1351 * @throws { BusinessError } 13900020 - Invalid argument
1352 * @throws { BusinessError } 13900025 - No space left on device
1353 * @throws { BusinessError } 13900028 - Too many links
1354 * @throws { BusinessError } 13900030 - File name too long
1355 * @throws { BusinessError } 13900033 - Too many symbolic links encountered
1356 * @throws { BusinessError } 13900041 - Quota exceeded
1357 * @throws { BusinessError } 13900042 - Unknown error
1358 * @syscap SystemCapability.FileManagement.File.FileIO
1359 * @since 20
1360 */
1361function mkdir(path: string, recursion: boolean): Promise<void>;
1362
1363/**
1364 * Make dir.
1365 *
1366 * @param { string } path - path.
1367 * @param { AsyncCallback<void> } callback - Return the callback function.
1368 * @throws { BusinessError } 13900001 - Operation not permitted
1369 * @throws { BusinessError } 13900002 - No such file or directory
1370 * @throws { BusinessError } 13900008 - Bad file descriptor
1371 * @throws { BusinessError } 13900011 - Out of memory
1372 * @throws { BusinessError } 13900012 - Permission denied
1373 * @throws { BusinessError } 13900013 - Bad address
1374 * @throws { BusinessError } 13900015 - File exists
1375 * @throws { BusinessError } 13900018 - Not a directory
1376 * @throws { BusinessError } 13900020 - Invalid argument
1377 * @throws { BusinessError } 13900025 - No space left on device
1378 * @throws { BusinessError } 13900028 - Too many links
1379 * @throws { BusinessError } 13900030 - File name too long
1380 * @throws { BusinessError } 13900033 - Too many symbolic links encountered
1381 * @throws { BusinessError } 13900041 - Quota exceeded
1382 * @throws { BusinessError } 13900042 - Unknown error
1383 * @syscap SystemCapability.FileManagement.File.FileIO
1384 * @since 20
1385 */
1386function mkdir(path: string, callback: AsyncCallback<void>): void;
1387
1388/**
1389 * Make dir.
1390 *
1391 * @param { string } path - path.
1392 * @param { boolean } recursion - whether to recursively make directory.
1393 * @param { AsyncCallback<void> } callback - Return the callback function.
1394 * @throws { BusinessError } 13900001 - Operation not permitted
1395 * @throws { BusinessError } 13900002 - No such file or directory
1396 * @throws { BusinessError } 13900008 - Bad file descriptor
1397 * @throws { BusinessError } 13900011 - Out of memory
1398 * @throws { BusinessError } 13900012 - Permission denied
1399 * @throws { BusinessError } 13900013 - Bad address
1400 * @throws { BusinessError } 13900015 - File exists
1401 * @throws { BusinessError } 13900018 - Not a directory
1402 * @throws { BusinessError } 13900020 - Invalid argument
1403 * @throws { BusinessError } 13900025 - No space left on device
1404 * @throws { BusinessError } 13900028 - Too many links
1405 * @throws { BusinessError } 13900030 - File name too long
1406 * @throws { BusinessError } 13900033 - Too many symbolic links encountered
1407 * @throws { BusinessError } 13900041 - Quota exceeded
1408 * @throws { BusinessError } 13900042 - Unknown error
1409 * @syscap SystemCapability.FileManagement.File.FileIO
1410 * @since 20
1411 */
1412function mkdir(path: string, recursion: boolean, callback: AsyncCallback<void>): void;
1413
1414/**
1415 * Make dir with sync interface.
1416 *
1417 * @param { string } path - path.
1418 * @throws { BusinessError } 13900001 - Operation not permitted
1419 * @throws { BusinessError } 13900002 - No such file or directory
1420 * @throws { BusinessError } 13900008 - Bad file descriptor
1421 * @throws { BusinessError } 13900011 - Out of memory
1422 * @throws { BusinessError } 13900012 - Permission denied
1423 * @throws { BusinessError } 13900013 - Bad address
1424 * @throws { BusinessError } 13900015 - File exists
1425 * @throws { BusinessError } 13900018 - Not a directory
1426 * @throws { BusinessError } 13900020 - Invalid argument
1427 * @throws { BusinessError } 13900025 - No space left on device
1428 * @throws { BusinessError } 13900028 - Too many links
1429 * @throws { BusinessError } 13900030 - File name too long
1430 * @throws { BusinessError } 13900033 - Too many symbolic links encountered
1431 * @throws { BusinessError } 13900041 - Quota exceeded
1432 * @throws { BusinessError } 13900042 - Unknown error
1433 * @syscap SystemCapability.FileManagement.File.FileIO
1434 * @since 20
1435 */
1436function mkdirSync(path: string): void;
1437
1438/**
1439 * Make dir with sync interface.
1440 *
1441 * @param { string } path - path.
1442 * @param { boolean } recursion - whether to recursively make directory.
1443 * @throws { BusinessError } 13900001 - Operation not permitted
1444 * @throws { BusinessError } 13900002 - No such file or directory
1445 * @throws { BusinessError } 13900008 - Bad file descriptor
1446 * @throws { BusinessError } 13900011 - Out of memory
1447 * @throws { BusinessError } 13900012 - Permission denied
1448 * @throws { BusinessError } 13900013 - Bad address
1449 * @throws { BusinessError } 13900015 - File exists
1450 * @throws { BusinessError } 13900018 - Not a directory
1451 * @throws { BusinessError } 13900020 - Invalid argument
1452 * @throws { BusinessError } 13900025 - No space left on device
1453 * @throws { BusinessError } 13900028 - Too many links
1454 * @throws { BusinessError } 13900030 - File name too long
1455 * @throws { BusinessError } 13900033 - Too many symbolic links encountered
1456 * @throws { BusinessError } 13900041 - Quota exceeded
1457 * @throws { BusinessError } 13900042 - Unknown error
1458 * @syscap SystemCapability.FileManagement.File.FileIO
1459 * @since 20
1460 */
1461function mkdirSync(path: string, recursion: boolean): void;
1462
1463/**
1464 * Make temp dir.
1465 *
1466 * @param { string } prefix - dir prefix.
1467 * @returns { Promise<string> } Returns the path to the new directory in promise mode.
1468 * @throws { BusinessError } 13900001 - Operation not permitted
1469 * @throws { BusinessError } 13900002 - No such file or directory
1470 * @throws { BusinessError } 13900008 - Bad file descriptor
1471 * @throws { BusinessError } 13900011 - Out of memory
1472 * @throws { BusinessError } 13900012 - Permission denied
1473 * @throws { BusinessError } 13900013 - Bad address
1474 * @throws { BusinessError } 13900015 - File exists
1475 * @throws { BusinessError } 13900018 - Not a directory
1476 * @throws { BusinessError } 13900020 - Invalid argument
1477 * @throws { BusinessError } 13900025 - No space left on device
1478 * @throws { BusinessError } 13900028 - Too many links
1479 * @throws { BusinessError } 13900030 - File name too long
1480 * @throws { BusinessError } 13900033 - Too many symbolic links encountered
1481 * @throws { BusinessError } 13900041 - Quota exceeded
1482 * @throws { BusinessError } 13900042 - Unknown error
1483 * @syscap SystemCapability.FileManagement.File.FileIO
1484 * @since 20
1485 */
1486function mkdtemp(prefix: string): Promise<string>;
1487
1488/**
1489 * Make temp dir.
1490 *
1491 * @param { string } prefix - dir prefix.
1492 * @param { AsyncCallback<string> } callback - The callback is used to return the path to the new directory.
1493 * @throws { BusinessError } 13900001 - Operation not permitted
1494 * @throws { BusinessError } 13900002 - No such file or directory
1495 * @throws { BusinessError } 13900008 - Bad file descriptor
1496 * @throws { BusinessError } 13900011 - Out of memory
1497 * @throws { BusinessError } 13900012 - Permission denied
1498 * @throws { BusinessError } 13900013 - Bad address
1499 * @throws { BusinessError } 13900015 - File exists
1500 * @throws { BusinessError } 13900018 - Not a directory
1501 * @throws { BusinessError } 13900020 - Invalid argument
1502 * @throws { BusinessError } 13900025 - No space left on device
1503 * @throws { BusinessError } 13900028 - Too many links
1504 * @throws { BusinessError } 13900030 - File name too long
1505 * @throws { BusinessError } 13900033 - Too many symbolic links encountered
1506 * @throws { BusinessError } 13900041 - Quota exceeded
1507 * @throws { BusinessError } 13900042 - Unknown error
1508 * @syscap SystemCapability.FileManagement.File.FileIO
1509 * @since 20
1510 */
1511function mkdtemp(prefix: string, callback: AsyncCallback<string>): void;
1512
1513/**
1514 * Make temp dir with sync interface.
1515 *
1516 * @param { string } prefix - dir prefix.
1517 * @returns { string } Returns the path to the new directory.
1518 * @throws { BusinessError } 13900001 - Operation not permitted
1519 * @throws { BusinessError } 13900002 - No such file or directory
1520 * @throws { BusinessError } 13900008 - Bad file descriptor
1521 * @throws { BusinessError } 13900011 - Out of memory
1522 * @throws { BusinessError } 13900012 - Permission denied
1523 * @throws { BusinessError } 13900013 - Bad address
1524 * @throws { BusinessError } 13900015 - File exists
1525 * @throws { BusinessError } 13900018 - Not a directory
1526 * @throws { BusinessError } 13900020 - Invalid argument
1527 * @throws { BusinessError } 13900025 - No space left on device
1528 * @throws { BusinessError } 13900028 - Too many links
1529 * @throws { BusinessError } 13900030 - File name too long
1530 * @throws { BusinessError } 13900033 - Too many symbolic links encountered
1531 * @throws { BusinessError } 13900041 - Quota exceeded
1532 * @throws { BusinessError } 13900042 - Unknown error
1533 * @syscap SystemCapability.FileManagement.File.FileIO
1534 * @since 20
1535 */
1536function mkdtempSync(prefix: string): string;
1537
1538/**
1539 * Move directory.
1540 *
1541 * @param { string } src - source file path.
1542 * @param { string } dest - destination file path.
1543 * @param { number } [mode = 0] - move mode when duplicate file name exists.
1544 * @returns { Promise<void> } The promise returned by the function.
1545 * @throws { BusinessError } 13900001 - Operation not permitted
1546 * @throws { BusinessError } 13900002 - No such file or directory
1547 * @throws { BusinessError } 13900008 - Bad file descriptor
1548 * @throws { BusinessError } 13900011 - Out of memory
1549 * @throws { BusinessError } 13900012 - Permission denied
1550 * @throws { BusinessError } 13900013 - Bad address
1551 * @throws { BusinessError } 13900014 - Device or resource busy
1552 * @throws { BusinessError } 13900015 - File exists
1553 * @throws { BusinessError } 13900016 - Cross-device link
1554 * @throws { BusinessError } 13900018 - Not a directory
1555 * @throws { BusinessError } 13900019 - Is a directory
1556 * @throws { BusinessError } 13900020 - Invalid argument
1557 * @throws { BusinessError } 13900025 - No space left on device
1558 * @throws { BusinessError } 13900027 - Read-only file system
1559 * @throws { BusinessError } 13900028 - Too many links
1560 * @throws { BusinessError } 13900032 - Directory not empty
1561 * @throws { BusinessError } 13900033 - Too many symbolic links encountered
1562 * @throws { BusinessError } 13900041 - Quota exceeded
1563 * @throws { BusinessError } 13900042 - Unknown error
1564 * @syscap SystemCapability.FileManagement.File.FileIO
1565 * @since 20
1566 */
1567function moveDir(src: string, dest: string, mode?: number): Promise<void>;
1568
1569/**
1570 * Move directory.
1571 *
1572 * @param { string } src - source file path.
1573 * @param { string } dest - destination file path.
1574 * @param { AsyncCallback<void> } callback - Return the callback function.
1575 * @throws { BusinessError } 13900001 - Operation not permitted
1576 * @throws { BusinessError } 13900002 - No such file or directory
1577 * @throws { BusinessError } 13900008 - Bad file descriptor
1578 * @throws { BusinessError } 13900011 - Out of memory
1579 * @throws { BusinessError } 13900012 - Permission denied
1580 * @throws { BusinessError } 13900013 - Bad address
1581 * @throws { BusinessError } 13900014 - Device or resource busy
1582 * @throws { BusinessError } 13900016 - Cross-device link
1583 * @throws { BusinessError } 13900018 - Not a directory
1584 * @throws { BusinessError } 13900019 - Is a directory
1585 * @throws { BusinessError } 13900020 - Invalid argument
1586 * @throws { BusinessError } 13900025 - No space left on device
1587 * @throws { BusinessError } 13900027 - Read-only file system
1588 * @throws { BusinessError } 13900028 - Too many links
1589 * @throws { BusinessError } 13900032 - Directory not empty
1590 * @throws { BusinessError } 13900033 - Too many symbolic links encountered
1591 * @throws { BusinessError } 13900041 - Quota exceeded
1592 * @throws { BusinessError } 13900042 - Unknown error
1593 * @syscap SystemCapability.FileManagement.File.FileIO
1594 * @since 20
1595 */
1596function moveDir(src: string, dest: string, callback: AsyncCallback<void>): void;
1597
1598/**
1599 * Move directory.
1600 *
1601 * @param { string } src - source file path.
1602 * @param { string } dest - destination file path.
1603 * @param { number } mode - move mode when duplicate file name exists.
1604 * @param { AsyncCallback<void> } callback - Return the callback function.
1605 * @throws { BusinessError } 13900001 - Operation not permitted
1606 * @throws { BusinessError } 13900002 - No such file or directory
1607 * @throws { BusinessError } 13900008 - Bad file descriptor
1608 * @throws { BusinessError } 13900011 - Out of memory
1609 * @throws { BusinessError } 13900012 - Permission denied
1610 * @throws { BusinessError } 13900013 - Bad address
1611 * @throws { BusinessError } 13900014 - Device or resource busy
1612 * @throws { BusinessError } 13900016 - Cross-device link
1613 * @throws { BusinessError } 13900018 - Not a directory
1614 * @throws { BusinessError } 13900019 - Is a directory
1615 * @throws { BusinessError } 13900020 - Invalid argument
1616 * @throws { BusinessError } 13900025 - No space left on device
1617 * @throws { BusinessError } 13900027 - Read-only file system
1618 * @throws { BusinessError } 13900028 - Too many links
1619 * @throws { BusinessError } 13900032 - Directory not empty
1620 * @throws { BusinessError } 13900033 - Too many symbolic links encountered
1621 * @throws { BusinessError } 13900041 - Quota exceeded
1622 * @throws { BusinessError } 13900042 - Unknown error
1623 * @syscap SystemCapability.FileManagement.File.FileIO
1624 * @since 20
1625 */
1626function moveDir(src: string, dest: string, mode: number, callback: AsyncCallback<void>): void;
1627
1628/**
1629 * Move directory with sync interface.
1630 *
1631 * @param { string } src - source file path.
1632 * @param { string } dest - destination file path.
1633 * @param { number } [mode = 0] - move mode when duplicate file name exists.
1634 * @throws { BusinessError } 13900001 - Operation not permitted
1635 * @throws { BusinessError } 13900002 - No such file or directory
1636 * @throws { BusinessError } 13900008 - Bad file descriptor
1637 * @throws { BusinessError } 13900011 - Out of memory
1638 * @throws { BusinessError } 13900012 - Permission denied
1639 * @throws { BusinessError } 13900013 - Bad address
1640 * @throws { BusinessError } 13900014 - Device or resource busy
1641 * @throws { BusinessError } 13900015 - File exists
1642 * @throws { BusinessError } 13900016 - Cross-device link
1643 * @throws { BusinessError } 13900018 - Not a directory
1644 * @throws { BusinessError } 13900019 - Is a directory
1645 * @throws { BusinessError } 13900020 - Invalid argument
1646 * @throws { BusinessError } 13900025 - No space left on device
1647 * @throws { BusinessError } 13900027 - Read-only file system
1648 * @throws { BusinessError } 13900028 - Too many links
1649 * @throws { BusinessError } 13900032 - Directory not empty
1650 * @throws { BusinessError } 13900033 - Too many symbolic links encountered
1651 * @throws { BusinessError } 13900041 - Quota exceeded
1652 * @throws { BusinessError } 13900042 - Unknown error
1653 * @syscap SystemCapability.FileManagement.File.FileIO
1654 * @since 20
1655 */
1656function moveDirSync(src: string, dest: string, mode?: number): void;
1657
1658/**
1659 * Move file.
1660 *
1661 * @param { string } src - source file path.
1662 * @param { string } dest - destination file path.
1663 * @param { number } [mode = 0] - move mode when duplicate file name exists.
1664 * @returns { Promise<void> } The promise returned by the function.
1665 * @throws { BusinessError } 13900001 - Operation not permitted
1666 * @throws { BusinessError } 13900002 - No such file or directory
1667 * @throws { BusinessError } 13900008 - Bad file descriptor
1668 * @throws { BusinessError } 13900011 - Out of memory
1669 * @throws { BusinessError } 13900012 - Permission denied
1670 * @throws { BusinessError } 13900013 - Bad address
1671 * @throws { BusinessError } 13900014 - Device or resource busy
1672 * @throws { BusinessError } 13900015 - File exists
1673 * @throws { BusinessError } 13900016 - Cross-device link
1674 * @throws { BusinessError } 13900018 - Not a directory
1675 * @throws { BusinessError } 13900019 - Is a directory
1676 * @throws { BusinessError } 13900020 - Invalid argument
1677 * @throws { BusinessError } 13900025 - No space left on device
1678 * @throws { BusinessError } 13900027 - Read-only file system
1679 * @throws { BusinessError } 13900028 - Too many links
1680 * @throws { BusinessError } 13900032 - Directory not empty
1681 * @throws { BusinessError } 13900033 - Too many symbolic links encountered
1682 * @throws { BusinessError } 13900041 - Quota exceeded
1683 * @throws { BusinessError } 13900042 - Unknown error
1684 * @syscap SystemCapability.FileManagement.File.FileIO
1685 * @since 20
1686 */
1687function moveFile(src: string, dest: string, mode?: number): Promise<void>;
1688
1689/**
1690 * Move file.
1691 *
1692 * @param { string } src - source file path.
1693 * @param { string } dest - destination file path.
1694 * @param { AsyncCallback<void> } callback - Return the callback function.
1695 * @throws { BusinessError } 13900001 - Operation not permitted
1696 * @throws { BusinessError } 13900002 - No such file or directory
1697 * @throws { BusinessError } 13900008 - Bad file descriptor
1698 * @throws { BusinessError } 13900011 - Out of memory
1699 * @throws { BusinessError } 13900012 - Permission denied
1700 * @throws { BusinessError } 13900013 - Bad address
1701 * @throws { BusinessError } 13900014 - Device or resource busy
1702 * @throws { BusinessError } 13900015 - File exists
1703 * @throws { BusinessError } 13900016 - Cross-device link
1704 * @throws { BusinessError } 13900018 - Not a directory
1705 * @throws { BusinessError } 13900019 - Is a directory
1706 * @throws { BusinessError } 13900020 - Invalid argument
1707 * @throws { BusinessError } 13900025 - No space left on device
1708 * @throws { BusinessError } 13900027 - Read-only file system
1709 * @throws { BusinessError } 13900028 - Too many links
1710 * @throws { BusinessError } 13900032 - Directory not empty
1711 * @throws { BusinessError } 13900033 - Too many symbolic links encountered
1712 * @throws { BusinessError } 13900041 - Quota exceeded
1713 * @throws { BusinessError } 13900042 - Unknown error
1714 * @syscap SystemCapability.FileManagement.File.FileIO
1715 * @since 20
1716 */
1717function moveFile(src: string, dest: string, callback: AsyncCallback<void>): void;
1718
1719/**
1720 * Move file.
1721 *
1722 * @param { string } src - source file path.
1723 * @param { string } dest - destination file path.
1724 * @param { number } [mode = 0] - move mode when duplicate file name exists.
1725 * @param { AsyncCallback<void> } callback - Return the callback function.
1726 * @throws { BusinessError } 13900001 - Operation not permitted
1727 * @throws { BusinessError } 13900002 - No such file or directory
1728 * @throws { BusinessError } 13900008 - Bad file descriptor
1729 * @throws { BusinessError } 13900011 - Out of memory
1730 * @throws { BusinessError } 13900012 - Permission denied
1731 * @throws { BusinessError } 13900013 - Bad address
1732 * @throws { BusinessError } 13900014 - Device or resource busy
1733 * @throws { BusinessError } 13900015 - File exists
1734 * @throws { BusinessError } 13900016 - Cross-device link
1735 * @throws { BusinessError } 13900018 - Not a directory
1736 * @throws { BusinessError } 13900019 - Is a directory
1737 * @throws { BusinessError } 13900020 - Invalid argument
1738 * @throws { BusinessError } 13900025 - No space left on device
1739 * @throws { BusinessError } 13900027 - Read-only file system
1740 * @throws { BusinessError } 13900028 - Too many links
1741 * @throws { BusinessError } 13900032 - Directory not empty
1742 * @throws { BusinessError } 13900033 - Too many symbolic links encountered
1743 * @throws { BusinessError } 13900041 - Quota exceeded
1744 * @throws { BusinessError } 13900042 - Unknown error
1745 * @syscap SystemCapability.FileManagement.File.FileIO
1746 * @since 20
1747 */
1748function moveFile(src: string, dest: string, mode: number, callback: AsyncCallback<void>): void;
1749
1750/**
1751 * Move file with sync interface.
1752 *
1753 * @param { string } src - source file path.
1754 * @param { string } dest - destination file path.
1755 * @param { number } [mode = 0] - move mode when duplicate file name exists.
1756 * @throws { BusinessError } 13900001 - Operation not permitted
1757 * @throws { BusinessError } 13900002 - No such file or directory
1758 * @throws { BusinessError } 13900008 - Bad file descriptor
1759 * @throws { BusinessError } 13900011 - Out of memory
1760 * @throws { BusinessError } 13900012 - Permission denied
1761 * @throws { BusinessError } 13900013 - Bad address
1762 * @throws { BusinessError } 13900014 - Device or resource busy
1763 * @throws { BusinessError } 13900015 - File exists
1764 * @throws { BusinessError } 13900016 - Cross-device link
1765 * @throws { BusinessError } 13900018 - Not a directory
1766 * @throws { BusinessError } 13900019 - Is a directory
1767 * @throws { BusinessError } 13900020 - Invalid argument
1768 * @throws { BusinessError } 13900025 - No space left on device
1769 * @throws { BusinessError } 13900027 - Read-only file system
1770 * @throws { BusinessError } 13900028 - Too many links
1771 * @throws { BusinessError } 13900032 - Directory not empty
1772 * @throws { BusinessError } 13900033 - Too many symbolic links encountered
1773 * @throws { BusinessError } 13900041 - Quota exceeded
1774 * @throws { BusinessError } 13900042 - Unknown error
1775 * @syscap SystemCapability.FileManagement.File.FileIO
1776 * @since 20
1777 */
1778function moveFileSync(src: string, dest: string, mode?: number): void;
1779
1780/**
1781 * Open file.
1782 *
1783 * @param { string } path - path.
1784 * @param { number } [mode = OpenMode.READ_ONLY] - mode.
1785 * @returns { Promise<File> } Returns the File object in Promise mode to record the file descriptor.
1786 * @throws { BusinessError } 13900001 - Operation not permitted
1787 * @throws { BusinessError } 13900002 - No such file or directory
1788 * @throws { BusinessError } 13900004 - Interrupted system call
1789 * @throws { BusinessError } 13900006 - No such device or address
1790 * @throws { BusinessError } 13900008 - Bad file descriptor
1791 * @throws { BusinessError } 13900011 - Out of memory
1792 * @throws { BusinessError } 13900012 - Permission denied
1793 * @throws { BusinessError } 13900013 - Bad address
1794 * @throws { BusinessError } 13900014 - Device or resource busy
1795 * @throws { BusinessError } 13900015 - File exists
1796 * @throws { BusinessError } 13900017 - No such device
1797 * @throws { BusinessError } 13900018 - Not a directory
1798 * @throws { BusinessError } 13900019 - Is a directory
1799 * @throws { BusinessError } 13900020 - Invalid argument
1800 * @throws { BusinessError } 13900022 - Too many open files
1801 * @throws { BusinessError } 13900023 - Text file busy
1802 * @throws { BusinessError } 13900024 - File too large
1803 * @throws { BusinessError } 13900025 - No space left on device
1804 * @throws { BusinessError } 13900027 - Read-only file system
1805 * @throws { BusinessError } 13900029 - Resource deadlock would occur
1806 * @throws { BusinessError } 13900030 - File name too long
1807 * @throws { BusinessError } 13900033 - Too many symbolic links encountered
1808 * @throws { BusinessError } 13900034 - Operation would block
1809 * @throws { BusinessError } 13900038 - Value too large for defined data type
1810 * @throws { BusinessError } 13900041 - Quota exceeded
1811 * @throws { BusinessError } 13900042 - Unknown error
1812 * @throws { BusinessError } 13900044 - Network is unreachable
1813 * @syscap SystemCapability.FileManagement.File.FileIO
1814 * @since 20
1815 */
1816function open(path: string, mode?: number): Promise<File>;
1817
1818/**
1819 * Open file.
1820 *
1821 * @param { string } path - path.
1822 * @param { AsyncCallback<File> } callback - The callback is used to return the File object to record the file descriptor.
1823 * @throws { BusinessError } 13900001 - Operation not permitted
1824 * @throws { BusinessError } 13900002 - No such file or directory
1825 * @throws { BusinessError } 13900004 - Interrupted system call
1826 * @throws { BusinessError } 13900006 - No such device or address
1827 * @throws { BusinessError } 13900008 - Bad file descriptor
1828 * @throws { BusinessError } 13900011 - Out of memory
1829 * @throws { BusinessError } 13900012 - Permission denied
1830 * @throws { BusinessError } 13900013 - Bad address
1831 * @throws { BusinessError } 13900014 - Device or resource busy
1832 * @throws { BusinessError } 13900015 - File exists
1833 * @throws { BusinessError } 13900017 - No such device
1834 * @throws { BusinessError } 13900018 - Not a directory
1835 * @throws { BusinessError } 13900019 - Is a directory
1836 * @throws { BusinessError } 13900020 - Invalid argument
1837 * @throws { BusinessError } 13900022 - Too many open files
1838 * @throws { BusinessError } 13900023 - Text file busy
1839 * @throws { BusinessError } 13900024 - File too large
1840 * @throws { BusinessError } 13900025 - No space left on device
1841 * @throws { BusinessError } 13900027 - Read-only file system
1842 * @throws { BusinessError } 13900029 - Resource deadlock would occur
1843 * @throws { BusinessError } 13900030 - File name too long
1844 * @throws { BusinessError } 13900033 - Too many symbolic links encountered
1845 * @throws { BusinessError } 13900034 - Operation would block
1846 * @throws { BusinessError } 13900038 - Value too large for defined data type
1847 * @throws { BusinessError } 13900041 - Quota exceeded
1848 * @throws { BusinessError } 13900042 - Unknown error
1849 * @syscap SystemCapability.FileManagement.File.FileIO
1850 * @since 20
1851 */
1852function open(path: string, callback: AsyncCallback<File>): void;
1853
1854/**
1855 * Open file.
1856 *
1857 * @param { string } path - path.
1858 * @param { number } [mode = OpenMode.READ_ONLY] - mode.
1859 * @param { AsyncCallback<File> } callback - The callback is used to return the File object to record the file descriptor.
1860 * @throws { BusinessError } 13900001 - Operation not permitted
1861 * @throws { BusinessError } 13900002 - No such file or directory
1862 * @throws { BusinessError } 13900004 - Interrupted system call
1863 * @throws { BusinessError } 13900006 - No such device or address
1864 * @throws { BusinessError } 13900008 - Bad file descriptor
1865 * @throws { BusinessError } 13900011 - Out of memory
1866 * @throws { BusinessError } 13900012 - Permission denied
1867 * @throws { BusinessError } 13900013 - Bad address
1868 * @throws { BusinessError } 13900014 - Device or resource busy
1869 * @throws { BusinessError } 13900015 - File exists
1870 * @throws { BusinessError } 13900017 - No such device
1871 * @throws { BusinessError } 13900018 - Not a directory
1872 * @throws { BusinessError } 13900019 - Is a directory
1873 * @throws { BusinessError } 13900020 - Invalid argument
1874 * @throws { BusinessError } 13900022 - Too many open files
1875 * @throws { BusinessError } 13900023 - Text file busy
1876 * @throws { BusinessError } 13900024 - File too large
1877 * @throws { BusinessError } 13900025 - No space left on device
1878 * @throws { BusinessError } 13900027 - Read-only file system
1879 * @throws { BusinessError } 13900029 - Resource deadlock would occur
1880 * @throws { BusinessError } 13900030 - File name too long
1881 * @throws { BusinessError } 13900033 - Too many symbolic links encountered
1882 * @throws { BusinessError } 13900034 - Operation would block
1883 * @throws { BusinessError } 13900038 - Value too large for defined data type
1884 * @throws { BusinessError } 13900041 - Quota exceeded
1885 * @throws { BusinessError } 13900042 - Unknown error
1886 * @syscap SystemCapability.FileManagement.File.FileIO
1887 * @since 20
1888 */
1889function open(path: string, mode: number, callback: AsyncCallback<File>): void;
1890
1891/**
1892 * Open file with sync interface.
1893 *
1894 * @param { string } path - path.
1895 * @param { number } [mode = OpenMode.READ_ONLY] - mode.
1896 * @returns { File } Returns the File object to record the file descriptor.
1897 * @throws { BusinessError } 13900001 - Operation not permitted
1898 * @throws { BusinessError } 13900002 - No such file or directory
1899 * @throws { BusinessError } 13900004 - Interrupted system call
1900 * @throws { BusinessError } 13900006 - No such device or address
1901 * @throws { BusinessError } 13900008 - Bad file descriptor
1902 * @throws { BusinessError } 13900011 - Out of memory
1903 * @throws { BusinessError } 13900012 - Permission denied
1904 * @throws { BusinessError } 13900013 - Bad address
1905 * @throws { BusinessError } 13900014 - Device or resource busy
1906 * @throws { BusinessError } 13900015 - File exists
1907 * @throws { BusinessError } 13900017 - No such device
1908 * @throws { BusinessError } 13900018 - Not a directory
1909 * @throws { BusinessError } 13900019 - Is a directory
1910 * @throws { BusinessError } 13900020 - Invalid argument
1911 * @throws { BusinessError } 13900022 - Too many open files
1912 * @throws { BusinessError } 13900023 - Text file busy
1913 * @throws { BusinessError } 13900024 - File too large
1914 * @throws { BusinessError } 13900025 - No space left on device
1915 * @throws { BusinessError } 13900027 - Read-only file system
1916 * @throws { BusinessError } 13900029 - Resource deadlock would occur
1917 * @throws { BusinessError } 13900030 - File name too long
1918 * @throws { BusinessError } 13900033 - Too many symbolic links encountered
1919 * @throws { BusinessError } 13900034 - Operation would block
1920 * @throws { BusinessError } 13900038 - Value too large for defined data type
1921 * @throws { BusinessError } 13900041 - Quota exceeded
1922 * @throws { BusinessError } 13900042 - Unknown error
1923 * @throws { BusinessError } 13900044 - Network is unreachable
1924 * @syscap SystemCapability.FileManagement.File.FileIO
1925 * @since 20
1926 */
1927function openSync(path: string, mode?: number): File;
1928
1929/**
1930 * Read file.
1931 *
1932 * @param { number } fd - file descriptor.
1933 * @param { ArrayBuffer } buffer - buffer.
1934 * @param { ReadOptions } [options] - options.
1935 * @returns { Promise<number> } Returns the number of file bytes read to buffer in promise mode.
1936 * @throws { BusinessError } 13900004 - Interrupted system call
1937 * @throws { BusinessError } 13900005 - I/O error
1938 * @throws { BusinessError } 13900008 - Bad file descriptor
1939 * @throws { BusinessError } 13900010 - Try again
1940 * @throws { BusinessError } 13900013 - Bad address
1941 * @throws { BusinessError } 13900019 - Is a directory
1942 * @throws { BusinessError } 13900020 - Invalid argument
1943 * @throws { BusinessError } 13900034 - Operation would block
1944 * @throws { BusinessError } 13900042 - Unknown error
1945 * @throws { BusinessError } 13900044 - Network is unreachable
1946 * @syscap SystemCapability.FileManagement.File.FileIO
1947 * @since 20
1948 */
1949function read(
1950  fd: number,
1951  buffer: ArrayBuffer,
1952  options?: ReadOptions
1953): Promise<number>;
1954
1955/**
1956 * Read file.
1957 *
1958 * @param { number } fd - file descriptor.
1959 * @param { ArrayBuffer } buffer - buffer.
1960 * @param { AsyncCallback<number> } callback - The callback is used to return the number of file bytes read to buffer.
1961 * @throws { BusinessError } 13900004 - Interrupted system call
1962 * @throws { BusinessError } 13900005 - I/O error
1963 * @throws { BusinessError } 13900008 - Bad file descriptor
1964 * @throws { BusinessError } 13900010 - Try again
1965 * @throws { BusinessError } 13900013 - Bad address
1966 * @throws { BusinessError } 13900019 - Is a directory
1967 * @throws { BusinessError } 13900020 - Invalid argument
1968 * @throws { BusinessError } 13900034 - Operation would block
1969 * @throws { BusinessError } 13900042 - Unknown error
1970 * @syscap SystemCapability.FileManagement.File.FileIO
1971 * @since 20
1972 */
1973function read(fd: number, buffer: ArrayBuffer, callback: AsyncCallback<number>): void;
1974
1975/**
1976 * Read file.
1977 *
1978 * @param { number } fd - file descriptor.
1979 * @param { ArrayBuffer } buffer - buffer.
1980 * @param { ReadOptions } [options] - options.
1981 * @param { AsyncCallback<number> } callback - The callback is used to return the number of file bytes read to buffer.
1982 * @throws { BusinessError } 13900004 - Interrupted system call
1983 * @throws { BusinessError } 13900005 - I/O error
1984 * @throws { BusinessError } 13900008 - Bad file descriptor
1985 * @throws { BusinessError } 13900010 - Try again
1986 * @throws { BusinessError } 13900013 - Bad address
1987 * @throws { BusinessError } 13900019 - Is a directory
1988 * @throws { BusinessError } 13900020 - Invalid argument
1989 * @throws { BusinessError } 13900034 - Operation would block
1990 * @throws { BusinessError } 13900042 - Unknown error
1991 * @syscap SystemCapability.FileManagement.File.FileIO
1992 * @since 20
1993 */
1994function read(
1995  fd: number,
1996  buffer: ArrayBuffer,
1997  options: ReadOptions,
1998  callback: AsyncCallback<number>
1999): void;
2000
2001/**
2002 * Read file with sync interface.
2003 *
2004 * @param { number } fd - file descriptor.
2005 * @param { ArrayBuffer } buffer - buffer.
2006 * @param { ReadOptions } [options] - options.
2007 * @returns { number } Returns the number of file bytes read to buffer.
2008 * @throws { BusinessError } 13900004 - Interrupted system call
2009 * @throws { BusinessError } 13900005 - I/O error
2010 * @throws { BusinessError } 13900008 - Bad file descriptor
2011 * @throws { BusinessError } 13900010 - Try again
2012 * @throws { BusinessError } 13900013 - Bad address
2013 * @throws { BusinessError } 13900019 - Is a directory
2014 * @throws { BusinessError } 13900020 - Invalid argument
2015 * @throws { BusinessError } 13900034 - Operation would block
2016 * @throws { BusinessError } 13900042 - Unknown error
2017 * @throws { BusinessError } 13900044 - Network is unreachable
2018 * @syscap SystemCapability.FileManagement.File.FileIO
2019 * @since 20
2020 */
2021function readSync(
2022  fd: number,
2023  buffer: ArrayBuffer,
2024  options?: ReadOptions
2025): number;
2026
2027/**
2028 * Read content line by line.
2029 *
2030 * @param { string } filePath - file path.
2031 * @param { Options } [options] - optional parameters
2032 * @returns { Promise<ReaderIterator> } Returns the iterator object in promise mode.
2033 * @throws { BusinessError } 13900002 - No such file or directory
2034 * @throws { BusinessError } 13900012 - Permission denied
2035 * @throws { BusinessError } 13900015 - File exists
2036 * @throws { BusinessError } 13900019 - Is a directory
2037 * @throws { BusinessError } 13900020 - Invalid argument
2038 * @throws { BusinessError } 13900022 - Too many open files
2039 * @throws { BusinessError } 13900025 - No space left on device
2040 * @throws { BusinessError } 13900027 - Read-only file system
2041 * @throws { BusinessError } 13900030 - File name too long
2042 * @throws { BusinessError } 13900033 - Too many symbolic links encountered
2043 * @throws { BusinessError } 13900041 - Quota exceeded
2044 * @throws { BusinessError } 13900042 - Unknown error
2045 * @throws { BusinessError } 13900044 - Network is unreachable
2046 * @syscap SystemCapability.FileManagement.File.FileIO
2047 * @since 20
2048 */
2049function readLines(filePath: string, options?: Options): Promise<ReaderIterator>;
2050
2051/**
2052 * Read content line by line.
2053 *
2054 * @param { string } filePath - file path.
2055 * @param { AsyncCallback<ReaderIterator> } callback - The callback is used to return the iterator object.
2056 * @throws { BusinessError } 13900002 - No such file or directory
2057 * @throws { BusinessError } 13900012 - Permission denied
2058 * @throws { BusinessError } 13900015 - File exists
2059 * @throws { BusinessError } 13900019 - Is a directory
2060 * @throws { BusinessError } 13900020 - Invalid argument
2061 * @throws { BusinessError } 13900022 - Too many open files
2062 * @throws { BusinessError } 13900025 - No space left on device
2063 * @throws { BusinessError } 13900027 - Read-only file system
2064 * @throws { BusinessError } 13900030 - File name too long
2065 * @throws { BusinessError } 13900033 - Too many symbolic links encountered
2066 * @throws { BusinessError } 13900041 - Quota exceeded
2067 * @throws { BusinessError } 13900042 - Unknown error
2068 * @syscap SystemCapability.FileManagement.File.FileIO
2069 * @since 20
2070 */
2071function readLines(filePath: string, callback: AsyncCallback<ReaderIterator>): void;
2072
2073/**
2074 * Read content line by line.
2075 *
2076 * @param { string } filePath - file path.
2077 * @param { Options } options - optional parameters
2078 * @param { AsyncCallback<ReaderIterator> } callback - The callback is used to return the iterator object.
2079 * @throws { BusinessError } 13900002 - No such file or directory
2080 * @throws { BusinessError } 13900012 - Permission denied
2081 * @throws { BusinessError } 13900015 - File exists
2082 * @throws { BusinessError } 13900019 - Is a directory
2083 * @throws { BusinessError } 13900020 - Invalid argument
2084 * @throws { BusinessError } 13900022 - Too many open files
2085 * @throws { BusinessError } 13900025 - No space left on device
2086 * @throws { BusinessError } 13900027 - Read-only file system
2087 * @throws { BusinessError } 13900030 - File name too long
2088 * @throws { BusinessError } 13900033 - Too many symbolic links encountered
2089 * @throws { BusinessError } 13900041 - Quota exceeded
2090 * @throws { BusinessError } 13900042 - Unknown error
2091 * @syscap SystemCapability.FileManagement.File.FileIO
2092 * @since 20
2093 */
2094function readLines(filePath: string, options: Options, callback: AsyncCallback<ReaderIterator>): void;
2095
2096/**
2097 * Read content line by line with sync interface.
2098 *
2099 * @param { string } filePath - file path.
2100 * @param { Options } [options] - optional parameters
2101 * @returns { ReaderIterator } Returns the iterator object.
2102 * @throws { BusinessError } 13900002 - No such file or directory
2103 * @throws { BusinessError } 13900012 - Permission denied
2104 * @throws { BusinessError } 13900015 - File exists
2105 * @throws { BusinessError } 13900019 - Is a directory
2106 * @throws { BusinessError } 13900020 - Invalid argument
2107 * @throws { BusinessError } 13900022 - Too many open files
2108 * @throws { BusinessError } 13900025 - No space left on device
2109 * @throws { BusinessError } 13900027 - Read-only file system
2110 * @throws { BusinessError } 13900030 - File name too long
2111 * @throws { BusinessError } 13900033 - Too many symbolic links encountered
2112 * @throws { BusinessError } 13900041 - Quota exceeded
2113 * @throws { BusinessError } 13900042 - Unknown error
2114 * @throws { BusinessError } 13900044 - Network is unreachable
2115 * @syscap SystemCapability.FileManagement.File.FileIO
2116 * @since 20
2117 */
2118function readLinesSync(filePath: string, options?: Options): ReaderIterator;
2119
2120/**
2121 * Read text.
2122 *
2123 * @param { string } filePath - file path.
2124 * @param { ReadTextOptions } [options] - options.
2125 * @returns { Promise<string> } Returns the contents of the read file in promise mode.
2126 * @throws { BusinessError } 13900001 - Operation not permitted
2127 * @throws { BusinessError } 13900004 - Interrupted system call
2128 * @throws { BusinessError } 13900005 - I/O error
2129 * @throws { BusinessError } 13900008 - Bad file descriptor
2130 * @throws { BusinessError } 13900010 - Try again
2131 * @throws { BusinessError } 13900013 - Bad address
2132 * @throws { BusinessError } 13900019 - Is a directory
2133 * @throws { BusinessError } 13900020 - Invalid argument
2134 * @throws { BusinessError } 13900024 - File too large
2135 * @throws { BusinessError } 13900025 - No space left on device
2136 * @throws { BusinessError } 13900034 - Operation would block
2137 * @throws { BusinessError } 13900041 - Quota exceeded
2138 * @throws { BusinessError } 13900042 - Unknown error
2139 * @throws { BusinessError } 13900044 - Network is unreachable
2140 * @syscap SystemCapability.FileManagement.File.FileIO
2141 * @since 20
2142 */
2143function readText(
2144  filePath: string,
2145  options?: ReadTextOptions
2146): Promise<string>;
2147
2148/**
2149 * Read text.
2150 *
2151 * @param { string } filePath - file path.
2152 * @param { AsyncCallback<string> } callback - The callback is used to return the contents of the read file.
2153 * @throws { BusinessError } 13900001 - Operation not permitted
2154 * @throws { BusinessError } 13900004 - Interrupted system call
2155 * @throws { BusinessError } 13900005 - I/O error
2156 * @throws { BusinessError } 13900008 - Bad file descriptor
2157 * @throws { BusinessError } 13900010 - Try again
2158 * @throws { BusinessError } 13900013 - Bad address
2159 * @throws { BusinessError } 13900019 - Is a directory
2160 * @throws { BusinessError } 13900020 - Invalid argument
2161 * @throws { BusinessError } 13900024 - File too large
2162 * @throws { BusinessError } 13900025 - No space left on device
2163 * @throws { BusinessError } 13900034 - Operation would block
2164 * @throws { BusinessError } 13900041 - Quota exceeded
2165 * @throws { BusinessError } 13900042 - Unknown error
2166 * @syscap SystemCapability.FileManagement.File.FileIO
2167 * @since 20
2168 */
2169function readText(filePath: string, callback: AsyncCallback<string>): void;
2170
2171/**
2172 * Read text.
2173 *
2174 * @param { string } filePath - file path.
2175 * @param { ReadTextOptions } [options] - options.
2176 * @param { AsyncCallback<string> } callback - The callback is used to return the contents of the read file.
2177 * @throws { BusinessError } 13900001 - Operation not permitted
2178 * @throws { BusinessError } 13900004 - Interrupted system call
2179 * @throws { BusinessError } 13900005 - I/O error
2180 * @throws { BusinessError } 13900008 - Bad file descriptor
2181 * @throws { BusinessError } 13900010 - Try again
2182 * @throws { BusinessError } 13900013 - Bad address
2183 * @throws { BusinessError } 13900019 - Is a directory
2184 * @throws { BusinessError } 13900020 - Invalid argument
2185 * @throws { BusinessError } 13900024 - File too large
2186 * @throws { BusinessError } 13900025 - No space left on device
2187 * @throws { BusinessError } 13900034 - Operation would block
2188 * @throws { BusinessError } 13900041 - Quota exceeded
2189 * @throws { BusinessError } 13900042 - Unknown error
2190 * @syscap SystemCapability.FileManagement.File.FileIO
2191 * @since 20
2192 */
2193function readText(
2194  filePath: string,
2195  options: ReadTextOptions,
2196  callback: AsyncCallback<string>
2197): void;
2198
2199/**
2200 * Read text with sync interface.
2201 *
2202 * @param { string } filePath - file path.
2203 * @param { ReadTextOptions } [options] - options.
2204 * @returns { string } Returns the contents of the read file.
2205 * @throws { BusinessError } 13900001 - Operation not permitted
2206 * @throws { BusinessError } 13900004 - Interrupted system call
2207 * @throws { BusinessError } 13900005 - I/O error
2208 * @throws { BusinessError } 13900008 - Bad file descriptor
2209 * @throws { BusinessError } 13900010 - Try again
2210 * @throws { BusinessError } 13900013 - Bad address
2211 * @throws { BusinessError } 13900019 - Is a directory
2212 * @throws { BusinessError } 13900020 - Invalid argument
2213 * @throws { BusinessError } 13900024 - File too large
2214 * @throws { BusinessError } 13900025 - No space left on device
2215 * @throws { BusinessError } 13900034 - Operation would block
2216 * @throws { BusinessError } 13900041 - Quota exceeded
2217 * @throws { BusinessError } 13900042 - Unknown error
2218 * @throws { BusinessError } 13900044 - Network is unreachable
2219 * @syscap SystemCapability.FileManagement.File.FileIO
2220 * @since 20
2221 */
2222function readTextSync(
2223  filePath: string,
2224  options?: ReadTextOptions
2225): string;
2226
2227/**
2228 * Rename file.
2229 *
2230 * @param { string } oldPath - oldPath.
2231 * @param { string } newPath - newPath.
2232 * @returns { Promise<void> } The promise returned by the function.
2233 * @throws { BusinessError } 13900001 - Operation not permitted
2234 * @throws { BusinessError } 13900002 - No such file or directory
2235 * @throws { BusinessError } 13900008 - Bad file descriptor
2236 * @throws { BusinessError } 13900011 - Out of memory
2237 * @throws { BusinessError } 13900012 - Permission denied
2238 * @throws { BusinessError } 13900013 - Bad address
2239 * @throws { BusinessError } 13900014 - Device or resource busy
2240 * @throws { BusinessError } 13900015 - File exists
2241 * @throws { BusinessError } 13900016 - Cross-device link
2242 * @throws { BusinessError } 13900018 - Not a directory
2243 * @throws { BusinessError } 13900019 - Is a directory
2244 * @throws { BusinessError } 13900020 - Invalid argument
2245 * @throws { BusinessError } 13900025 - No space left on device
2246 * @throws { BusinessError } 13900027 - Read-only file system
2247 * @throws { BusinessError } 13900028 - Too many links
2248 * @throws { BusinessError } 13900032 - Directory not empty
2249 * @throws { BusinessError } 13900033 - Too many symbolic links encountered
2250 * @throws { BusinessError } 13900041 - Quota exceeded
2251 * @throws { BusinessError } 13900042 - Unknown error
2252 * @syscap SystemCapability.FileManagement.File.FileIO
2253 * @since 20
2254 */
2255function rename(oldPath: string, newPath: string): Promise<void>;
2256
2257/**
2258 * Rename file.
2259 *
2260 * @param { string } oldPath - oldPath.
2261 * @param { string } newPath - newPath.
2262 * @param { AsyncCallback<void> } callback - Returns the callback function.
2263 * @throws { BusinessError } 13900001 - Operation not permitted
2264 * @throws { BusinessError } 13900002 - No such file or directory
2265 * @throws { BusinessError } 13900008 - Bad file descriptor
2266 * @throws { BusinessError } 13900011 - Out of memory
2267 * @throws { BusinessError } 13900012 - Permission denied
2268 * @throws { BusinessError } 13900013 - Bad address
2269 * @throws { BusinessError } 13900014 - Device or resource busy
2270 * @throws { BusinessError } 13900015 - File exists
2271 * @throws { BusinessError } 13900016 - Cross-device link
2272 * @throws { BusinessError } 13900018 - Not a directory
2273 * @throws { BusinessError } 13900019 - Is a directory
2274 * @throws { BusinessError } 13900020 - Invalid argument
2275 * @throws { BusinessError } 13900025 - No space left on device
2276 * @throws { BusinessError } 13900027 - Read-only file system
2277 * @throws { BusinessError } 13900028 - Too many links
2278 * @throws { BusinessError } 13900032 - Directory not empty
2279 * @throws { BusinessError } 13900033 - Too many symbolic links encountered
2280 * @throws { BusinessError } 13900041 - Quota exceeded
2281 * @throws { BusinessError } 13900042 - Unknown error
2282 * @syscap SystemCapability.FileManagement.File.FileIO
2283 * @since 20
2284 */
2285function rename(oldPath: string, newPath: string, callback: AsyncCallback<void>): void;
2286
2287/**
2288 * Rename file with sync interface.
2289 *
2290 * @param { string } oldPath - oldPath.
2291 * @param { string } newPath - newPath.
2292 * @throws { BusinessError } 13900001 - Operation not permitted
2293 * @throws { BusinessError } 13900002 - No such file or directory
2294 * @throws { BusinessError } 13900008 - Bad file descriptor
2295 * @throws { BusinessError } 13900011 - Out of memory
2296 * @throws { BusinessError } 13900012 - Permission denied
2297 * @throws { BusinessError } 13900013 - Bad address
2298 * @throws { BusinessError } 13900014 - Device or resource busy
2299 * @throws { BusinessError } 13900015 - File exists
2300 * @throws { BusinessError } 13900016 - Cross-device link
2301 * @throws { BusinessError } 13900018 - Not a directory
2302 * @throws { BusinessError } 13900019 - Is a directory
2303 * @throws { BusinessError } 13900020 - Invalid argument
2304 * @throws { BusinessError } 13900025 - No space left on device
2305 * @throws { BusinessError } 13900027 - Read-only file system
2306 * @throws { BusinessError } 13900028 - Too many links
2307 * @throws { BusinessError } 13900032 - Directory not empty
2308 * @throws { BusinessError } 13900033 - Too many symbolic links encountered
2309 * @throws { BusinessError } 13900041 - Quota exceeded
2310 * @throws { BusinessError } 13900042 - Unknown error
2311 * @syscap SystemCapability.FileManagement.File.FileIO
2312 * @since 20
2313 */
2314function renameSync(oldPath: string, newPath: string): void;
2315
2316/**
2317 * Delete dir.
2318 *
2319 * @param { string } path - path.
2320 * @returns { Promise<void> } The promise returned by the function.
2321 * @throws { BusinessError } 13900001 - Operation not permitted
2322 * @throws { BusinessError } 13900002 - No such file or directory
2323 * @throws { BusinessError } 13900011 - Out of memory
2324 * @throws { BusinessError } 13900012 - Permission denied
2325 * @throws { BusinessError } 13900013 - Bad address
2326 * @throws { BusinessError } 13900014 - Device or resource busy
2327 * @throws { BusinessError } 13900018 - Not a directory
2328 * @throws { BusinessError } 13900020 - Invalid argument
2329 * @throws { BusinessError } 13900027 - Read-only file system1
2330 * @throws { BusinessError } 13900030 - File name too long
2331 * @throws { BusinessError } 13900032 - Directory not empty
2332 * @throws { BusinessError } 13900042 - Unknown error
2333 * @syscap SystemCapability.FileManagement.File.FileIO
2334 * @since 20
2335 */
2336function rmdir(path: string): Promise<void>;
2337
2338/**
2339 * Delete dir.
2340 *
2341 * @param { string } path - path.
2342 * @param { AsyncCallback<void> } callback - Return the callback function.
2343 * @throws { BusinessError } 13900001 - Operation not permitted
2344 * @throws { BusinessError } 13900002 - No such file or directory
2345 * @throws { BusinessError } 13900011 - Out of memory
2346 * @throws { BusinessError } 13900012 - Permission denied
2347 * @throws { BusinessError } 13900013 - Bad address
2348 * @throws { BusinessError } 13900014 - Device or resource busy
2349 * @throws { BusinessError } 13900018 - Not a directory
2350 * @throws { BusinessError } 13900020 - Invalid argument
2351 * @throws { BusinessError } 13900027 - Read-only file system1
2352 * @throws { BusinessError } 13900030 - File name too long
2353 * @throws { BusinessError } 13900032 - Directory not empty
2354 * @throws { BusinessError } 13900042 - Unknown error
2355 * @syscap SystemCapability.FileManagement.File.FileIO
2356 * @since 20
2357 */
2358function rmdir(path: string, callback: AsyncCallback<void>): void;
2359
2360/**
2361 * Delete dir with sync interface.
2362 *
2363 * @param { string } path - path.
2364 * @throws { BusinessError } 13900001 - Operation not permitted
2365 * @throws { BusinessError } 13900002 - No such file or directory
2366 * @throws { BusinessError } 13900011 - Out of memory
2367 * @throws { BusinessError } 13900012 - Permission denied
2368 * @throws { BusinessError } 13900013 - Bad address
2369 * @throws { BusinessError } 13900014 - Device or resource busy
2370 * @throws { BusinessError } 13900018 - Not a directory
2371 * @throws { BusinessError } 13900020 - Invalid argument
2372 * @throws { BusinessError } 13900027 - Read-only file system1
2373 * @throws { BusinessError } 13900030 - File name too long
2374 * @throws { BusinessError } 13900032 - Directory not empty
2375 * @throws { BusinessError } 13900042 - Unknown error
2376 * @syscap SystemCapability.FileManagement.File.FileIO
2377 * @since 20
2378 */
2379function rmdirSync(path: string): void;
2380
2381/**
2382 * Get file information.
2383 *
2384 * @param { string | number } file - path or file descriptor.
2385 * @returns { Promise<Stat> } Returns the Stat object in promise mode.
2386 * @throws { BusinessError } 13900002 - No such file or directory
2387 * @throws { BusinessError } 13900004 - Interrupted system call
2388 * @throws { BusinessError } 13900005 - I/O error
2389 * @throws { BusinessError } 13900008 - Bad file descriptor
2390 * @throws { BusinessError } 13900011 - Out of memory
2391 * @throws { BusinessError } 13900012 - Permission denied
2392 * @throws { BusinessError } 13900013 - Bad address
2393 * @throws { BusinessError } 13900018 - Not a directory
2394 * @throws { BusinessError } 13900030 - File name too long
2395 * @throws { BusinessError } 13900031 - Function not implemented
2396 * @throws { BusinessError } 13900033 - Too many symbolic links encountered
2397 * @throws { BusinessError } 13900038 - Value too large for defined data type
2398 * @throws { BusinessError } 13900042 - Unknown error
2399 * @syscap SystemCapability.FileManagement.File.FileIO
2400 * @since 20
2401 */
2402function stat(file: string | number): Promise<Stat>;
2403
2404/**
2405 * Get file information.
2406 *
2407 * @param { string | number } file - path or file descriptor.
2408 * @param { AsyncCallback<Stat> } callback - The callback is used to return the Stat object.
2409 * @throws { BusinessError } 13900002 - No such file or directory
2410 * @throws { BusinessError } 13900004 - Interrupted system call
2411 * @throws { BusinessError } 13900005 - I/O error
2412 * @throws { BusinessError } 13900008 - Bad file descriptor
2413 * @throws { BusinessError } 13900011 - Out of memory
2414 * @throws { BusinessError } 13900012 - Permission denied
2415 * @throws { BusinessError } 13900013 - Bad address
2416 * @throws { BusinessError } 13900018 - Not a directory
2417 * @throws { BusinessError } 13900030 - File name too long
2418 * @throws { BusinessError } 13900031 - Function not implemented
2419 * @throws { BusinessError } 13900033 - Too many symbolic links encountered
2420 * @throws { BusinessError } 13900038 - Value too large for defined data type
2421 * @throws { BusinessError } 13900042 - Unknown error
2422 * @syscap SystemCapability.FileManagement.File.FileIO
2423 * @since 20
2424 */
2425function stat(file: string | number, callback: AsyncCallback<Stat>): void;
2426
2427/**
2428 * Get file information with sync interface.
2429 *
2430 * @param { string | number } file - path or file descriptor.
2431 * @returns { Stat } Returns the Stat object.
2432 * @throws { BusinessError } 13900002 - No such file or directory
2433 * @throws { BusinessError } 13900004 - Interrupted system call
2434 * @throws { BusinessError } 13900005 - I/O error
2435 * @throws { BusinessError } 13900008 - Bad file descriptor
2436 * @throws { BusinessError } 13900011 - Out of memory
2437 * @throws { BusinessError } 13900012 - Permission denied
2438 * @throws { BusinessError } 13900013 - Bad address
2439 * @throws { BusinessError } 13900018 - Not a directory
2440 * @throws { BusinessError } 13900030 - File name too long
2441 * @throws { BusinessError } 13900031 - Function not implemented
2442 * @throws { BusinessError } 13900033 - Too many symbolic links encountered
2443 * @throws { BusinessError } 13900038 - Value too large for defined data type
2444 * @throws { BusinessError } 13900042 - Unknown error
2445 * @syscap SystemCapability.FileManagement.File.FileIO
2446 * @since 20
2447 */
2448function statSync(file: string | number): Stat;
2449
2450/**
2451 * Link file.
2452 *
2453 * @param { string } target - target.
2454 * @param { string } srcPath - srcPath.
2455 * @returns { Promise<void> } The promise returned by the function.
2456 * @throws { BusinessError } 13900001 - Operation not permitted
2457 * @throws { BusinessError } 13900002 - No such file or directory
2458 * @throws { BusinessError } 13900005 - I/O error
2459 * @throws { BusinessError } 13900008 - Bad file descriptor
2460 * @throws { BusinessError } 13900011 - Out of memory
2461 * @throws { BusinessError } 13900012 - Permission denied
2462 * @throws { BusinessError } 13900013 - Bad address
2463 * @throws { BusinessError } 13900015 - File exists
2464 * @throws { BusinessError } 13900018 - Not a directory
2465 * @throws { BusinessError } 13900025 - No space left on device
2466 * @throws { BusinessError } 13900027 - Read-only file system
2467 * @throws { BusinessError } 13900030 - File name too long
2468 * @throws { BusinessError } 13900041 - Quota exceeded
2469 * @throws { BusinessError } 13900042 - Unknown error
2470 * @syscap SystemCapability.FileManagement.File.FileIO
2471 * @since 20
2472 */
2473function symlink(target: string, srcPath: string): Promise<void>;
2474
2475/**
2476 * Link file.
2477 *
2478 * @param { string } target - target.
2479 * @param { string } srcPath - srcPath.
2480 * @param { AsyncCallback<void> } callback - Return the callback function.
2481 * @throws { BusinessError } 13900001 - Operation not permitted
2482 * @throws { BusinessError } 13900002 - No such file or directory
2483 * @throws { BusinessError } 13900005 - I/O error
2484 * @throws { BusinessError } 13900008 - Bad file descriptor
2485 * @throws { BusinessError } 13900011 - Out of memory
2486 * @throws { BusinessError } 13900012 - Permission denied
2487 * @throws { BusinessError } 13900013 - Bad address
2488 * @throws { BusinessError } 13900015 - File exists
2489 * @throws { BusinessError } 13900018 - Not a directory
2490 * @throws { BusinessError } 13900025 - No space left on device
2491 * @throws { BusinessError } 13900027 - Read-only file system
2492 * @throws { BusinessError } 13900030 - File name too long
2493 * @throws { BusinessError } 13900041 - Quota exceeded
2494 * @throws { BusinessError } 13900042 - Unknown error
2495 * @syscap SystemCapability.FileManagement.File.FileIO
2496 * @since 20
2497 */
2498function symlink(target: string, srcPath: string, callback: AsyncCallback<void>): void;
2499
2500/**
2501 * Link file with sync interface.
2502 *
2503 * @param { string } target - target.
2504 * @param { string } srcPath - srcPath.
2505 * @throws { BusinessError } 13900001 - Operation not permitted
2506 * @throws { BusinessError } 13900002 - No such file or directory
2507 * @throws { BusinessError } 13900005 - I/O error
2508 * @throws { BusinessError } 13900008 - Bad file descriptor
2509 * @throws { BusinessError } 13900011 - Out of memory
2510 * @throws { BusinessError } 13900012 - Permission denied
2511 * @throws { BusinessError } 13900013 - Bad address
2512 * @throws { BusinessError } 13900015 - File exists
2513 * @throws { BusinessError } 13900018 - Not a directory
2514 * @throws { BusinessError } 13900025 - No space left on device
2515 * @throws { BusinessError } 13900027 - Read-only file system
2516 * @throws { BusinessError } 13900030 - File name too long
2517 * @throws { BusinessError } 13900041 - Quota exceeded
2518 * @throws { BusinessError } 13900042 - Unknown error
2519 * @syscap SystemCapability.FileManagement.File.FileIO
2520 * @since 20
2521 */
2522function symlinkSync(target: string, srcPath: string): void;
2523
2524/**
2525 * Truncate file.
2526 *
2527 * @param { string | number } file - path or file descriptor.
2528 * @param { number } [len = 0] - len.
2529 * @returns { Promise<void> } The promise returned by the function.
2530 * @throws { BusinessError } 13900001 - Operation not permitted
2531 * @throws { BusinessError } 13900002 - No such file or directory
2532 * @throws { BusinessError } 13900004 - Interrupted system call
2533 * @throws { BusinessError } 13900005 - I/O error
2534 * @throws { BusinessError } 13900008 - Bad file descriptor
2535 * @throws { BusinessError } 13900012 - Permission denied
2536 * @throws { BusinessError } 13900013 - Bad address
2537 * @throws { BusinessError } 13900018 - Not a directory
2538 * @throws { BusinessError } 13900019 - Is a directory
2539 * @throws { BusinessError } 13900020 - Invalid argument
2540 * @throws { BusinessError } 13900023 - Text file busy
2541 * @throws { BusinessError } 13900024 - File too large
2542 * @throws { BusinessError } 13900027 - Read-only file system
2543 * @throws { BusinessError } 13900030 - File name too long
2544 * @throws { BusinessError } 13900033 - Too many symbolic links encountered
2545 * @throws { BusinessError } 13900042 - Unknown error
2546 * @syscap SystemCapability.FileManagement.File.FileIO
2547 * @since 20
2548 */
2549function truncate(file: string | number, len?: number): Promise<void>;
2550
2551/**
2552 * Truncate file.
2553 *
2554 * @param { string | number } file - path or file descriptor.
2555 * @param { AsyncCallback<void> } callback - Return the callback function.
2556 * @throws { BusinessError } 13900001 - Operation not permitted
2557 * @throws { BusinessError } 13900002 - No such file or directory
2558 * @throws { BusinessError } 13900004 - Interrupted system call
2559 * @throws { BusinessError } 13900005 - I/O error
2560 * @throws { BusinessError } 13900008 - Bad file descriptor
2561 * @throws { BusinessError } 13900012 - Permission denied
2562 * @throws { BusinessError } 13900013 - Bad address
2563 * @throws { BusinessError } 13900018 - Not a directory
2564 * @throws { BusinessError } 13900019 - Is a directory
2565 * @throws { BusinessError } 13900020 - Invalid argument
2566 * @throws { BusinessError } 13900023 - Text file busy
2567 * @throws { BusinessError } 13900024 - File too large
2568 * @throws { BusinessError } 13900027 - Read-only file system
2569 * @throws { BusinessError } 13900030 - File name too long
2570 * @throws { BusinessError } 13900033 - Too many symbolic links encountered
2571 * @throws { BusinessError } 13900042 - Unknown error
2572 * @syscap SystemCapability.FileManagement.File.FileIO
2573 * @since 20
2574 */
2575function truncate(file: string | number, callback: AsyncCallback<void>): void;
2576
2577/**
2578 * Truncate file.
2579 *
2580 * @param { string | number } file - path or file descriptor.
2581 * @param { number } [len = 0] - len.
2582 * @param { AsyncCallback<void> } callback - Return the callback function.
2583 * @throws { BusinessError } 13900001 - Operation not permitted
2584 * @throws { BusinessError } 13900002 - No such file or directory
2585 * @throws { BusinessError } 13900004 - Interrupted system call
2586 * @throws { BusinessError } 13900005 - I/O error
2587 * @throws { BusinessError } 13900008 - Bad file descriptor
2588 * @throws { BusinessError } 13900012 - Permission denied
2589 * @throws { BusinessError } 13900013 - Bad address
2590 * @throws { BusinessError } 13900018 - Not a directory
2591 * @throws { BusinessError } 13900019 - Is a directory
2592 * @throws { BusinessError } 13900020 - Invalid argument
2593 * @throws { BusinessError } 13900023 - Text file busy
2594 * @throws { BusinessError } 13900024 - File too large
2595 * @throws { BusinessError } 13900027 - Read-only file system
2596 * @throws { BusinessError } 13900030 - File name too long
2597 * @throws { BusinessError } 13900033 - Too many symbolic links encountered
2598 * @throws { BusinessError } 13900042 - Unknown error
2599 * @syscap SystemCapability.FileManagement.File.FileIO
2600 * @since 20
2601 */
2602function truncate(file: string | number, len: number, callback: AsyncCallback<void>): void;
2603
2604/**
2605 * Truncate file with sync interface.
2606 *
2607 * @param { string | number } file - path or file descriptor.
2608 * @param { number } [len = 0] - len.
2609 * @throws { BusinessError } 13900001 - Operation not permitted
2610 * @throws { BusinessError } 13900002 - No such file or directory
2611 * @throws { BusinessError } 13900004 - Interrupted system call
2612 * @throws { BusinessError } 13900005 - I/O error
2613 * @throws { BusinessError } 13900008 - Bad file descriptor
2614 * @throws { BusinessError } 13900012 - Permission denied
2615 * @throws { BusinessError } 13900013 - Bad address
2616 * @throws { BusinessError } 13900018 - Not a directory
2617 * @throws { BusinessError } 13900019 - Is a directory
2618 * @throws { BusinessError } 13900020 - Invalid argument
2619 * @throws { BusinessError } 13900023 - Text file busy
2620 * @throws { BusinessError } 13900024 - File too large
2621 * @throws { BusinessError } 13900027 - Read-only file system
2622 * @throws { BusinessError } 13900030 - File name too long
2623 * @throws { BusinessError } 13900033 - Too many symbolic links encountered
2624 * @throws { BusinessError } 13900042 - Unknown error
2625 * @syscap SystemCapability.FileManagement.File.FileIO
2626 * @since 20
2627 */
2628function truncateSync(file: string | number, len?: number): void;
2629
2630/**
2631 * Delete file.
2632 *
2633 * @param { string } path - path.
2634 * @returns { Promise<void> } The promise returned by the function.
2635 * @throws { BusinessError } 13900001 - Operation not permitted
2636 * @throws { BusinessError } 13900002 - No such file or directory
2637 * @throws { BusinessError } 13900005 - I/O error
2638 * @throws { BusinessError } 13900008 - Bad file descriptor
2639 * @throws { BusinessError } 13900011 - Out of memory
2640 * @throws { BusinessError } 13900012 - Permission denied
2641 * @throws { BusinessError } 13900013 - Bad address
2642 * @throws { BusinessError } 13900014 - Device or resource busy
2643 * @throws { BusinessError } 13900018 - Not a directory
2644 * @throws { BusinessError } 13900019 - Is a directory
2645 * @throws { BusinessError } 13900020 - Invalid argument
2646 * @throws { BusinessError } 13900027 - Read-only file system
2647 * @throws { BusinessError } 13900030 - File name too long
2648 * @throws { BusinessError } 13900033 - Too many symbolic links encountered
2649 * @throws { BusinessError } 13900042 - Unknown error
2650 * @syscap SystemCapability.FileManagement.File.FileIO
2651 * @since 20
2652 */
2653function unlink(path: string): Promise<void>;
2654
2655/**
2656 * Delete file.
2657 *
2658 * @param { string } path - path.
2659 * @param { AsyncCallback<void> } callback - Return the callback function.
2660 * @throws { BusinessError } 13900001 - Operation not permitted
2661 * @throws { BusinessError } 13900002 - No such file or directory
2662 * @throws { BusinessError } 13900005 - I/O error
2663 * @throws { BusinessError } 13900008 - Bad file descriptor
2664 * @throws { BusinessError } 13900011 - Out of memory
2665 * @throws { BusinessError } 13900012 - Permission denied
2666 * @throws { BusinessError } 13900013 - Bad address
2667 * @throws { BusinessError } 13900014 - Device or resource busy
2668 * @throws { BusinessError } 13900018 - Not a directory
2669 * @throws { BusinessError } 13900019 - Is a directory
2670 * @throws { BusinessError } 13900020 - Invalid argument
2671 * @throws { BusinessError } 13900027 - Read-only file system
2672 * @throws { BusinessError } 13900030 - File name too long
2673 * @throws { BusinessError } 13900033 - Too many symbolic links encountered
2674 * @throws { BusinessError } 13900042 - Unknown error
2675 * @syscap SystemCapability.FileManagement.File.FileIO
2676 * @since 20
2677 */
2678function unlink(path: string, callback: AsyncCallback<void>): void;
2679
2680/**
2681 * Delete file with sync interface.
2682 *
2683 * @param { string } path - path.
2684 * @throws { BusinessError } 13900001 - Operation not permitted
2685 * @throws { BusinessError } 13900002 - No such file or directory
2686 * @throws { BusinessError } 13900005 - I/O error
2687 * @throws { BusinessError } 13900008 - Bad file descriptor
2688 * @throws { BusinessError } 13900011 - Out of memory
2689 * @throws { BusinessError } 13900012 - Permission denied
2690 * @throws { BusinessError } 13900013 - Bad address
2691 * @throws { BusinessError } 13900014 - Device or resource busy
2692 * @throws { BusinessError } 13900018 - Not a directory
2693 * @throws { BusinessError } 13900019 - Is a directory
2694 * @throws { BusinessError } 13900020 - Invalid argument
2695 * @throws { BusinessError } 13900027 - Read-only file system
2696 * @throws { BusinessError } 13900030 - File name too long
2697 * @throws { BusinessError } 13900033 - Too many symbolic links encountered
2698 * @throws { BusinessError } 13900042 - Unknown error
2699 * @syscap SystemCapability.FileManagement.File.FileIO
2700 * @since 20
2701 */
2702function unlinkSync(path: string): void;
2703
2704/**
2705 * Change file mtime.
2706 *
2707 * @param { string } path - path.
2708 * @param { number } mtime - last modification time
2709 * @throws { BusinessError } 13900001 - Operation not permitted
2710 * @throws { BusinessError } 13900002 - No such file or directory
2711 * @throws { BusinessError } 13900012 - Permission denied
2712 * @throws { BusinessError } 13900020 - Invalid argument
2713 * @throws { BusinessError } 13900027 - Read-only file system
2714 * @throws { BusinessError } 13900042 - Unknown error
2715 * @syscap SystemCapability.FileManagement.File.FileIO
2716 * @since 20
2717 */
2718function utimes(path: string, mtime: number): void;
2719
2720/**
2721 * Write file.
2722 *
2723 * @param { number } fd - file descriptor.
2724 * @param { ArrayBuffer | string } buffer - buffer.
2725 * @param { WriteOptions } [options] - options.
2726 * @returns { Promise<number> } Returns the number of bytes written to the file in promise mode.
2727 * @throws { BusinessError } 13900001 - Operation not permitted
2728 * @throws { BusinessError } 13900004 - Interrupted system call
2729 * @throws { BusinessError } 13900005 - I/O error
2730 * @throws { BusinessError } 13900008 - Bad file descriptor
2731 * @throws { BusinessError } 13900010 - Try again
2732 * @throws { BusinessError } 13900013 - Bad address
2733 * @throws { BusinessError } 13900020 - Invalid argument
2734 * @throws { BusinessError } 13900024 - File too large
2735 * @throws { BusinessError } 13900025 - No space left on device
2736 * @throws { BusinessError } 13900034 - Operation would block
2737 * @throws { BusinessError } 13900041 - Quota exceeded
2738 * @throws { BusinessError } 13900042 - Unknown error
2739 * @syscap SystemCapability.FileManagement.File.FileIO
2740 * @since 20
2741 */
2742function write(
2743  fd: number,
2744  buffer: ArrayBuffer | string,
2745  options?: WriteOptions
2746): Promise<number>;
2747
2748/**
2749 * Write file.
2750 *
2751 * @param { number } fd - file descriptor.
2752 * @param { ArrayBuffer | string } buffer - buffer.
2753 * @param { AsyncCallback<number> } callback - The callback is used to return the number of bytes written to the file.
2754 * @throws { BusinessError } 13900001 - Operation not permitted
2755 * @throws { BusinessError } 13900004 - Interrupted system call
2756 * @throws { BusinessError } 13900005 - I/O error
2757 * @throws { BusinessError } 13900008 - Bad file descriptor
2758 * @throws { BusinessError } 13900010 - Try again
2759 * @throws { BusinessError } 13900013 - Bad address
2760 * @throws { BusinessError } 13900020 - Invalid argument
2761 * @throws { BusinessError } 13900024 - File too large
2762 * @throws { BusinessError } 13900025 - No space left on device
2763 * @throws { BusinessError } 13900034 - Operation would block
2764 * @throws { BusinessError } 13900041 - Quota exceeded
2765 * @throws { BusinessError } 13900042 - Unknown error
2766 * @syscap SystemCapability.FileManagement.File.FileIO
2767 * @since 20
2768 */
2769function write(fd: number, buffer: ArrayBuffer | string, callback: AsyncCallback<number>): void;
2770
2771/**
2772 * Write file.
2773 *
2774 * @param { number } fd - file descriptor.
2775 * @param { ArrayBuffer | string } buffer - buffer.
2776 * @param { WriteOptions } [options] - options.
2777 * @param { AsyncCallback<number> } callback - The callback is used to return the number of bytes written to the file.
2778 * @throws { BusinessError } 13900001 - Operation not permitted
2779 * @throws { BusinessError } 13900004 - Interrupted system call
2780 * @throws { BusinessError } 13900005 - I/O error
2781 * @throws { BusinessError } 13900008 - Bad file descriptor
2782 * @throws { BusinessError } 13900010 - Try again
2783 * @throws { BusinessError } 13900013 - Bad address
2784 * @throws { BusinessError } 13900020 - Invalid argument
2785 * @throws { BusinessError } 13900024 - File too large
2786 * @throws { BusinessError } 13900025 - No space left on device
2787 * @throws { BusinessError } 13900034 - Operation would block
2788 * @throws { BusinessError } 13900041 - Quota exceeded
2789 * @throws { BusinessError } 13900042 - Unknown error
2790 * @syscap SystemCapability.FileManagement.File.FileIO
2791 * @since 20
2792 */
2793function write(
2794  fd: number,
2795  buffer: ArrayBuffer | string,
2796  options: WriteOptions,
2797  callback: AsyncCallback<number>
2798): void;
2799
2800/**
2801 * Write file with sync interface.
2802 *
2803 * @param { number } fd - file descriptor.
2804 * @param { ArrayBuffer | string } buffer - buffer.
2805 * @param { WriteOptions } [options] - options.
2806 * @returns { number } Returns the number of bytes written to the file.
2807 * @throws { BusinessError } 13900001 - Operation not permitted
2808 * @throws { BusinessError } 13900004 - Interrupted system call
2809 * @throws { BusinessError } 13900005 - I/O error
2810 * @throws { BusinessError } 13900008 - Bad file descriptor
2811 * @throws { BusinessError } 13900010 - Try again
2812 * @throws { BusinessError } 13900013 - Bad address
2813 * @throws { BusinessError } 13900020 - Invalid argument
2814 * @throws { BusinessError } 13900024 - File too large
2815 * @throws { BusinessError } 13900025 - No space left on device
2816 * @throws { BusinessError } 13900034 - Operation would block
2817 * @throws { BusinessError } 13900041 - Quota exceeded
2818 * @throws { BusinessError } 13900042 - Unknown error
2819 * @syscap SystemCapability.FileManagement.File.FileIO
2820 * @since 20
2821 */
2822function writeSync(
2823  fd: number,
2824  buffer: ArrayBuffer | string,
2825  options?: WriteOptions
2826): number;
2827
2828/**
2829 * Set extended attributes information of the file.
2830 *
2831 * @param { string } path - path.
2832 * @param { string } key - the key of extended attribute.
2833 * @param { string } value - the value of extended attribute.
2834 * @returns { Promise<void> } The promise returned by the function.
2835 * @throws { BusinessError } 401 - Parameter error.Possible causes:1.Mandatory parameters are left unspecified;
2836 * <br>2.Incorrect parameter types.
2837 * @throws { BusinessError } 13900002 - No such file or directory
2838 * @throws { BusinessError } 13900011 - Out of memory
2839 * @throws { BusinessError } 13900012 - Permission denied
2840 * @throws { BusinessError } 13900020 - Invalid argument
2841 * @throws { BusinessError } 13900025 - No space left on device
2842 * @throws { BusinessError } 13900031 - Function not implemented
2843 * @throws { BusinessError } 13900038 - Value too large for defined data type
2844 * @throws { BusinessError } 13900041 - Quota exceeded
2845 * @throws { BusinessError } 13900042 - Unknown error
2846 * @syscap SystemCapability.FileManagement.File.FileIO
2847 * @since 20
2848 */
2849function setxattr(path: string, key: string, value: string): Promise<void>;
2850
2851/**
2852 * Set extended attributes information of the file.
2853 *
2854 * @param { string } path - path.
2855 * @param { string } key - the key of extended attribute.
2856 * @param { string } value - the value of extended attribute.
2857 * @throws { BusinessError } 401 - Parameter error.Possible causes:1.Mandatory parameters are left unspecified;
2858 * <br>2.Incorrect parameter types.
2859 * @throws { BusinessError } 13900002 - No such file or directory
2860 * @throws { BusinessError } 13900011 - Out of memory
2861 * @throws { BusinessError } 13900012 - Permission denied
2862 * @throws { BusinessError } 13900020 - Invalid argument
2863 * @throws { BusinessError } 13900025 - No space left on device
2864 * @throws { BusinessError } 13900031 - Function not implemented
2865 * @throws { BusinessError } 13900038 - Value too large for defined data type
2866 * @throws { BusinessError } 13900041 - Quota exceeded
2867 * @throws { BusinessError } 13900042 - Unknown error
2868 * @syscap SystemCapability.FileManagement.File.FileIO
2869 * @since 20
2870 */
2871
2872function setxattrSync(path: string, key: string, value: string): void;
2873
2874/**
2875 * Get extended attributes information of the file.
2876 *
2877 * @param { string } path - path.
2878 * @param { string } key - the key of extended attribute.
2879 * @returns { Promise<string> } The promise returned by the function.
2880 * @throws { BusinessError } 401 - Parameter error.Possible causes:1.Mandatory parameters are left unspecified;
2881 * <br>2.Incorrect parameter types.
2882 * @throws { BusinessError } 13900002 - No such file or directory
2883 * @throws { BusinessError } 13900007 - Arg list too long
2884 * @throws { BusinessError } 13900012 - Permission denied
2885 * @throws { BusinessError } 13900031 - Function not implemented
2886 * @throws { BusinessError } 13900037 - No data available
2887 * @throws { BusinessError } 13900038 - Value too large for defined data type
2888 * @throws { BusinessError } 13900042 - Unknown error
2889 * @syscap SystemCapability.FileManagement.File.FileIO
2890 * @since 20
2891 */
2892function getxattr(path: string, key: string): Promise<string>;
2893
2894/**
2895 * Get extended attributes information of the file with sync interface.
2896 *
2897 * @param { string } path - path.
2898 * @param { string } key - the key of extended attribute.
2899 * @returns { string } Return the value of extended attribute.
2900 * @throws { BusinessError } 401 - Parameter error.Possible causes:1.Mandatory parameters are left unspecified;
2901 * <br>2.Incorrect parameter types.
2902 * @throws { BusinessError } 13900002 - No such file or directory
2903 * @throws { BusinessError } 13900007 - Arg list too long
2904 * @throws { BusinessError } 13900012 - Permission denied
2905 * @throws { BusinessError } 13900031 - Function not implemented
2906 * @throws { BusinessError } 13900037 - No data available
2907 * @throws { BusinessError } 13900038 - Value too large for defined data type
2908 * @throws { BusinessError } 13900042 - Unknown error
2909 * @syscap SystemCapability.FileManagement.File.FileIO
2910 * @since 20
2911 */
2912function getxattrSync(path: string, key: string): string;
2913
2914/**
2915 * Progress data of copyFile
2916 *
2917 * @typedef Progress
2918 * @syscap SystemCapability.FileManagement.File.FileIO
2919 * @since 20
2920 */
2921interface Progress {
2922  /**
2923   * @type { number }
2924   * @readonly
2925   * @syscap SystemCapability.FileManagement.File.FileIO
2926   * @since 20
2927   */
2928  readonly processedSize: number;
2929
2930  /**
2931   * @type { number }
2932   * @readonly
2933   * @syscap SystemCapability.FileManagement.File.FileIO
2934   * @since 20
2935   */
2936  readonly totalSize: number;
2937}
2938
2939/**
2940 * Task signal.
2941 *
2942 * @syscap SystemCapability.FileManagement.File.FileIO
2943 * @since 20
2944 */
2945class TaskSignal {
2946  /**
2947   * Cancel the copy task in progress.
2948   *
2949   * @throws { BusinessError } 13900010 - Try again
2950   * @throws { BusinessError } 13900012 - Permission denied by the file system
2951   * @throws { BusinessError } 13900043 - No task can be canceled.
2952   * @syscap SystemCapability.FileManagement.File.FileIO
2953   * @since 20
2954   */
2955  cancel(): void;
2956
2957  /**
2958   * Subscribe the cancel event of current task.
2959   *
2960   * @returns { Promise<string> } Return the result of the cancel event.
2961   * @throws { BusinessError } 13900004 - Interrupted system call
2962   * @throws { BusinessError } 13900008 - Bad file descriptor
2963   * @throws { BusinessError } 13900042 - Unknown error
2964   * @syscap SystemCapability.FileManagement.File.FileIO
2965   * @since 20
2966   */
2967  onCancel(): Promise<string>;
2968}
2969
2970/**
2971 * Get options of copy
2972 *
2973 * @typedef CopyOptions
2974 * @syscap SystemCapability.FileManagement.File.FileIO
2975 * @since 20
2976 */
2977interface CopyOptions {
2978  /**
2979   * Listener of copy progress
2980   *
2981   * @type { ?ProgressListener }
2982   * @syscap SystemCapability.FileManagement.File.FileIO
2983   * @since 20
2984   */
2985  progressListener?: ProgressListener;
2986  /**
2987   * Cancel signal of copy.
2988   *
2989   * @type { ?TaskSignal }
2990   * @syscap SystemCapability.FileManagement.File.FileIO
2991   * @since 20
2992   */
2993  copySignal?: TaskSignal;
2994}
2995
2996/**
2997 * Listener of copy progress.
2998 *
2999 * @typedef { function } ProgressListener
3000 * @param { Progress } progress - indicates the progress data of copyFile
3001 * @syscap SystemCapability.FileManagement.File.FileIO
3002 * @since 20
3003 */
3004type ProgressListener = (progress: Progress) => void;
3005
3006/**
3007 * File object.
3008 *
3009 * @interface File
3010 * @syscap SystemCapability.FileManagement.File.FileIO
3011 * @since 20
3012 */
3013interface File {
3014
3015  /**
3016   * @type { number }
3017   * @readonly
3018   * @syscap SystemCapability.FileManagement.File.FileIO
3019   * @since 20
3020   */
3021  readonly fd: number;
3022
3023  /**
3024   * File path
3025   *
3026   * @type { string }
3027   * @readonly
3028   * @throws { BusinessError } 13900005 - I/O error
3029   * @throws { BusinessError } 13900042 - Unknown error
3030   * @throws { BusinessError } 14300002 - Invalid URI
3031   * @syscap SystemCapability.FileManagement.File.FileIO
3032   * @since 20
3033   */
3034  readonly path: string;
3035
3036  /**
3037   * File name
3038   *
3039   * @type { string }
3040   * @readonly
3041   * @throws { BusinessError } 13900005 - I/O error
3042   * @throws { BusinessError } 13900042 - Unknown error
3043   * @syscap SystemCapability.FileManagement.File.FileIO
3044   * @since 20
3045   */
3046  readonly name: string;
3047
3048  /**
3049   * Get parent path of file.
3050   *
3051   * @returns { string } Return the parent path of file.
3052   * @throws { BusinessError } 13900005 - I/O error
3053   * @throws { BusinessError } 13900042 - Unknown error
3054   * @throws { BusinessError } 14300002 - Invalid URI
3055   * @syscap SystemCapability.FileManagement.File.FileIO
3056   * @since 20
3057   */
3058  getParent(): string;
3059
3060  /**
3061   * Lock file with blocking method.
3062   *
3063   * @param { boolean } exclusive - whether lock is exclusive.
3064   * @returns { Promise<void> } The promise returned by the function.
3065   * @throws { BusinessError } 13900004 - Interrupted system call
3066   * @throws { BusinessError } 13900008 - Bad file descriptor
3067   * @throws { BusinessError } 13900020 - Invalid argument
3068   * @throws { BusinessError } 13900034 - Operation would block
3069   * @throws { BusinessError } 13900042 - Unknown error
3070   * @throws { BusinessError } 13900043 - No record locks available
3071   * @syscap SystemCapability.FileManagement.File.FileIO
3072   * @since 20
3073   */
3074  lock(exclusive?: boolean): Promise<void>;
3075
3076  /**
3077   * Lock file with blocking method.
3078   *
3079   * @param { AsyncCallback<void> } callback - Return the callback function.
3080   * @throws { BusinessError } 13900004 - Interrupted system call
3081   * @throws { BusinessError } 13900008 - Bad file descriptor
3082   * @throws { BusinessError } 13900020 - Invalid argument
3083   * @throws { BusinessError } 13900034 - Operation would block
3084   * @throws { BusinessError } 13900042 - Unknown error
3085   * @throws { BusinessError } 13900043 - No record locks available
3086   * @syscap SystemCapability.FileManagement.File.FileIO
3087   * @since 20
3088   */
3089  lock(callback: AsyncCallback<void>): void;
3090
3091  /**
3092   * Lock file with blocking method.
3093   *
3094   * @param { boolean } exclusive - whether lock is exclusive.
3095   * @param { AsyncCallback<void> } callback - Return the callback function.
3096   * @throws { BusinessError } 13900004 - Interrupted system call
3097   * @throws { BusinessError } 13900008 - Bad file descriptor
3098   * @throws { BusinessError } 13900020 - Invalid argument
3099   * @throws { BusinessError } 13900034 - Operation would block
3100   * @throws { BusinessError } 13900042 - Unknown error
3101   * @throws { BusinessError } 13900043 - No record locks available
3102   * @syscap SystemCapability.FileManagement.File.FileIO
3103   * @since 20
3104   */
3105  lock(exclusive: boolean, callback: AsyncCallback<void>): void;
3106
3107  /**
3108   * Try to lock file with returning results immediately.
3109   *
3110   * @param { boolean } exclusive - whether lock is exclusive.
3111   * @throws { BusinessError } 13900004 - Interrupted system call
3112   * @throws { BusinessError } 13900008 - Bad file descriptor
3113   * @throws { BusinessError } 13900020 - Invalid argument
3114   * @throws { BusinessError } 13900034 - Operation would block
3115   * @throws { BusinessError } 13900042 - Unknown error
3116   * @throws { BusinessError } 13900043 - No record locks available
3117   * @syscap SystemCapability.FileManagement.File.FileIO
3118   * @since 20
3119   */
3120  tryLock(exclusive?: boolean): void;
3121
3122  /**
3123   * Unlock file.
3124   *
3125   * @throws { BusinessError } 13900004 - Interrupted system call
3126   * @throws { BusinessError } 13900008 - Bad file descriptor
3127   * @throws { BusinessError } 13900020 - Invalid argument
3128   * @throws { BusinessError } 13900034 - Operation would block
3129   * @throws { BusinessError } 13900042 - Unknown error
3130   * @throws { BusinessError } 13900043 - No record locks available
3131   * @syscap SystemCapability.FileManagement.File.FileIO
3132   * @since 20
3133   */
3134  unlock(): void;
3135}
3136
3137/**
3138 * RandomAccessFile object.
3139 *
3140 * @interface RandomAccessFile
3141 * @syscap SystemCapability.FileManagement.File.FileIO
3142 * @since 20
3143 */
3144interface RandomAccessFile {
3145
3146  /**
3147   * File descriptor
3148   *
3149   * @type { number }
3150   * @readonly
3151   * @syscap SystemCapability.FileManagement.File.FileIO
3152   * @since 20
3153   */
3154  readonly fd: number;
3155
3156  /**
3157   * File pointer
3158   *
3159   * @type { number }
3160   * @readonly
3161   * @syscap SystemCapability.FileManagement.File.FileIO
3162   * @since 20
3163   */
3164  readonly filePointer: number;
3165
3166  /**
3167   * Set file pointer.
3168   *
3169   * @param { number } filePointer - filePointer.
3170   * @throws { BusinessError } 13900004 - Interrupted system call
3171   * @throws { BusinessError } 13900005 - I/O error
3172   * @throws { BusinessError } 13900008 - Bad file descriptor
3173   * @throws { BusinessError } 13900020 - Invalid argument
3174   * @throws { BusinessError } 13900042 - Unknown error
3175   * @syscap SystemCapability.FileManagement.File.FileIO
3176   * @since 20
3177   */
3178  setFilePointer(filePointer: number): void;
3179
3180  /**
3181   * Close randomAccessFile with sync interface.
3182   *
3183   * @throws { BusinessError } 13900004 - Interrupted system call
3184   * @throws { BusinessError } 13900005 - I/O error
3185   * @throws { BusinessError } 13900008 - Bad file descriptor
3186   * @throws { BusinessError } 13900025 - No space left on device
3187   * @throws { BusinessError } 13900041 - Quota exceeded
3188   * @throws { BusinessError } 13900042 - Unknown error
3189   * @syscap SystemCapability.FileManagement.File.FileIO
3190   * @since 20
3191   */
3192  close(): void;
3193
3194  /**
3195   * Write randomAccessFile.
3196   *
3197   * @param { ArrayBuffer | string } buffer - buffer.
3198   * @param { WriteOptions } [options] - options.
3199   * @returns { Promise<number> } Returns the number of bytes written to the file in promise mode.
3200   * @throws { BusinessError } 13900001 - Operation not permitted
3201   * @throws { BusinessError } 13900004 - Interrupted system call
3202   * @throws { BusinessError } 13900005 - I/O error
3203   * @throws { BusinessError } 13900008 - Bad file descriptor
3204   * @throws { BusinessError } 13900010 - Try again
3205   * @throws { BusinessError } 13900013 - Bad address
3206   * @throws { BusinessError } 13900020 - Invalid argument
3207   * @throws { BusinessError } 13900024 - File too large
3208   * @throws { BusinessError } 13900025 - No space left on device
3209   * @throws { BusinessError } 13900034 - Operation would block
3210   * @throws { BusinessError } 13900041 - Quota exceeded
3211   * @throws { BusinessError } 13900042 - Unknown error
3212   * @syscap SystemCapability.FileManagement.File.FileIO
3213   * @since 20
3214   */
3215  write(
3216    buffer: ArrayBuffer | string,
3217    options?: WriteOptions
3218  ): Promise<number>;
3219
3220  /**
3221   * Write randomAccessFile.
3222   *
3223   * @param { ArrayBuffer | string } buffer - buffer.
3224   * @param { AsyncCallback<number> } callback - The callback is used to return the number of bytes written to the file.
3225   * @throws { BusinessError } 13900001 - Operation not permitted
3226   * @throws { BusinessError } 13900004 - Interrupted system call
3227   * @throws { BusinessError } 13900005 - I/O error
3228   * @throws { BusinessError } 13900008 - Bad file descriptor
3229   * @throws { BusinessError } 13900010 - Try again
3230   * @throws { BusinessError } 13900013 - Bad address
3231   * @throws { BusinessError } 13900020 - Invalid argument
3232   * @throws { BusinessError } 13900024 - File too large
3233   * @throws { BusinessError } 13900025 - No space left on device
3234   * @throws { BusinessError } 13900034 - Operation would block
3235   * @throws { BusinessError } 13900041 - Quota exceeded
3236   * @throws { BusinessError } 13900042 - Unknown error
3237   * @syscap SystemCapability.FileManagement.File.FileIO
3238   * @since 20
3239   */
3240  write(buffer: ArrayBuffer | string, callback: AsyncCallback<number>): void;
3241
3242  /**
3243   * Write randomAccessFile.
3244   *
3245   * @param { ArrayBuffer | string } buffer - buffer.
3246   * @param { WriteOptions } [options] - options.
3247   * @param { AsyncCallback<number> } callback - The callback is used to return the number of bytes written to the file.
3248   * @throws { BusinessError } 13900001 - Operation not permitted
3249   * @throws { BusinessError } 13900004 - Interrupted system call
3250   * @throws { BusinessError } 13900005 - I/O error
3251   * @throws { BusinessError } 13900008 - Bad file descriptor
3252   * @throws { BusinessError } 13900010 - Try again
3253   * @throws { BusinessError } 13900013 - Bad address
3254   * @throws { BusinessError } 13900020 - Invalid argument
3255   * @throws { BusinessError } 13900024 - File too large
3256   * @throws { BusinessError } 13900025 - No space left on device
3257   * @throws { BusinessError } 13900034 - Operation would block
3258   * @throws { BusinessError } 13900041 - Quota exceeded
3259   * @throws { BusinessError } 13900042 - Unknown error
3260   * @syscap SystemCapability.FileManagement.File.FileIO
3261   * @since 20
3262   */
3263  write(
3264    buffer: ArrayBuffer | string,
3265    options: WriteOptions,
3266    callback: AsyncCallback<number>
3267  ): void;
3268
3269  /**
3270   * Write randomAccessFile with sync interface.
3271   *
3272   * @param { ArrayBuffer | string } buffer - buffer.
3273   * @param { WriteOptions } [options] - options.
3274   * @returns { number } Returns the number of bytes written to the file.
3275   * @throws { BusinessError } 13900001 - Operation not permitted
3276   * @throws { BusinessError } 13900004 - Interrupted system call
3277   * @throws { BusinessError } 13900005 - I/O error
3278   * @throws { BusinessError } 13900008 - Bad file descriptor
3279   * @throws { BusinessError } 13900010 - Try again
3280   * @throws { BusinessError } 13900013 - Bad address
3281   * @throws { BusinessError } 13900020 - Invalid argument
3282   * @throws { BusinessError } 13900024 - File too large
3283   * @throws { BusinessError } 13900025 - No space left on device
3284   * @throws { BusinessError } 13900034 - Operation would block
3285   * @throws { BusinessError } 13900041 - Quota exceeded
3286   * @throws { BusinessError } 13900042 - Unknown error
3287   * @syscap SystemCapability.FileManagement.File.FileIO
3288   * @since 20
3289   */
3290  writeSync(
3291    buffer: ArrayBuffer | string,
3292    options?: WriteOptions
3293  ): number;
3294
3295  /**
3296   * Read randomAccessFile.
3297   *
3298   * @param { ArrayBuffer } buffer - buffer.
3299   * @param { ReadOptions } [options] - options.
3300   * @returns { Promise<number> } Returns the number of file bytes read to buffer in promise mode.
3301   * @throws { BusinessError } 13900004 - Interrupted system call
3302   * @throws { BusinessError } 13900005 - I/O error
3303   * @throws { BusinessError } 13900008 - Bad file descriptor
3304   * @throws { BusinessError } 13900010 - Try again
3305   * @throws { BusinessError } 13900013 - Bad address
3306   * @throws { BusinessError } 13900019 - Is a directory
3307   * @throws { BusinessError } 13900020 - Invalid argument
3308   * @throws { BusinessError } 13900034 - Operation would block
3309   * @throws { BusinessError } 13900042 - Unknown error
3310   * @throws { BusinessError } 13900044 - Network is unreachable
3311   * @syscap SystemCapability.FileManagement.File.FileIO
3312   * @since 20
3313   */
3314  read(
3315    buffer: ArrayBuffer,
3316    options?: ReadOptions
3317  ): Promise<number>;
3318
3319  /**
3320   * Read randomAccessFile.
3321   *
3322   * @param { ArrayBuffer } buffer - buffer.
3323   * @param { AsyncCallback<number> } callback - The callback is used to return the number of file bytes read to buffer.
3324   * @throws { BusinessError } 13900004 - Interrupted system call
3325   * @throws { BusinessError } 13900005 - I/O error
3326   * @throws { BusinessError } 13900008 - Bad file descriptor
3327   * @throws { BusinessError } 13900010 - Try again
3328   * @throws { BusinessError } 13900013 - Bad address
3329   * @throws { BusinessError } 13900019 - Is a directory
3330   * @throws { BusinessError } 13900020 - Invalid argument
3331   * @throws { BusinessError } 13900034 - Operation would block
3332   * @throws { BusinessError } 13900042 - Unknown error
3333   * @syscap SystemCapability.FileManagement.File.FileIO
3334   * @since 20
3335   */
3336  read(buffer: ArrayBuffer, callback: AsyncCallback<number>): void;
3337
3338  /**
3339  * Read randomAccessFile.
3340  *
3341  * @param { ArrayBuffer } buffer - buffer.
3342  * @param { ReadOptions } [options] - options.
3343  * @param { AsyncCallback<number> } callback - The callback is used to return the number of file bytes read to buffer.
3344  * @throws { BusinessError } 13900004 - Interrupted system call
3345  * @throws { BusinessError } 13900005 - I/O error
3346  * @throws { BusinessError } 13900008 - Bad file descriptor
3347  * @throws { BusinessError } 13900010 - Try again
3348  * @throws { BusinessError } 13900013 - Bad address
3349  * @throws { BusinessError } 13900019 - Is a directory
3350  * @throws { BusinessError } 13900020 - Invalid argument
3351  * @throws { BusinessError } 13900034 - Operation would block
3352  * @throws { BusinessError } 13900042 - Unknown error
3353  * @syscap SystemCapability.FileManagement.File.FileIO
3354  * @since 20
3355  */
3356  read(
3357    buffer: ArrayBuffer,
3358    options: ReadOptions,
3359    callback: AsyncCallback<number>
3360  ): void;
3361
3362  /**
3363   * Read randomAccessFile with sync interface.
3364   *
3365   * @param { ArrayBuffer } buffer - buffer.
3366   * @param { ReadOptions } [options] - options.
3367   * @returns { number } Returns the number of file bytes read to buffer.
3368   * @throws { BusinessError } 13900004 - Interrupted system call
3369   * @throws { BusinessError } 13900005 - I/O error
3370   * @throws { BusinessError } 13900008 - Bad file descriptor
3371   * @throws { BusinessError } 13900010 - Try again
3372   * @throws { BusinessError } 13900013 - Bad address
3373   * @throws { BusinessError } 13900019 - Is a directory
3374   * @throws { BusinessError } 13900020 - Invalid argument
3375   * @throws { BusinessError } 13900034 - Operation would block
3376   * @throws { BusinessError } 13900042 - Unknown error
3377   * @throws { BusinessError } 13900044 - Network is unreachable
3378   * @syscap SystemCapability.FileManagement.File.FileIO
3379   * @since 20
3380   */
3381  readSync(
3382    buffer: ArrayBuffer,
3383    options?: ReadOptions
3384  ): number;
3385}
3386
3387/**
3388 * The AtomicFile class provides methods for performing atomic operations on files.
3389 * @syscap SystemCapability.FileManagement.File.FileIO
3390 * @since 20
3391 */
3392export class AtomicFile {
3393  /**
3394   * The AtomicFile constructor.
3395   * @param { string } path file path.
3396   * @throws { BusinessError } 401 Parameter error.Possible causes:1.Mandatory parameters are left unspecified; 2.Incorrect parameter types.
3397   * @syscap SystemCapability.FileManagement.File.FileIO
3398   * @since 20
3399   */
3400  constructor(path: string);
3401
3402  /**
3403   * Get the File object from AtomicFile object.
3404   * @returns { File } Returns the file object.
3405   * @throws { BusinessError } 13900002 No such file or directory
3406   * @throws { BusinessError } 13900005 IO error
3407   * @throws { BusinessError } 13900012 Permission denied
3408   * @throws { BusinessError } 13900042 Internal error
3409   * @syscap SystemCapability.FileManagement.File.FileIO
3410   * @since 20
3411   */
3412  getBaseFile(): File;
3413
3414  /**
3415   * Read the entire contents of the file.
3416   * @returns { ArrayBuffer } Returns the ArrayBuffer of the file contents.
3417   * @throws { BusinessError } 13900005 I/O error
3418   * @throws { BusinessError } 13900042 Internal error
3419   * @syscap SystemCapability.FileManagement.File.FileIO
3420   * @since 20
3421   */
3422  readFully(): ArrayBuffer;
3423
3424  /**
3425   * If the file is written successfully, the file is closed.
3426   * @throws { BusinessError } 13900042 Internal error
3427   * @syscap SystemCapability.FileManagement.File.FileIO
3428   * @since 20
3429   */
3430  finishWrite(): void;
3431
3432  /**
3433   * If writing to the file fails, the file is rolled back.
3434   * @throws { BusinessError } 13900042 Internal error
3435   * @syscap SystemCapability.FileManagement.File.FileIO
3436   * @since 20
3437   */
3438  failWrite(): void;
3439
3440  /**
3441   * Delete all file.
3442   * @throws { BusinessError } 13900001 Operation not permitted
3443   * @throws { BusinessError } 13900002 No such file or directory
3444   * @throws { BusinessError } 13900012 Permission denied
3445   * @throws { BusinessError } 13900027 Read-only file system
3446   * @throws { BusinessError } 13900042 Internal error
3447   * @syscap SystemCapability.FileManagement.File.FileIO
3448   * @since 20
3449   */
3450  delete(): void;
3451}
3452
3453/**
3454 * Stat object.
3455 *
3456 * @interface Stat
3457 * @syscap SystemCapability.FileManagement.File.FileIO
3458 * @since 20
3459 */
3460interface Stat {
3461
3462  /**
3463   * @type { bigint }
3464   * @readonly
3465   * @throws { BusinessError } 13900005 - I/O error
3466   * @throws { BusinessError } 13900042 - Unknown error
3467   * @syscap SystemCapability.FileManagement.File.FileIO
3468   * @since 20
3469   */
3470  readonly ino: bigint;
3471
3472  /**
3473   * @type { number }
3474   * @readonly
3475   * @throws { BusinessError } 13900005 - I/O error
3476   * @throws { BusinessError } 13900042 - Unknown error
3477   * @syscap SystemCapability.FileManagement.File.FileIO
3478   * @since 20
3479   */
3480  readonly mode: number;
3481
3482  /**
3483   * @type { number }
3484   * @readonly
3485   * @throws { BusinessError } 13900005 - I/O error
3486   * @throws { BusinessError } 13900042 - Unknown error
3487   * @throws { BusinessError } 13900005 - I/O error
3488   * @throws { BusinessError } 13900042 - Unknown error
3489   * @syscap SystemCapability.FileManagement.File.FileIO
3490   * @since 20
3491   */
3492  readonly uid: number;
3493
3494  /**
3495   * @type { number }
3496   * @readonly
3497   * @throws { BusinessError } 13900005 - I/O error
3498   * @throws { BusinessError } 13900042 - Unknown error
3499   * @syscap SystemCapability.FileManagement.File.FileIO
3500   * @since 20
3501   */
3502  readonly gid: number;
3503
3504  /**
3505   * @type { number }
3506   * @readonly
3507   * @throws { BusinessError } 13900005 - I/O error
3508   * @throws { BusinessError } 13900042 - Unknown error
3509   * @syscap SystemCapability.FileManagement.File.FileIO
3510   * @since 20
3511   */
3512  readonly size: number;
3513
3514  /**
3515   * @type { number }
3516   * @readonly
3517   * @throws { BusinessError } 13900005 - I/O error
3518   * @throws { BusinessError } 13900042 - Unknown error
3519   * @syscap SystemCapability.FileManagement.File.FileIO
3520   * @since 20
3521   */
3522  readonly atime: number;
3523
3524  /**
3525   * @type { number }
3526   * @readonly
3527   * @throws { BusinessError } 13900005 - I/O error
3528   * @throws { BusinessError } 13900042 - Unknown error
3529   * @syscap SystemCapability.FileManagement.File.FileIO
3530   * @since 20
3531   */
3532  readonly mtime: number;
3533
3534  /**
3535   * @type { number }
3536   * @readonly
3537   * @throws { BusinessError } 13900005 - I/O error
3538   * @throws { BusinessError } 13900042 - Unknown error
3539   * @syscap SystemCapability.FileManagement.File.FileIO
3540   * @since 20
3541   */
3542  readonly ctime: number;
3543
3544  /**
3545   * Returns nanosecond of the access time.
3546   * @type { bigint }
3547   * @readonly
3548   * @throws { BusinessError } 13900042 - Internal error
3549   * @syscap SystemCapability.FileManagement.File.FileIO
3550   * @since 20
3551   */
3552  readonly atimeNs?:bigint;
3553
3554  /**
3555   * Returns nanosecond of the modification time.
3556   * @type { bigint }
3557   * @readonly
3558   * @throws { BusinessError } 13900042 - Internal error
3559   * @syscap SystemCapability.FileManagement.File.FileIO
3560   * @since 20
3561   */
3562  readonly mtimeNs?:bigint;
3563
3564  /**
3565   * Returns nanosecond of the change time.
3566   * @type { bigint }
3567   * @readonly
3568   * @throws { BusinessError } 13900042 - Internal error
3569   * @syscap SystemCapability.FileManagement.File.FileIO
3570   * @since 20
3571   */
3572  readonly ctimeNs?:bigint;
3573
3574  /**
3575   *
3576   * @type { LocationType }
3577   * @readonly
3578   * @throws { BusinessError } 13900042 - Unknown error
3579   * @syscap SystemCapability.FileManagement.File.FileIO
3580   * @since 20
3581   */
3582  readonly location: LocationType;
3583
3584  /**
3585   * Whether path/fd is block device.
3586   *
3587   * @returns { boolean } Returns whether the path/fd point to a block device or not.
3588   * @throws { BusinessError } 13900005 - I/O error
3589   * @throws { BusinessError } 13900042 - Unknown error
3590   * @syscap SystemCapability.FileManagement.File.FileIO
3591   * @since 20
3592   */
3593  isBlockDevice(): boolean;
3594
3595  /**
3596   * Whether path/fd is character device.
3597   *
3598   * @returns { boolean } Returns whether the path/fd point to a character device or not.
3599   * @throws { BusinessError } 13900005 - I/O error
3600   * @throws { BusinessError } 13900042 - Unknown error
3601   * @syscap SystemCapability.FileManagement.File.FileIO
3602   * @since 20
3603   */
3604  isCharacterDevice(): boolean;
3605
3606  /**
3607   * Whether path/fd is directory.
3608   *
3609   * @returns { boolean } Returns whether the path/fd point to a directory or not.
3610   * @throws { BusinessError } 13900005 - I/O error
3611   * @throws { BusinessError } 13900042 - Unknown error
3612   * @syscap SystemCapability.FileManagement.File.FileIO
3613   * @since 20
3614   */
3615  isDirectory(): boolean;
3616
3617  /**
3618   * Whether path/fd is fifo.
3619   *
3620   * @returns { boolean } Returns whether the path/fd point to a fifo file or not.
3621   * @throws { BusinessError } 13900005 - I/O error
3622   * @throws { BusinessError } 13900042 - Unknown error
3623   * @syscap SystemCapability.FileManagement.File.FileIO
3624   * @since 20
3625   */
3626  isFIFO(): boolean;
3627
3628  /**
3629   * Whether path/fd is file.
3630   *
3631   * @returns { boolean } Returns whether the path/fd point to a normal file or not.
3632   * @throws { BusinessError } 13900005 - I/O error
3633   * @throws { BusinessError } 13900042 - Unknown error
3634   * @syscap SystemCapability.FileManagement.File.FileIO
3635   * @since 20
3636   */
3637  isFile(): boolean;
3638
3639  /**
3640   * Whether path/fd is socket.
3641   *
3642   * @returns { boolean } Returns whether the path/fd point to a socket file or not.
3643   * @throws { BusinessError } 13900005 - I/O error
3644   * @throws { BusinessError } 13900042 - Unknown error
3645   * @syscap SystemCapability.FileManagement.File.FileIO
3646   * @since 20
3647   */
3648  isSocket(): boolean;
3649
3650  /**
3651   * Whether path/fd is symbolic link.
3652   *
3653   * @returns { boolean } Returns whether the path/fd point to a symbolic link or not.
3654   * @throws { BusinessError } 13900005 - I/O error
3655   * @throws { BusinessError } 13900042 - Unknown error
3656   * @syscap SystemCapability.FileManagement.File.FileIO
3657   * @since 20
3658   */
3659  isSymbolicLink(): boolean;
3660}
3661
3662/**
3663 * Stream object
3664 *
3665 * @interface Stream
3666 * @syscap SystemCapability.FileManagement.File.FileIO
3667 * @since 20
3668 */
3669interface Stream {
3670  /**
3671   * Close stream.
3672   *
3673   * @returns { Promise<void> } The promise returned by the function.
3674   * @throws { BusinessError } 13900004 - Interrupted system call
3675   * @throws { BusinessError } 13900005 - I/O error
3676   * @throws { BusinessError } 13900008 - Bad file descriptor
3677   * @throws { BusinessError } 13900025 - No space left on device
3678   * @throws { BusinessError } 13900041 - Quota exceeded
3679   * @throws { BusinessError } 13900042 - Unknown error
3680   * @syscap SystemCapability.FileManagement.File.FileIO
3681   * @since 20
3682   */
3683  close(): Promise<void>;
3684
3685  /**
3686   * Close stream.
3687   *
3688   * @param { AsyncCallback<void> } callback - Return the callback function.
3689   * @throws { BusinessError } 13900004 - Interrupted system call
3690   * @throws { BusinessError } 13900005 - I/O error
3691   * @throws { BusinessError } 13900008 - Bad file descriptor
3692   * @throws { BusinessError } 13900025 - No space left on device
3693   * @throws { BusinessError } 13900041 - Quota exceeded
3694   * @throws { BusinessError } 13900042 - Unknown error
3695   * @syscap SystemCapability.FileManagement.File.FileIO
3696   * @since 20
3697   */
3698  close(callback: AsyncCallback<void>): void;
3699
3700  /**
3701   * Close stream with sync interface.
3702   *
3703   * @throws { BusinessError } 13900004 - Interrupted system call
3704   * @throws { BusinessError } 13900005 - I/O error
3705   * @throws { BusinessError } 13900008 - Bad file descriptor
3706   * @throws { BusinessError } 13900025 - No space left on device
3707   * @throws { BusinessError } 13900041 - Quota exceeded
3708   * @throws { BusinessError } 13900042 - Unknown error
3709   * @syscap SystemCapability.FileManagement.File.FileIO
3710   * @since 20
3711   */
3712  closeSync(): void;
3713
3714  /**
3715   * Flush stream.
3716   *
3717   * @returns { Promise<void> } The promise returned by the function.
3718   * @throws { BusinessError } 13900001 - Operation not permitted
3719   * @throws { BusinessError } 13900004 - Interrupted system call
3720   * @throws { BusinessError } 13900005 - I/O error
3721   * @throws { BusinessError } 13900008 - Bad file descriptor
3722   * @throws { BusinessError } 13900010 - Try again
3723   * @throws { BusinessError } 13900013 - Bad address
3724   * @throws { BusinessError } 13900020 - Invalid argument
3725   * @throws { BusinessError } 13900024 - File too large
3726   * @throws { BusinessError } 13900025 - No space left on device
3727   * @throws { BusinessError } 13900034 - Operation would block
3728   * @throws { BusinessError } 13900041 - Quota exceeded
3729   * @throws { BusinessError } 13900042 - Unknown error
3730   * @syscap SystemCapability.FileManagement.File.FileIO
3731   * @since 20
3732   */
3733  flush(): Promise<void>;
3734
3735  /**
3736   * Flush stream.
3737   *
3738   * @param { AsyncCallback<void> } callback - Return the callback function.
3739   * @throws { BusinessError } 13900001 - Operation not permitted
3740   * @throws { BusinessError } 13900004 - Interrupted system call
3741   * @throws { BusinessError } 13900005 - I/O error
3742   * @throws { BusinessError } 13900008 - Bad file descriptor
3743   * @throws { BusinessError } 13900010 - Try again
3744   * @throws { BusinessError } 13900013 - Bad address
3745   * @throws { BusinessError } 13900020 - Invalid argument
3746   * @throws { BusinessError } 13900024 - File too large
3747   * @throws { BusinessError } 13900025 - No space left on device
3748   * @throws { BusinessError } 13900034 - Operation would block
3749   * @throws { BusinessError } 13900041 - Quota exceeded
3750   * @throws { BusinessError } 13900042 - Unknown error
3751   * @syscap SystemCapability.FileManagement.File.FileIO
3752   * @since 20
3753   */
3754  flush(callback: AsyncCallback<void>): void;
3755
3756  /**
3757   * Flush stream with sync interface.
3758   *
3759   * @throws { BusinessError } 13900001 - Operation not permitted
3760   * @throws { BusinessError } 13900004 - Interrupted system call
3761   * @throws { BusinessError } 13900005 - I/O error
3762   * @throws { BusinessError } 13900008 - Bad file descriptor
3763   * @throws { BusinessError } 13900010 - Try again
3764   * @throws { BusinessError } 13900013 - Bad address
3765   * @throws { BusinessError } 13900020 - Invalid argument
3766   * @throws { BusinessError } 13900024 - File too large
3767   * @throws { BusinessError } 13900025 - No space left on device
3768   * @throws { BusinessError } 13900034 - Operation would block
3769   * @throws { BusinessError } 13900041 - Quota exceeded
3770   * @throws { BusinessError } 13900042 - Unknown error
3771   * @syscap SystemCapability.FileManagement.File.FileIO
3772   * @since 20
3773   */
3774  flushSync(): void;
3775
3776  /**
3777   * Write stream.
3778   *
3779   * @param { ArrayBuffer | string } buffer - buffer.
3780   * @param { WriteOptions } [options] - options.
3781   * @returns { Promise<number> } Returns the number of file bytes written to file in promise mode.
3782   * @throws { BusinessError } 13900001 - Operation not permitted
3783   * @throws { BusinessError } 13900004 - Interrupted system call
3784   * @throws { BusinessError } 13900005 - I/O error
3785   * @throws { BusinessError } 13900008 - Bad file descriptor
3786   * @throws { BusinessError } 13900010 - Try again
3787   * @throws { BusinessError } 13900013 - Bad address
3788   * @throws { BusinessError } 13900020 - Invalid argument
3789   * @throws { BusinessError } 13900024 - File too large
3790   * @throws { BusinessError } 13900025 - No space left on device
3791   * @throws { BusinessError } 13900034 - Operation would block
3792   * @throws { BusinessError } 13900041 - Quota exceeded
3793   * @throws { BusinessError } 13900042 - Unknown error
3794   * @syscap SystemCapability.FileManagement.File.FileIO
3795   * @since 20
3796   */
3797  write(
3798    buffer: ArrayBuffer | string,
3799    options?: WriteOptions
3800  ): Promise<number>;
3801
3802  /**
3803   * Write stream.
3804   *
3805   * @param { ArrayBuffer | string } buffer - buffer.
3806   * @param { AsyncCallback<number> } callback - The callback is used to return the number of file bytes written to file.
3807   * @throws { BusinessError } 13900001 - Operation not permitted
3808   * @throws { BusinessError } 13900004 - Interrupted system call
3809   * @throws { BusinessError } 13900005 - I/O error
3810   * @throws { BusinessError } 13900008 - Bad file descriptor
3811   * @throws { BusinessError } 13900010 - Try again
3812   * @throws { BusinessError } 13900013 - Bad address
3813   * @throws { BusinessError } 13900020 - Invalid argument
3814   * @throws { BusinessError } 13900024 - File too large
3815   * @throws { BusinessError } 13900025 - No space left on device
3816   * @throws { BusinessError } 13900034 - Operation would block
3817   * @throws { BusinessError } 13900041 - Quota exceeded
3818   * @throws { BusinessError } 13900042 - Unknown error
3819   * @syscap SystemCapability.FileManagement.File.FileIO
3820   * @since 20
3821   */
3822  write(buffer: ArrayBuffer | string, callback: AsyncCallback<number>): void;
3823
3824  /**
3825   * Write stream.
3826   *
3827   * @param { ArrayBuffer | string } buffer - buffer.
3828   * @param { WriteOptions } [options] - options.
3829   * @param { AsyncCallback<number> } callback - The callback is used to return the number of file bytes written to file.
3830   * @throws { BusinessError } 13900001 - Operation not permitted
3831   * @throws { BusinessError } 13900004 - Interrupted system call
3832   * @throws { BusinessError } 13900005 - I/O error
3833   * @throws { BusinessError } 13900008 - Bad file descriptor
3834   * @throws { BusinessError } 13900010 - Try again
3835   * @throws { BusinessError } 13900013 - Bad address
3836   * @throws { BusinessError } 13900020 - Invalid argument
3837   * @throws { BusinessError } 13900024 - File too large
3838   * @throws { BusinessError } 13900025 - No space left on device
3839   * @throws { BusinessError } 13900034 - Operation would block
3840   * @throws { BusinessError } 13900041 - Quota exceeded
3841   * @throws { BusinessError } 13900042 - Unknown error
3842   * @syscap SystemCapability.FileManagement.File.FileIO
3843   * @since 20
3844   */
3845  write(
3846    buffer: ArrayBuffer | string,
3847    options: WriteOptions,
3848    callback: AsyncCallback<number>
3849  ): void;
3850
3851  /**
3852   * Write stream with sync interface.
3853   *
3854   * @param { ArrayBuffer | string } buffer - buffer.
3855   * @param { WriteOptions } [options] - options.
3856   * @returns { number } Returns the number of file bytes written to file.
3857   * @throws { BusinessError } 13900001 - Operation not permitted
3858   * @throws { BusinessError } 13900004 - Interrupted system call
3859   * @throws { BusinessError } 13900005 - I/O error
3860   * @throws { BusinessError } 13900008 - Bad file descriptor
3861   * @throws { BusinessError } 13900010 - Try again
3862   * @throws { BusinessError } 13900013 - Bad address
3863   * @throws { BusinessError } 13900020 - Invalid argument
3864   * @throws { BusinessError } 13900024 - File too large
3865   * @throws { BusinessError } 13900025 - No space left on device
3866   * @throws { BusinessError } 13900034 - Operation would block
3867   * @throws { BusinessError } 13900041 - Quota exceeded
3868   * @throws { BusinessError } 13900042 - Unknown error
3869   * @syscap SystemCapability.FileManagement.File.FileIO
3870   * @since 20
3871   */
3872  writeSync(
3873    buffer: ArrayBuffer | string,
3874    options?: WriteOptions
3875  ): number;
3876
3877  /**
3878   * Read stream.
3879   *
3880   * @param { ArrayBuffer } buffer - buffer.
3881   * @param { ReadOptions } [options] - options.
3882   * @returns { Promise<number> } Returns the number of file bytes read to buffer in promise mode.
3883   * @throws { BusinessError } 13900004 - Interrupted system call
3884   * @throws { BusinessError } 13900005 - I/O error
3885   * @throws { BusinessError } 13900008 - Bad file descriptor
3886   * @throws { BusinessError } 13900010 - Try again
3887   * @throws { BusinessError } 13900013 - Bad address
3888   * @throws { BusinessError } 13900019 - Is a directory
3889   * @throws { BusinessError } 13900020 - Invalid argument
3890   * @throws { BusinessError } 13900034 - Operation would block
3891   * @throws { BusinessError } 13900042 - Unknown error
3892   * @throws { BusinessError } 13900044 - Network is unreachable
3893   * @syscap SystemCapability.FileManagement.File.FileIO
3894   * @since 20
3895   */
3896  read(
3897    buffer: ArrayBuffer,
3898    options?: ReadOptions
3899  ): Promise<number>;
3900
3901  /**
3902   * Read stream.
3903   *
3904   * @param { ArrayBuffer } buffer - buffer.
3905   * @param { AsyncCallback<number> } callback - The callback is used to return the number of file bytes read to buffer.
3906   * @throws { BusinessError } 13900004 - Interrupted system call
3907   * @throws { BusinessError } 13900005 - I/O error
3908   * @throws { BusinessError } 13900008 - Bad file descriptor
3909   * @throws { BusinessError } 13900010 - Try again
3910   * @throws { BusinessError } 13900013 - Bad address
3911   * @throws { BusinessError } 13900019 - Is a directory
3912   * @throws { BusinessError } 13900020 - Invalid argument
3913   * @throws { BusinessError } 13900034 - Operation would block
3914   * @throws { BusinessError } 13900042 - Unknown error
3915   * @syscap SystemCapability.FileManagement.File.FileIO
3916   * @since 20
3917   */
3918  read(buffer: ArrayBuffer, callback: AsyncCallback<number>): void;
3919
3920  /**
3921   * Read stream.
3922   *
3923   * @param { ArrayBuffer } buffer - buffer.
3924   * @param { ReadOptions } [options] - options.
3925   * @param { AsyncCallback<number> } callback - The callback is used to return the number of file bytes read to buffer.
3926   * @throws { BusinessError } 13900004 - Interrupted system call
3927   * @throws { BusinessError } 13900005 - I/O error
3928   * @throws { BusinessError } 13900008 - Bad file descriptor
3929   * @throws { BusinessError } 13900010 - Try again
3930   * @throws { BusinessError } 13900013 - Bad address
3931   * @throws { BusinessError } 13900019 - Is a directory
3932   * @throws { BusinessError } 13900020 - Invalid argument
3933   * @throws { BusinessError } 13900034 - Operation would block
3934   * @throws { BusinessError } 13900042 - Unknown error
3935   * @syscap SystemCapability.FileManagement.File.FileIO
3936   * @since 20
3937   */
3938  read(
3939    buffer: ArrayBuffer,
3940    options: ReadOptions,
3941    callback: AsyncCallback<number>
3942  ): void;
3943
3944  /**
3945   * Read stream with sync interface.
3946   *
3947   * @param { ArrayBuffer } buffer - buffer.
3948   * @param { ReadOptions } [options] - options.
3949   * @returns { number } Returns the number of file bytes read to file.
3950   * @throws { BusinessError } 13900004 - Interrupted system call
3951   * @throws { BusinessError } 13900005 - I/O error
3952   * @throws { BusinessError } 13900008 - Bad file descriptor
3953   * @throws { BusinessError } 13900010 - Try again
3954   * @throws { BusinessError } 13900013 - Bad address
3955   * @throws { BusinessError } 13900019 - Is a directory
3956   * @throws { BusinessError } 13900020 - Invalid argument
3957   * @throws { BusinessError } 13900034 - Operation would block
3958   * @throws { BusinessError } 13900042 - Unknown error
3959   * @throws { BusinessError } 13900044 - Network is unreachable
3960   * @syscap SystemCapability.FileManagement.File.FileIO
3961   * @since 20
3962   */
3963  readSync(
3964    buffer: ArrayBuffer,
3965    options?: ReadOptions
3966  ): number;
3967}
3968
3969/**
3970 * Watcher object
3971 *
3972 * @interface Watcher
3973 * @syscap SystemCapability.FileManagement.File.FileIO
3974 * @since 20
3975 */
3976interface Watcher {
3977  /**
3978   * Start watcher.
3979   *
3980   * @throws { BusinessError } 13900002 - No such file or directory
3981   * @throws { BusinessError } 13900008 - Bad file descriptor
3982   * @throws { BusinessError } 13900011 - Out of memory
3983   * @throws { BusinessError } 13900012 - Permission denied
3984   * @throws { BusinessError } 13900013 - Bad address
3985   * @throws { BusinessError } 13900015 - File exists
3986   * @throws { BusinessError } 13900018 - Not a directory
3987   * @throws { BusinessError } 13900020 - Invalid argument
3988   * @throws { BusinessError } 13900021 - File table overflow
3989   * @throws { BusinessError } 13900022 - Too many open files
3990   * @throws { BusinessError } 13900025 - No space left on device
3991   * @throws { BusinessError } 13900030 - File name too long
3992   * @throws { BusinessError } 13900042 - Unknown error
3993   * @syscap SystemCapability.FileManagement.File.FileIO
3994   * @since 20
3995   */
3996  start(): void;
3997
3998  /**
3999   * Stop watcher.
4000   *
4001   * @throws { BusinessError } 13900002 - No such file or directory
4002   * @throws { BusinessError } 13900008 - Bad file descriptor
4003   * @throws { BusinessError } 13900011 - Out of memory
4004   * @throws { BusinessError } 13900012 - Permission denied
4005   * @throws { BusinessError } 13900013 - Bad address
4006   * @throws { BusinessError } 13900015 - File exists
4007   * @throws { BusinessError } 13900018 - Not a directory
4008   * @throws { BusinessError } 13900020 - Invalid argument
4009   * @throws { BusinessError } 13900021 - File table overflow
4010   * @throws { BusinessError } 13900022 - Too many open files
4011   * @throws { BusinessError } 13900025 - No space left on device
4012   * @throws { BusinessError } 13900030 - File name too long
4013   * @throws { BusinessError } 13900042 - Unknown error
4014   * @syscap SystemCapability.FileManagement.File.FileIO
4015   * @since 20
4016   */
4017  stop(): void;
4018}
4019
4020/**
4021 * Enumeration of different types of whence.
4022 *
4023 * @enum { number } whence type
4024 * @syscap SystemCapability.FileManagement.File.FileIO
4025 * @since 20
4026 */
4027enum WhenceType {
4028  /**
4029   * Starting position of the file offset.
4030   *
4031   * @syscap SystemCapability.FileManagement.File.FileIO
4032   * @since 20
4033   */
4034  SEEK_SET = 0,
4035
4036  /**
4037   * Current position of the file offset.
4038   *
4039   * @syscap SystemCapability.FileManagement.File.FileIO
4040   * @since 20
4041   */
4042  SEEK_CUR = 1,
4043
4044  /**
4045   * Ending position of the file offset.
4046   *
4047   * @syscap SystemCapability.FileManagement.File.FileIO
4048   * @since 20
4049   */
4050  SEEK_END = 2,
4051}
4052
4053/**
4054 * Enumeration of different types of file location.
4055 *
4056 * @enum { number } location type
4057 * @syscap SystemCapability.FileManagement.File.FileIO
4058 * @since 20
4059 */
4060enum LocationType {
4061  /**
4062   * Local file.
4063   *
4064   * @syscap SystemCapability.FileManagement.File.FileIO
4065   * @since 20
4066   */
4067  LOCAL = 1 << 0,
4068
4069  /**
4070   * Cloud file.
4071   *
4072   * @syscap SystemCapability.FileManagement.File.FileIO
4073   * @since 20
4074   */
4075  CLOUD = 1 << 1,
4076}
4077
4078/**
4079 * Enumeration of different types of access mode.
4080 *
4081 * @enum { number } access mode type
4082 * @syscap SystemCapability.FileManagement.File.FileIO
4083 * @since 20
4084 */
4085enum AccessModeType {
4086  /**
4087   * Check if the file exists.
4088   *
4089   * @syscap SystemCapability.FileManagement.File.FileIO
4090   * @since 20
4091   */
4092  EXIST = 0,
4093
4094  /**
4095   * Check if the file has write permission.
4096   *
4097   * @syscap SystemCapability.FileManagement.File.FileIO
4098   * @since 20
4099   */
4100  WRITE = 2,
4101
4102  /**
4103   * Check if the file has read permission.
4104   *
4105   * @syscap SystemCapability.FileManagement.File.FileIO
4106   * @since 20
4107   */
4108  READ = 4,
4109
4110  /**
4111   * Check if the file has read and write permission.
4112   *
4113   * @syscap SystemCapability.FileManagement.File.FileIO
4114   * @since 20
4115   */
4116  READ_WRITE = 6,
4117}
4118
4119/**
4120 * Enumeration of different types of access flag.
4121 *
4122 * @enum { number } access flag type
4123 * @syscap SystemCapability.FileManagement.File.FileIO
4124 * @since 20
4125 */
4126enum AccessFlagType {
4127  /**
4128   * Check if the file is on the local.
4129   *
4130   * @syscap SystemCapability.FileManagement.File.FileIO
4131   * @since 20
4132   */
4133  LOCAL = 0,
4134}
4135
4136/**
4137 * ReaderIterator object
4138 *
4139 * @interface ReaderIterator
4140 * @syscap SystemCapability.FileManagement.File.FileIO
4141 * @since 20
4142 */
4143interface ReaderIterator {
4144  /**
4145   * Get next result from the iterator.
4146   *
4147   * @returns { ReaderIteratorResult } Returns the result of reader iterator.
4148   * @throws { BusinessError } 13900005 - I/O error
4149   * @throws { BusinessError } 13900037 - No data available
4150   * @throws { BusinessError } 13900042 - Unknown error
4151   * @syscap SystemCapability.FileManagement.File.FileIO
4152   * @since 20
4153   */
4154  next(): ReaderIteratorResult;
4155}
4156
4157}
4158
4159/**
4160 * Implements watcher event listening.
4161 *
4162 * @typedef { function } WatchEventListener
4163 * @param { WatchEvent } event - Event type for the callback to invoke.
4164 * @syscap SystemCapability.FileManagement.File.FileIO
4165 * @since 20
4166 */
4167export type WatchEventListener = (event: WatchEvent) => void;
4168
4169/**
4170 * Event Listening.
4171 *
4172 * @interface WatchEvent
4173 * @syscap SystemCapability.FileManagement.File.FileIO
4174 * @since 20
4175 */
4176export interface WatchEvent {
4177  /**
4178   * File name.
4179   *
4180   * @type { string }
4181   * @readonly
4182   * @syscap SystemCapability.FileManagement.File.FileIO
4183   * @since 20
4184   */
4185  readonly fileName: string;
4186
4187  /**
4188   * Event happened.
4189   *
4190   * @type { number }
4191   * @readonly
4192   * @syscap SystemCapability.FileManagement.File.FileIO
4193   * @since 20
4194   */
4195  readonly event: number;
4196
4197  /**
4198   * Associated rename event.
4199   *
4200   * @type { number }
4201   * @readonly
4202   * @syscap SystemCapability.FileManagement.File.FileIO
4203   * @since 20
4204   */
4205  readonly cookie: number;
4206}
4207
4208/**
4209 * Reader Iterator Result
4210 *
4211 * @interface ReaderIteratorResult
4212 * @syscap SystemCapability.FileManagement.File.FileIO
4213 * @since 20
4214 */
4215export interface ReaderIteratorResult {
4216  /**
4217   * Whether reader iterator completes the traversal.
4218   *
4219   * @type { boolean }
4220   * @syscap SystemCapability.FileManagement.File.FileIO
4221   * @since 20
4222   */
4223  done: boolean;
4224
4225  /**
4226   * The value of reader iterator.
4227   *
4228   * @type { string }
4229   * @syscap SystemCapability.FileManagement.File.FileIO
4230   * @since 20
4231   */
4232  value: string;
4233}
4234
4235/**
4236 * File filter type
4237 *
4238 * @interface Filter
4239 * @syscap SystemCapability.FileManagement.File.FileIO
4240 * @since 20
4241 */
4242export interface Filter {
4243
4244  /**
4245   * The suffix of the file.
4246   *
4247   * @type { ?Array<string> }
4248   * @syscap SystemCapability.FileManagement.File.FileIO
4249   * @since 20
4250   */
4251  suffix?: Array<string>;
4252
4253  /**
4254   * The display name of the file.
4255   *
4256   * @type { ?Array<string> }
4257   * @syscap SystemCapability.FileManagement.File.FileIO
4258   * @since 20
4259   */
4260  displayName?: Array<string>;
4261
4262  /**
4263   * The mimetype of the file.
4264   *
4265   * @type { ?Array<string> }
4266   * @syscap SystemCapability.FileManagement.File.FileIO
4267   * @since 20
4268   */
4269  mimeType?: Array<string>;
4270
4271  /**
4272   * The exceeding size of the file.
4273   *
4274   * @type { ?number }
4275   * @syscap SystemCapability.FileManagement.File.FileIO
4276   * @since 20
4277   */
4278  fileSizeOver?: number;
4279
4280  /**
4281   * The last modification time of the file.
4282   *
4283   * @type { ?number }
4284   * @syscap SystemCapability.FileManagement.File.FileIO
4285   * @since 20
4286   */
4287  lastModifiedAfter?: number;
4288
4289  /**
4290   * Whether to exclude media files.
4291   *
4292   * @type { ?boolean }
4293   * @syscap SystemCapability.FileManagement.File.FileIO
4294   * @since 20
4295   */
4296  excludeMedia?: boolean;
4297}
4298
4299/**
4300 * Conflict Files type
4301 *
4302 * @interface ConflictFiles
4303 * @syscap SystemCapability.FileManagement.File.FileIO
4304 * @since 20
4305 */
4306export interface ConflictFiles {
4307
4308  /**
4309   * The path of the source file.
4310   *
4311   * @type { string }
4312   * @syscap SystemCapability.FileManagement.File.FileIO
4313   * @since 20
4314   */
4315  srcFile: string;
4316
4317  /**
4318   * The path of the destination file.
4319   *
4320   * @type { string }
4321   * @syscap SystemCapability.FileManagement.File.FileIO
4322   * @since 20
4323   */
4324  destFile: string;
4325}
4326
4327/**
4328 * Options type
4329 *
4330 * @interface Options
4331 * @syscap SystemCapability.FileManagement.File.FileIO
4332 * @since 20
4333 */
4334export interface Options {
4335  /**
4336   * The encoding style.
4337   *
4338   * @type { ?string }
4339   * @syscap SystemCapability.FileManagement.File.FileIO
4340   * @since 20
4341   */
4342  encoding?: string;
4343}
4344
4345/**
4346 * ReadOptions type
4347 *
4348 * @interface ReadOptions
4349 * @syscap SystemCapability.FileManagement.File.FileIO
4350 * @since 20
4351 */
4352export interface ReadOptions {
4353  /**
4354   * The offset when reading the file.
4355   *
4356   * @type { ?number }
4357   * @syscap SystemCapability.FileManagement.File.FileIO
4358   * @since 20
4359   */
4360  offset?: number;
4361  /**
4362   * The length for reading.
4363   *
4364   * @type { ?number }
4365   * @syscap SystemCapability.FileManagement.File.FileIO
4366   * @since 20
4367   */
4368  length?: number;
4369}
4370
4371/**
4372 * ReadTextOptions type
4373 *
4374 * @extends ReadOptions
4375 * @interface ReadTextOptions
4376 * @syscap SystemCapability.FileManagement.File.FileIO
4377 * @since 20
4378 */
4379export interface ReadTextOptions extends ReadOptions {
4380  /**
4381   * The encoding style when reading text.
4382   *
4383   * @type { ?string }
4384   * @syscap SystemCapability.FileManagement.File.FileIO
4385   * @since 20
4386   */
4387  encoding?: string;
4388}
4389
4390/**
4391 * WriteOptions type
4392 *
4393 * @extends Options
4394 * @interface WriteOptions
4395 * @syscap SystemCapability.FileManagement.File.FileIO
4396 * @since 20
4397 */
4398export interface WriteOptions extends Options {
4399  /**
4400   * The offset when writing the file.
4401   *
4402   * @type { ?number }
4403   * @syscap SystemCapability.FileManagement.File.FileIO
4404   * @since 20
4405   */
4406  offset?: number;
4407  /**
4408   * The length for writing.
4409   *
4410   * @type { ?number }
4411   * @syscap SystemCapability.FileManagement.File.FileIO
4412   * @since 20
4413   */
4414  length?: number;
4415}
4416
4417/**
4418 * ListFileOptions type
4419 *
4420 * @interface ListFileOptions
4421 * @syscap SystemCapability.FileManagement.File.FileIO
4422 * @since 20
4423 */
4424export interface ListFileOptions {
4425  /**
4426   * Whether to recursively list files.
4427   *
4428   * @type { ?boolean }
4429   * @syscap SystemCapability.FileManagement.File.FileIO
4430   * @since 20
4431   */
4432  recursion?: boolean;
4433
4434  /**
4435   * The number of files listed.
4436   *
4437   * @type { ?number }
4438   * @syscap SystemCapability.FileManagement.File.FileIO
4439   * @since 20
4440   */
4441  listNum?: number;
4442
4443  /**
4444   * The filter of listing files.
4445   *
4446   * @type { ?Filter }
4447   * @syscap SystemCapability.FileManagement.File.FileIO
4448   * @since 20
4449   */
4450  filter?: Filter;
4451}
4452
4453/**
4454 * RandomAccessFileOptions type
4455 *
4456 * @interface RandomAccessFileOptions
4457 * @syscap SystemCapability.FileManagement.File.FileIO
4458 * @since 20
4459 */
4460export interface RandomAccessFileOptions {
4461  /**
4462   * The starting position of file offset.
4463   *
4464   * @type { ?number }
4465   * @syscap SystemCapability.FileManagement.File.FileIO
4466   * @since 20
4467   */
4468  start?: number;
4469
4470  /**
4471   * The ending position of file offset.
4472   *
4473   * @type { ?number }
4474   * @syscap SystemCapability.FileManagement.File.FileIO
4475   * @since 20
4476   */
4477  end?: number;
4478}
4479
4480/**
4481 * ReadStreamOptions type
4482 *
4483 * @interface ReadStreamOptions
4484 * @syscap SystemCapability.FileManagement.File.FileIO
4485 * @since 20
4486 */
4487export interface ReadStreamOptions {
4488  /**
4489   * The starting range for reading a file by stream.
4490   *
4491   * @type { ?number }
4492   * @syscap SystemCapability.FileManagement.File.FileIO
4493   * @since 20
4494   */
4495  start?: number;
4496
4497  /**
4498   * The ending range for reading a file by stream.
4499   *
4500   * @type { ?number }
4501   * @syscap SystemCapability.FileManagement.File.FileIO
4502   * @since 20
4503   */
4504  end?: number;
4505}
4506
4507/**
4508 * WriteStreamOptions type
4509 *
4510 * @interface WriteStreamOptions
4511 * @syscap SystemCapability.FileManagement.File.FileIO
4512 * @since 20
4513 */
4514export interface WriteStreamOptions {
4515  /**
4516   * The mode for creating write stream.
4517   *
4518   * @type { ?number }
4519   * @syscap SystemCapability.FileManagement.File.FileIO
4520   * @since 20
4521   */
4522  mode?: number;
4523  /**
4524   * The starting range for writing a file by stream.
4525   *
4526   * @type { ?number }
4527   * @syscap SystemCapability.FileManagement.File.FileIO
4528   * @since 20
4529   */
4530  start?: number;
4531}
4532
4533/**
4534 * Task signal.
4535 * @typedef { fileIo.TaskSignal }
4536 * @syscap SystemCapability.FileManagement.File.FileIO
4537 * @since 20
4538 */
4539type TaskSignal = fileIo.TaskSignal;
4540
4541/**
4542 * Watcher object
4543 * @typedef { fileIo.Watcher }
4544 * @syscap SystemCapability.FileManagement.File.FileIO
4545 * @since 20
4546 */
4547type Watcher = fileIo.Watcher;
4548
4549/**
4550 * Watcher object
4551 * @typedef { fileIo.AtomicFile }
4552 * @syscap SystemCapability.FileManagement.File.FileIO
4553 * @since 20
4554 */
4555type AtomicFile = fileIo.AtomicFile;
4556
4557export default fileIo;
4558export {TaskSignal, Watcher, AtomicFile}
4559