Rectify the the specification for file_api's JSDoc-files

Signed-off-by: fengjunqing <fengjunqing@huawei.com>
This commit is contained in:
fengjunqing 2023-05-30 13:53:09 +08:00
parent 1cd8c6f364
commit 90f6e3ed1f
9 changed files with 1735 additions and 786 deletions

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2021 Huawei Device Co., Ltd.
* Copyright (c) 2021-2023 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
@ -12,15 +12,18 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { AsyncCallback } from './@ohos.base'
import { AsyncCallback } from './@ohos.base';
export default document;
/**
* document
*
* @namespace document
* @syscap SystemCapability.FileManagement.UserFileService
* @since 6
* @permission N/A
* @deprecated since 9
*/
declare namespace document {
export { choose };
@ -30,33 +33,60 @@ declare namespace document {
/**
* choose.
*
* @param { string[] } types - type.
* @returns { Promise<string> } return Promise
* @throws { TypedError } Parameter check failed
* @syscap SystemCapability.FileManagement.UserFileService
* @since 6
* @permission N/A
* @function choose
* @param {string} type - type.
* @param {AsyncCallback<void>} [callback] - callback.
* @returns {void | Promise<void>} no callback return Promise otherwise return void
* @throws {TypedError} Parameter check failed
* @deprecated since 9
*/
declare function choose(types?: string[]): Promise<string>;
/**
* choose.
*
* @param { AsyncCallback<string> } [callback] - callback.
* @throws { TypedError } Parameter check failed
* @syscap SystemCapability.FileManagement.UserFileService
* @since 6
* @deprecated since 9
*/
declare function choose(callback: AsyncCallback<string>): void;
/**
* choose.
*
* @param { string[] } types - type.
* @param { AsyncCallback<string> } [callback] - callback.
* @throws { TypedError } Parameter check failed
* @syscap SystemCapability.FileManagement.UserFileService
* @since 6
* @deprecated since 9
*/
declare function choose(types: string[], callback: AsyncCallback<string>): void;
/**
* show.
*
* @param { string } uri - uri.
* @param { string } type - type.
* @returns { Promise<void> } return Promise
* @throws { TypedError } Parameter check failed
* @syscap SystemCapability.FileManagement.UserFileService
* @since 6
* @permission N/A
* @function show
* @param {string} uri - uri.
* @param {string} type - type.
* @param {AsyncCallback<void>} [callback] - callback.
* @returns {void | Promise<void>} no callback return Promise otherwise return void
* @throws {TypedError} Parameter check failed
* @deprecated since 9
*/
declare function show(uri: string, type: string): Promise<void>;
/**
* show.
*
* @param { string } uri - uri.
* @param { string } type - type.
* @param { AsyncCallback<void> } [callback] - callback.
* @throws { TypedError } Parameter check failed
* @syscap SystemCapability.FileManagement.UserFileService
* @since 6
* @deprecated since 9
*/
declare function show(uri: string, type: string, callback: AsyncCallback<void>): void;

View File

@ -13,7 +13,7 @@
* limitations under the License.
*/
import type { AsyncCallback } from "./@ohos.base";
import type { AsyncCallback } from './@ohos.base';
/**
* Provides Environment APIs.

255
api/@ohos.file.fs.d.ts vendored
View File

@ -12,6 +12,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { AsyncCallback } from './@ohos.base';
export default fileIo;
@ -101,16 +102,166 @@ declare namespace fileIo {
* @since 10
*/
namespace OpenMode {
const READ_ONLY = 0o0; // Read only Permission
const WRITE_ONLY = 0o1; // Write only Permission
const READ_WRITE = 0o2; // Write and Read Permission
const CREATE = 0o100; // If not exist, create file
const TRUNC = 0o1000; // File truncate len 0
const APPEND = 0o2000; // File append write
const NONBLOCK = 0o4000; // File open in nonblocking mode
const DIR = 0o200000; // File is Dir
const NOFOLLOW = 0o400000; // File is not symbolic link
const SYNC = 0o4010000; // SYNC IO
/**
* Read only Permission.
*
* @constant
* @syscap SystemCapability.FileManagement.File.FileIO
* @since 9
*/
/**
* Read only Permission.
*
* @constant
* @syscap SystemCapability.FileManagement.File.FileIO
* @crossplatform
* @since 10
*/
const READ_ONLY = 0o0;
/**
* Write only Permission.
*
* @constant
* @syscap SystemCapability.FileManagement.File.FileIO
* @since 9
*/
/**
* Write only Permission.
*
* @constant
* @syscap SystemCapability.FileManagement.File.FileIO
* @crossplatform
* @since 10
*/
const WRITE_ONLY = 0o1;
/**
* Write and Read Permission.
*
* @constant
* @syscap SystemCapability.FileManagement.File.FileIO
* @since 9
*/
/**
* Write and Read Permission.
*
* @constant
* @syscap SystemCapability.FileManagement.File.FileIO
* @crossplatform
* @since 10
*/
const READ_WRITE = 0o2;
/**
* If not exist, create file.
*
* @constant
* @syscap SystemCapability.FileManagement.File.FileIO
* @since 9
*/
/**
* If not exist, create file.
*
* @constant
* @syscap SystemCapability.FileManagement.File.FileIO
* @crossplatform
* @since 10
*/
const CREATE = 0o100;
/**
* File truncate len 0.
*
* @constant
* @syscap SystemCapability.FileManagement.File.FileIO
* @since 9
*/
/**
* File truncate len 0.
*
* @constant
* @syscap SystemCapability.FileManagement.File.FileIO
* @crossplatform
* @since 10
*/
const TRUNC = 0o1000;
/**
* File append write.
*
* @constant
* @syscap SystemCapability.FileManagement.File.FileIO
* @since 9
*/
/**
* File append write.
*
* @constant
* @syscap SystemCapability.FileManagement.File.FileIO
* @crossplatform
* @since 10
*/
const APPEND = 0o2000;
/**
* File open in nonblocking mode.
*
* @constant
* @syscap SystemCapability.FileManagement.File.FileIO
* @since 9
*/
/**
* File open in nonblocking mode.
*
* @constant
* @syscap SystemCapability.FileManagement.File.FileIO
* @crossplatform
* @since 10
*/
const NONBLOCK = 0o4000;
/**
* File is Dir.
*
* @constant
* @syscap SystemCapability.FileManagement.File.FileIO
* @since 9
*/
/**
* File is Dir.
*
* @constant
* @syscap SystemCapability.FileManagement.File.FileIO
* @crossplatform
* @since 10
*/
const DIR = 0o200000;
/**
* File is not symbolic link.
*
* @constant
* @syscap SystemCapability.FileManagement.File.FileIO
* @since 9
*/
/**
* File is not symbolic link.
*
* @constant
* @syscap SystemCapability.FileManagement.File.FileIO
* @crossplatform
* @since 10
*/
const NOFOLLOW = 0o400000;
/**
* SYNC IO.
*
* @constant
* @syscap SystemCapability.FileManagement.File.FileIO
* @since 9
*/
/**
* SYNC IO.
*
* @constant
* @syscap SystemCapability.FileManagement.File.FileIO
* @crossplatform
* @since 10
*/
const SYNC = 0o4010000;
}
}
@ -925,7 +1076,7 @@ declare function fsyncSync(fd: number): void;
* List file.
*
* @param { string } path - path.
* @param { Object } [options] - options.
* @param { object } [options] - options.
* @returns { Promise<string[]> } return Promise
* @throws { BusinessError } 13900002 - No such file or directory
* @throws { BusinessError } 13900008 - Bad file descriptor
@ -963,7 +1114,7 @@ declare function listFile(path: string, callback: AsyncCallback<string[]>): void
* List file.
*
* @param { string } path - path.
* @param { Object } [options] - options.
* @param { object } [options] - options.
* @param { AsyncCallback<string[]> } callback - callback.
* @throws { BusinessError } 13900002 - No such file or directory
* @throws { BusinessError } 13900008 - Bad file descriptor
@ -987,7 +1138,7 @@ declare function listFile(
* List file with sync interface.
*
* @param { string } path - path.
* @param { Object } [options] - options.
* @param { object } [options] - options.
* @returns { string[] } array of file name
* @throws { BusinessError } 13900002 - No such file or directory
* @throws { BusinessError } 13900008 - Bad file descriptor
@ -1361,10 +1512,10 @@ declare function mkdtempSync(prefix: string): string;
/**
* Move directory.
*
* @param {string} src - source file path.
* @param {string} dest - destination file path.
* @param {number} [mode = 0] - move mode when duplicate file name exists.
* @returns {Promise<void>} return Promise
* @param { string } src - source file path.
* @param { string } dest - destination file path.
* @param { number } [mode = 0] - move mode when duplicate file name exists.
* @returns { Promise<void> } return Promise
* @throws { BusinessError } 13900001 - Operation not permitted
* @throws { BusinessError } 13900002 - No such file or directory
* @throws { BusinessError } 13900008 - Bad file descriptor
@ -1392,9 +1543,9 @@ declare function moveDir(src: string, dest: string, mode?: number): Promise<void
/**
* Move directory.
*
* @param {string} src - source file path.
* @param {string} dest - destination file path.
* @param {AsyncCallback<void>} callback - callback.
* @param { string } src - source file path.
* @param { string } dest - destination file path.
* @param { AsyncCallback<void> } callback - callback.
* @throws { BusinessError } 13900001 - Operation not permitted
* @throws { BusinessError } 13900002 - No such file or directory
* @throws { BusinessError } 13900008 - Bad file descriptor
@ -1422,10 +1573,10 @@ declare function moveDir(src: string, dest: string, callback: AsyncCallback<void
/**
* Move directory.
*
* @param {string} src - source file path.
* @param {string} dest - destination file path.
* @param {number} mode - move mode when duplicate file name exists.
* @param {AsyncCallback<void>} callback - callback.
* @param { string } src - source file path.
* @param { string } dest - destination file path.
* @param { number } mode - move mode when duplicate file name exists.
* @param { AsyncCallback<void> } callback - callback.
* @throws { BusinessError } 13900001 - Operation not permitted
* @throws { BusinessError } 13900002 - No such file or directory
* @throws { BusinessError } 13900008 - Bad file descriptor
@ -1867,7 +2018,7 @@ declare function openSync(path: string, mode?: number): File;
*
* @param { number } fd - file descriptor.
* @param { ArrayBuffer } buffer - buffer.
* @param { Object } [options] - options.
* @param { object } [options] - options.
* @returns { Promise<number> } return Promise
* @throws { BusinessError } 13900004 - Interrupted system call
* @throws { BusinessError } 13900005 - I/O error
@ -1886,7 +2037,7 @@ declare function openSync(path: string, mode?: number): File;
*
* @param { number } fd - file descriptor.
* @param { ArrayBuffer } buffer - buffer.
* @param { Object } [options] - options.
* @param { object } [options] - options.
* @returns { Promise<number> } return Promise
* @throws { BusinessError } 13900004 - Interrupted system call
* @throws { BusinessError } 13900005 - I/O error
@ -1954,7 +2105,7 @@ declare function read(fd: number, buffer: ArrayBuffer, callback: AsyncCallback<n
*
* @param { number } fd - file descriptor.
* @param { ArrayBuffer } buffer - buffer.
* @param { Object } [options] - options.
* @param { object } [options] - options.
* @param { AsyncCallback<number> } [callback] - callback.
* @throws { BusinessError } 13900004 - Interrupted system call
* @throws { BusinessError } 13900005 - I/O error
@ -1973,7 +2124,7 @@ declare function read(fd: number, buffer: ArrayBuffer, callback: AsyncCallback<n
*
* @param { number } fd - file descriptor.
* @param { ArrayBuffer } buffer - buffer.
* @param { Object } [options] - options.
* @param { object } [options] - options.
* @param { AsyncCallback<number> } [callback] - callback.
* @throws { BusinessError } 13900004 - Interrupted system call
* @throws { BusinessError } 13900005 - I/O error
@ -2003,7 +2154,7 @@ declare function read(
*
* @param { number } fd - file descriptor.
* @param { ArrayBuffer } buffer - buffer.
* @param { Object } [options] - options.
* @param { object } [options] - options.
* @returns { number } number of bytesRead
* @throws { BusinessError } 13900004 - Interrupted system call
* @throws { BusinessError } 13900005 - I/O error
@ -2022,7 +2173,7 @@ declare function read(
*
* @param { number } fd - file descriptor.
* @param { ArrayBuffer } buffer - buffer.
* @param { Object } [options] - options.
* @param { object } [options] - options.
* @returns { number } number of bytesRead
* @throws { BusinessError } 13900004 - Interrupted system call
* @throws { BusinessError } 13900005 - I/O error
@ -2050,7 +2201,7 @@ declare function readSync(
* Read text.
*
* @param { string } filePath - file path.
* @param { Object } [options] - options.
* @param { object } [options] - options.
* @returns { Promise<string> } return Promise
* @throws { BusinessError } 13900001 - Operation not permitted
* @throws { BusinessError } 13900004 - Interrupted system call
@ -2104,7 +2255,7 @@ declare function readText(filePath: string, callback: AsyncCallback<string>): vo
* Read text.
*
* @param { string } filePath - file path.
* @param { Object } [options] - options.
* @param { object } [options] - options.
* @param { AsyncCallback<string> } [callback] - callback.
* @throws { BusinessError } 13900001 - Operation not permitted
* @throws { BusinessError } 13900004 - Interrupted system call
@ -2136,7 +2287,7 @@ declare function readText(
* Read text with sync interface.
*
* @param { string } filePath - file path.
* @param { Object } [options] - options.
* @param { object } [options] - options.
* @returns { string } readout result
* @throws { BusinessError } 13900001 - Operation not permitted
* @throws { BusinessError } 13900004 - Interrupted system call
@ -3032,7 +3183,7 @@ declare function unlinkSync(path: string): void;
*
* @param { number } fd - file descriptor.
* @param { ArrayBuffer | string } buffer - buffer.
* @param { Object } [options] - options.
* @param { object } [options] - options.
* @returns { Promise<number> } return Promise
* @throws { BusinessError } 13900001 - Operation not permitted
* @throws { BusinessError } 13900004 - Interrupted system call
@ -3054,7 +3205,7 @@ declare function unlinkSync(path: string): void;
*
* @param { number } fd - file descriptor.
* @param { ArrayBuffer | string } buffer - buffer.
* @param { Object } [options] - options.
* @param { object } [options] - options.
* @returns { Promise<number> } return Promise
* @throws { BusinessError } 13900001 - Operation not permitted
* @throws { BusinessError } 13900004 - Interrupted system call
@ -3132,7 +3283,7 @@ declare function write(fd: number, buffer: ArrayBuffer | string, callback: Async
*
* @param { number } fd - file descriptor.
* @param { ArrayBuffer | string } buffer - buffer.
* @param { Object } [options] - options.
* @param { object } [options] - options.
* @param { AsyncCallback<number> } [callback] - callback.
* @throws { BusinessError } 13900001 - Operation not permitted
* @throws { BusinessError } 13900004 - Interrupted system call
@ -3154,7 +3305,7 @@ declare function write(fd: number, buffer: ArrayBuffer | string, callback: Async
*
* @param { number } fd - file descriptor.
* @param { ArrayBuffer | string } buffer - buffer.
* @param { Object } [options] - options.
* @param { object } [options] - options.
* @param { AsyncCallback<number> } [callback] - callback.
* @throws { BusinessError } 13900001 - Operation not permitted
* @throws { BusinessError } 13900004 - Interrupted system call
@ -3188,7 +3339,7 @@ declare function write(
*
* @param { number } fd - file descriptor.
* @param { ArrayBuffer | string } buffer - buffer.
* @param { Object } [options] - options.
* @param { object } [options] - options.
* @returns { number } on success number of bytesRead
* @throws { BusinessError } 13900001 - Operation not permitted
* @throws { BusinessError } 13900004 - Interrupted system call
@ -3210,7 +3361,7 @@ declare function write(
*
* @param { number } fd - file descriptor.
* @param { ArrayBuffer | string } buffer - buffer.
* @param { Object } [options] - options.
* @param { object } [options] - options.
* @returns { number } on success number of bytesRead
* @throws { BusinessError } 13900001 - Operation not permitted
* @throws { BusinessError } 13900004 - Interrupted system call
@ -3766,7 +3917,7 @@ declare interface Stream {
* Write stream.
*
* @param { ArrayBuffer | string } buffer - buffer.
* @param { Object } [options] - options.
* @param { object } [options] - options.
* @returns { Promise<number> } return Promise
* @throws { BusinessError } 13900001 - Operation not permitted
* @throws { BusinessError } 13900004 - Interrupted system call
@ -3818,7 +3969,7 @@ declare interface Stream {
* Write stream.
*
* @param { ArrayBuffer | string } buffer - buffer.
* @param { Object } [options] - options.
* @param { object } [options] - options.
* @param { AsyncCallback<number> } [callback] - callback.
* @throws { BusinessError } 13900001 - Operation not permitted
* @throws { BusinessError } 13900004 - Interrupted system call
@ -3848,7 +3999,7 @@ declare interface Stream {
* Write stream with sync interface.
*
* @param { ArrayBuffer | string } buffer - buffer.
* @param { Object } [options] - options.
* @param { object } [options] - options.
* @returns { number } on success number of bytes written
* @throws { BusinessError } 13900001 - Operation not permitted
* @throws { BusinessError } 13900004 - Interrupted system call
@ -3877,7 +4028,7 @@ declare interface Stream {
* Read stream.
*
* @param { ArrayBuffer } buffer - buffer.
* @param { Object } [options] - options.
* @param { object } [options] - options.
* @returns { Promise<number> } return Promise
* @throws { BusinessError } 13900004 - Interrupted system call
* @throws { BusinessError } 13900005 - I/O error
@ -3922,7 +4073,7 @@ declare interface Stream {
* Read stream.
*
* @param { ArrayBuffer } buffer - buffer.
* @param { Object } [options] - options.
* @param { object } [options] - options.
* @param { AsyncCallback<number> } [callback] - callback.
* @throws { BusinessError } 13900004 - Interrupted system call
* @throws { BusinessError } 13900005 - I/O error
@ -3949,7 +4100,7 @@ declare interface Stream {
* Read stream with sync interface.
*
* @param { ArrayBuffer } buffer - buffer.
* @param { Object } [options] - options.
* @param { object } [options] - options.
* @returns { number } number of bytesRead
* @throws { BusinessError } 13900004 - Interrupted system call
* @throws { BusinessError } 13900005 - I/O error
@ -4097,42 +4248,42 @@ export interface Watcher {
*/
export type Filter = {
/**
* @type { Array<string> }
* @type { ?Array<string> }
* @syscap SystemCapability.FileManagement.File.FileIO
* @systemapi
* @since 9
*/
suffix?: Array<string>;
/**
* @type { Array<string> }
* @type { ?Array<string> }
* @syscap SystemCapability.FileManagement.File.FileIO
* @systemapi
* @since 9
*/
displayName?: Array<string>;
/**
* @type { Array<string> }
* @type { ?Array<string> }
* @syscap SystemCapability.FileManagement.File.FileIO
* @systemapi
* @since 9
*/
mimeType?: Array<string>;
/**
* @type { number }
* @type { ?number }
* @syscap SystemCapability.FileManagement.File.FileIO
* @systemapi
* @since 9
*/
fileSizeOver?: number;
/**
* @type { number }
* @type { ?number }
* @syscap SystemCapability.FileManagement.File.FileIO
* @systemapi
* @since 9
*/
lastModifiedAfter?: number;
/**
* @type { boolean }
* @type { ?boolean }
* @syscap SystemCapability.FileManagement.File.FileIO
* @systemapi
* @since 9
@ -4160,4 +4311,4 @@ export type ConflictFiles = {
* @since 10
*/
destFile: string;
}
};

View File

@ -12,7 +12,8 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import type { AsyncCallback } from './@ohos.base'
import type { AsyncCallback } from './@ohos.base';
/**
* Hash

View File

@ -13,7 +13,7 @@
* limitations under the License.
*/
import type { AsyncCallback } from "./@ohos.base";
import type { AsyncCallback } from './@ohos.base';
/**
* Provides securityLabel APIs

View File

@ -13,7 +13,7 @@
* limitations under the License.
*/
import type { AsyncCallback } from "./@ohos.base";
import type { AsyncCallback } from './@ohos.base';
/**
* Provides filesystem statistics APIs

1654
api/@ohos.fileio.d.ts vendored

File diff suppressed because it is too large Load Diff

61
api/@ohos.statfs.d.ts vendored
View File

@ -1,44 +1,75 @@
/*
* Copyright (C) 2021-2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
* Copyright (C) 2021-2023 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { AsyncCallback } from "./@ohos.base";
import { AsyncCallback } from './@ohos.base';
/**
* Provides filesystem statistics APIs
*
* @since 8
* @namespace Statfs
* @syscap SystemCapability.FileManagement.File.FileIO
* @since 8
* @deprecated since 9
* @useinstead ohos.file.statvfs.statfs
*/
declare namespace Statfs {
/**
* Get the number of free bytes on the specified path.
*
* @param { string } path
* @param { AsyncCallback<number> } callback - callback
* @syscap SystemCapability.FileManagement.File.FileIO
* @since 8
* @deprecated since 9
* @useinstead ohos.file.statvfs.getFreeSize
*/
function getFreeBytes(path: string, callback: AsyncCallback<number>): void;
/**
* Get the number of free bytes on the specified path.
*
* @param { string } path
* @returns { Promise<number> } return Promise
* @syscap SystemCapability.FileManagement.File.FileIO
* @since 8
* @deprecated since 9
* @useinstead ohos.file.statvfs.getFreeSize
*/
function getFreeBytes(path: string): Promise<number>;
/**
* Get the total number of bytes of the specified path.
*
* @param { string } path
* @param { AsyncCallback<number> } callback - callback
* @syscap SystemCapability.FileManagement.File.FileIO
* @since 8
* @deprecated since 9
* @useinstead ohos.file.statvfs.getTotalSize
*/
function getTotalBytes(path: string, callback: AsyncCallback<number>): void;
/**
* Get the total number of bytes of the specified path.
*
* @param { string } path
* @returns { Promise<number> } return Promise
* @syscap SystemCapability.FileManagement.File.FileIO
* @since 8
* @deprecated since 9
* @useinstead ohos.file.statvfs.getTotalSize
*/
function getTotalBytes(path: string): Promise<number>;
}

258
api/@system.file.d.ts vendored
View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2020 Huawei Device Co., Ltd.
* Copyright (c) 2020-2023 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
@ -13,27 +13,39 @@
* limitations under the License.
*/
/**
* @interface FileResponse
* @syscap SystemCapability.FileManagement.File.FileIO
* @since 3
* @deprecated since 10
*/
export interface FileResponse {
/**
* File URI.
*
* @syscap SystemCapability.FileManagement.File.FileIO
* @since 3
* @deprecated since 10
*/
uri: string;
/**
* File size, in bytes.
* If type is dir, the length value is fixed to 0.
*
* @syscap SystemCapability.FileManagement.File.FileIO
* @since 3
* @deprecated since 10
*/
length: number;
/**
* Timestamp when the file is stored, which is the number of milliseconds elapsed since 1970/01/01 00:00:00.
* For lite wearables, the value is fixed to 0, because this parameter is restricted by the underlying file system.
*
* @syscap SystemCapability.FileManagement.File.FileIO
* @since 3
* @deprecated since 10
*/
lastModifiedTime: number;
@ -41,23 +53,29 @@ export interface FileResponse {
* File type. The values are as follows:
* dir: directory
* file: file
*
* @syscap SystemCapability.FileManagement.File.FileIO
* @since 3
* @deprecated since 10
*/
type: "dir" | "file";
type: 'dir' | 'file';
/**
* File list. When the recursive value is true and the type is dir, the file information under the subdirectory will be returned.
* Otherwise, no value will be returned.
*
* @syscap SystemCapability.FileManagement.File.FileIO
* @since 3
* @deprecated since 10
*/
subFiles?: Array<FileResponse>;
}
/**
* @interface FileMoveOption
* @syscap SystemCapability.FileManagement.File.FileIO
* @since 3
* @deprecated since 10
*/
export interface FileMoveOption {
/**
@ -65,8 +83,10 @@ export interface FileMoveOption {
* Restricted by the underlying file system of lite wearables, the value must meet the following requirements:
* 1. The URI cannot contain special characters such as \/"*+,:;<=>?[]|\x7F.
* 2. The maximum number of characters allowed is 128.
*
* @syscap SystemCapability.FileManagement.File.FileIO
* @since 3
* @deprecated since 10
*/
srcUri: string;
@ -75,49 +95,62 @@ export interface FileMoveOption {
* Restricted by the underlying file system of lite wearables, the value must meet the following requirements:
* 1. The URI cannot contain special characters such as \/"*+,:;<=>?[]|\x7F.
* 2. The maximum number of characters allowed is 128.
*
* @syscap SystemCapability.FileManagement.File.FileIO
* @since 3
* @deprecated since 10
*/
dstUri: string;
/**
* Called when the source file is moved to the specified location successfully.
* This function returns the URI of the file moved to the target location.
*
* @syscap SystemCapability.FileManagement.File.FileIO
* @since 3
* @deprecated since 10
*/
success?: (uri: string) => void;
/**
* Called when moving fails.
*
* @syscap SystemCapability.FileManagement.File.FileIO
* @since 3
* @deprecated since 10
*/
fail?: (data: string, code: number) => void;
/**
* Called when the execution is completed.
*
* @syscap SystemCapability.FileManagement.File.FileIO
* @since 3
* @deprecated since 10
*/
complete?: () => void;
}
/**
* @interface FileListResponse
* @syscap SystemCapability.FileManagement.File.FileIO
* @since 3
* @deprecated since 10
*/
export interface FileListResponse {
/**
* @syscap SystemCapability.FileManagement.File.FileIO
* @since 3
* @deprecated since 10
*/
fileList: Array<FileResponse>;
}
/**
* @interface FileListOption
* @syscap SystemCapability.FileManagement.File.FileIO
* @since 3
* @deprecated since 10
*/
export interface FileListOption {
/**
@ -125,41 +158,57 @@ export interface FileListOption {
* Restricted by the underlying file system of lite wearables, the value must meet the following requirements:
* 1. The URI cannot contain special characters such as \/"*+,:;<=>?[]|\x7F.
* 2. The maximum number of characters allowed is 128.
*
* @syscap SystemCapability.FileManagement.File.FileIO
* @since 3
* @deprecated since 10
*/
uri: string;
/**
* Called when the list is obtained successfully.
*
* @syscap SystemCapability.FileManagement.File.FileIO
* @since 3
* @deprecated since 10
*/
success?: (data: FileListResponse) => void;
/**
* Called when the list fails to be obtained.
*
* @syscap SystemCapability.FileManagement.File.FileIO
* @since 3
* @deprecated since 10
*/
fail?: (data: string, code: number) => void;
/**
* Called when the execution is completed.
*
* @syscap SystemCapability.FileManagement.File.FileIO
* @since 3
* @deprecated since 10
*/
complete?: () => void;
}
/**
* @interface FileCopyOption
* @syscap SystemCapability.FileManagement.File.FileIO
* @since 3
* @deprecated since 10
*/
export interface FileCopyOption {
/**
* URI of the file to copy.
* Restricted by the underlying file system of lite wearables, the value must meet the following requirements:
* 1. The URI cannot contain special characters such as \/"*+,:;<=>?[]|\x7F.
* 2. The maximum number of characters allowed is 128.
*
* @syscap SystemCapability.FileManagement.File.FileIO
* @since 3
* @deprecated since 10
*/
srcUri: string;
@ -168,111 +217,151 @@ export interface FileCopyOption {
* Restricted by the underlying file system of lite wearables, the value must meet the following requirements:
* 1. The URI cannot contain special characters such as \/"*+,:;<=>?[]|\x7F.
* 2. The maximum number of characters allowed is 128.
*
* @syscap SystemCapability.FileManagement.File.FileIO
* @since 3
* @deprecated since 10
*/
dstUri: string;
/**
* Called when the copy file is saved successful.
* This function returns the URI of the file saved to the target location.
*
* @syscap SystemCapability.FileManagement.File.FileIO
* @since 3
* @deprecated since 10
*/
success?: (uri: string) => void;
/**
* Called when the copy or save operation fails.
*
* @syscap SystemCapability.FileManagement.File.FileIO
* @since 3
* @deprecated since 10
*/
fail?: (data: string, code: number) => void;
/**
* Called when the execution is completed.
*
* @syscap SystemCapability.FileManagement.File.FileIO
* @since 3
* @deprecated since 10
*/
complete?: () => void;
}
/**
* @interface FileGetOption
* @syscap SystemCapability.FileManagement.File.FileIO
* @since 3
* @deprecated since 10
*/
export interface FileGetOption {
/**
* File URI, which cannot be an application resource path.
* Restricted by the underlying file system of lite wearables, the value must meet the following requirements:
* 1. The URI cannot contain special characters such as \/"*+,:;<=>?[]|\x7F.
* 2. The maximum number of characters allowed is 128.
*
* @syscap SystemCapability.FileManagement.File.FileIO
* @since 3
* @deprecated since 10
*/
uri: string;
/**
* Whether to recursively obtain the file list under a subdirectory.
* The default value is false.
*
* @syscap SystemCapability.FileManagement.File.FileIO
* @since 3
* @deprecated since 10
*/
recursive?: boolean;
/**
* Called when file information is obtained successfully.
*
* @syscap SystemCapability.FileManagement.File.FileIO
* @since 3
* @deprecated since 10
*/
success?: (file: FileResponse) => void;
/**
* Called when file information fails to be obtained.
*
* @syscap SystemCapability.FileManagement.File.FileIO
* @since 3
* @deprecated since 10
*/
fail?: (data: string, code: number) => void;
/**
* Called when the execution is completed.
*
* @syscap SystemCapability.FileManagement.File.FileIO
* @since 3
* @deprecated since 10
*/
complete?: () => void;
}
/**
* @interface FileDeleteOption
* @syscap SystemCapability.FileManagement.File.FileIO
* @since 3
* @deprecated since 10
*/
export interface FileDeleteOption {
/**
* URI of the file to be deleted, which cannot be an application resource path.
* Restricted by the underlying file system of lite wearables, the value must meet the following requirements:
* 1. The URI cannot contain special characters such as \/"*+,:;<=>?[]|\x7F.
* 2. The maximum number of characters allowed is 128.
*
* @syscap SystemCapability.FileManagement.File.FileIO
* @since 3
* @deprecated since 10
*/
uri: string;
/**
* Called when local files are deleted successfully.
*
* @syscap SystemCapability.FileManagement.File.FileIO
* @since 3
* @deprecated since 10
*/
success?: () => void;
/**
* Called when the deletion fails.
*
* @syscap SystemCapability.FileManagement.File.FileIO
* @since 3
* @deprecated since 10
*/
fail?: (data: string, code: number) => void;
/**
* Called when the execution is completed.
*
* @syscap SystemCapability.FileManagement.File.FileIO
* @since 3
* @deprecated since 10
*/
complete?: () => void;
}
/**
* @interface FileWriteTextOption
* @syscap SystemCapability.FileManagement.File.FileIO
* @since 3
* @deprecated since 10
*/
export interface FileWriteTextOption {
/**
@ -280,126 +369,165 @@ export interface FileWriteTextOption {
* Restricted by the underlying file system of lite wearables, the value must meet the following requirements:
* 1. The URI cannot contain special characters such as \/"*+,:;<=>?[]|\x7F.
* 2. The maximum number of characters allowed is 128.
*
* @syscap SystemCapability.FileManagement.File.FileIO
* @since 3
* @deprecated since 10
*/
uri: string;
/**
* Character string to write into the local file.
*
* @syscap SystemCapability.FileManagement.File.FileIO
* @since 3
* @deprecated since 10
*/
text: string;
/**
* Encoding format. The default format is UTF-8.
*
* @syscap SystemCapability.FileManagement.File.FileIO
* @since 3
* @deprecated since 10
*/
encoding?: string;
/**
* Whether to enable the append mode. The default value is false.
*
* @syscap SystemCapability.FileManagement.File.FileIO
* @since 3
* @deprecated since 10
*/
append?: boolean;
/**
* Called when texts are written into a file successfully.
*
* @syscap SystemCapability.FileManagement.File.FileIO
* @since 3
* @deprecated since 10
*/
success?: () => void;
/**
* Called when texts fail to be written into a file.
*
* @syscap SystemCapability.FileManagement.File.FileIO
* @since 3
* @deprecated since 10
*/
fail?: (data: string, code: number) => void;
/**
* Called when the execution is completed.
*
* @syscap SystemCapability.FileManagement.File.FileIO
* @since 3
* @deprecated since 10
*/
complete?: () => void;
}
/**
* @interface FileReadTextResponse
* @syscap SystemCapability.FileManagement.File.FileIO
* @since 3
* @deprecated since 10
*/
export interface FileReadTextResponse {
/**
* @syscap SystemCapability.FileManagement.File.FileIO
* @since 3
* @deprecated since 10
*/
text: string;
}
/**
* @interface FileReadTextOption
* @syscap SystemCapability.FileManagement.File.FileIO
* @since 3
* @deprecated since 10
*/
export interface FileReadTextOption {
/**
* URI of a local file.
* Restricted by the underlying file system of lite wearables, the value must meet the following requirements:
* 1. The URI cannot contain special characters such as \/"*+,:;<=>?[]|\x7F.
* 2. The maximum number of characters allowed is 128.
*
* @syscap SystemCapability.FileManagement.File.FileIO
* @since 3
* @deprecated since 10
*/
uri: string;
/**
* Encoding format. The default format is UTF-8.
* Currently, only UTF-8 is supported.
*
* @syscap SystemCapability.FileManagement.File.FileIO
* @since 3
* @deprecated since 10
*/
encoding?: string;
/**
* Position where the reading starts.
* The default value is the start position of the file.
*
* @syscap SystemCapability.FileManagement.File.FileIO
* @since 3
* @deprecated since 10
*/
position?: number;
/**
* Position where the reading starts.
* The default value is the start position of the file.
*
* @syscap SystemCapability.FileManagement.File.FileIO
* @since 3
* @deprecated since 10
*/
length?: number;
/**
* Called when texts are read successfully.
*
* @syscap SystemCapability.FileManagement.File.FileIO
* @since 3
* @deprecated since 10
*/
success?: (data: FileReadTextResponse) => void;
/**
* Called when texts fail to be read.
*
* @syscap SystemCapability.FileManagement.File.FileIO
* @since 3
* @deprecated since 10
*/
fail?: (data: string, code: number) => void;
/**
* Called when the execution is completed.
*
* @syscap SystemCapability.FileManagement.File.FileIO
* @since 3
* @deprecated since 10
*/
complete?: () => void;
}
/**
* @interface FileWriteArrayBufferOption
* @syscap SystemCapability.FileManagement.File.FileIO
* @since 3
* @deprecated since 10
*/
export interface FileWriteArrayBufferOption {
/**
@ -407,70 +535,89 @@ export interface FileWriteArrayBufferOption {
* Restricted by the underlying file system of lite wearables, the value must meet the following requirements:
* 1. The URI cannot contain special characters such as \/"*+,:;<=>?[]|\x7F.
* 2. The maximum number of characters allowed is 128.
*
* @syscap SystemCapability.FileManagement.File.FileIO
* @since 3
* @deprecated since 10
*/
uri: string;
/**
* Buffer from which the data is derived.
*
* @syscap SystemCapability.FileManagement.File.FileIO
* @since 3
* @deprecated since 10
*/
buffer: Uint8Array;
/**
* Offset to the position where the writing starts. The default value is 0.
*
* @syscap SystemCapability.FileManagement.File.FileIO
* @since 3
* @deprecated since 10
*/
position?: number;
/**
* Whether to enable the append mode.
* The default value is false. If the value is true, the position parameter will become invalid.
*
* @syscap SystemCapability.FileManagement.File.FileIO
* @since 3
* @deprecated since 10
*/
append?: boolean;
/**
* Called when data from a buffer is written into a file successfully.
*
* @syscap SystemCapability.FileManagement.File.FileIO
* @since 3
* @deprecated since 10
*/
success?: () => void;
/**
* Called when data from a buffer fails to be written into a file.
*
* @syscap SystemCapability.FileManagement.File.FileIO
* @since 3
* @deprecated since 10
*/
fail?: (data: string, code: number) => void;
/**
* Called when the execution is completed.
*
* @syscap SystemCapability.FileManagement.File.FileIO
* @since 3
* @deprecated since 10
*/
complete?: () => void;
}
/**
* @interface FileReadArrayBufferResponse
* @syscap SystemCapability.FileManagement.File.FileIO
* @since 3
* @deprecated since 10
*/
export interface FileReadArrayBufferResponse {
/**
* @syscap SystemCapability.FileManagement.File.FileIO
* @since 3
* @deprecated since 10
*/
buffer: Uint8Array;
}
/**
* @interface FileReadArrayBufferOption
* @syscap SystemCapability.FileManagement.File.FileIO
* @since 3
* @deprecated since 10
*/
export interface FileReadArrayBufferOption {
/**
@ -478,52 +625,66 @@ export interface FileReadArrayBufferOption {
* Restricted by the underlying file system of lite wearables, the value must meet the following requirements:
* 1. The URI cannot contain special characters such as \/"*+,:;<=>?[]|\x7F.
* 2. The maximum number of characters allowed is 128.
*
* @syscap SystemCapability.FileManagement.File.FileIO
* @since 3
* @deprecated since 10
*/
uri: string;
/**
* Position where the reading starts.
* The default value is the start position of the file.
*
* @syscap SystemCapability.FileManagement.File.FileIO
* @since 3
* @deprecated since 10
*/
position?: number;
/**
* Length of the content to read.
* If this parameter is not set, all content of the file will be read.
*
* @syscap SystemCapability.FileManagement.File.FileIO
* @since 3
* @deprecated since 10
*/
length?: number;
/**
* Called when the buffer data is read successfully.
*
* @syscap SystemCapability.FileManagement.File.FileIO
* @since 3
* @deprecated since 10
*/
success?: (data: FileReadArrayBufferResponse) => void;
/**
* Called when the buffer data fails to be read.
*
* @syscap SystemCapability.FileManagement.File.FileIO
* @since 3
* @deprecated since 10
*/
fail?: (data: string, code: number) => void;
/**
* Called when the execution is completed.
*
* @syscap SystemCapability.FileManagement.File.FileIO
* @since 3
* @deprecated since 10
*/
complete?: () => void;
}
/**
* @interface FileAccessOption
* @syscap SystemCapability.FileManagement.File.FileIO
* @since 3
* @deprecated since 10
*/
export interface FileAccessOption {
/**
@ -531,36 +692,46 @@ export interface FileAccessOption {
* Restricted by the underlying file system of lite wearables, the value must meet the following requirements:
* 1. The URI cannot contain special characters such as \/"*+,:;<=>?[]|\x7F.
* 2. The maximum number of characters allowed is 128.
*
* @syscap SystemCapability.FileManagement.File.FileIO
* @since 3
* @deprecated since 10
*/
uri: string;
/**
* Called when the check result is obtained successfully.
*
* @syscap SystemCapability.FileManagement.File.FileIO
* @since 3
* @deprecated since 10
*/
success?: () => void;
/**
* Called when the check fails.
*
* @syscap SystemCapability.FileManagement.File.FileIO
* @since 3
* @deprecated since 10
*/
fail?: (data: string, code: number) => void;
/**
* Called when the execution is completed.
*
* @syscap SystemCapability.FileManagement.File.FileIO
* @since 3
* @deprecated since 10
*/
complete?: () => void;
}
/**
* @interface FileMkdirOption
* @syscap SystemCapability.FileManagement.File.FileIO
* @since 3
* @deprecated since 10
*/
export interface FileMkdirOption {
/**
@ -569,44 +740,56 @@ export interface FileMkdirOption {
* 1. The URI cannot contain special characters such as \/"*+,:;<=>?[]|\x7F.
* 2. The maximum number of characters allowed is 128.
* 3. A maximum of five recursions are allowed for creating the directory.
*
* @syscap SystemCapability.FileManagement.File.FileIO
* @since 3
* @deprecated since 10
*/
uri: string;
/**
* Whether to create the directory after creating its upper-level directory recursively.
* The default value is false.
*
* @syscap SystemCapability.FileManagement.File.FileIO
* @since 3
* @deprecated since 10
*/
recursive?: boolean;
/**
* Called when the directory is created successfully.
*
* @syscap SystemCapability.FileManagement.File.FileIO
* @since 3
* @deprecated since 10
*/
success?: () => void;
/**
* Called when the creation fails.
*
* @syscap SystemCapability.FileManagement.File.FileIO
* @since 3
* @deprecated since 10
*/
fail?: (data: string, code: number) => void;
/**
* Called when the execution is completed.
*
* @syscap SystemCapability.FileManagement.File.FileIO
* @since 3
* @deprecated since 10
*/
complete?: () => void;
}
/**
* @interface FileRmdirOption
* @syscap SystemCapability.FileManagement.File.FileIO
* @since 3
* @deprecated since 10
*/
export interface FileRmdirOption {
/**
@ -614,37 +797,47 @@ export interface FileRmdirOption {
* Restricted by the underlying file system of lite wearables, the value must meet the following requirements:
* 1. The URI cannot contain special characters such as \/"*+,:;<=>?[]|\x7F.
* 2. The maximum number of characters allowed is 128.
*
* @syscap SystemCapability.FileManagement.File.FileIO
* @since 3
* @deprecated since 10
*/
uri: string;
/**
* Whether to delete files and subdirectories recursively.
* The default value is false.
*
* @syscap SystemCapability.FileManagement.File.FileIO
* @since 3
* @deprecated since 10
*/
recursive?: boolean;
/**
* Called when the directory is deleted successfully.
*
* @syscap SystemCapability.FileManagement.File.FileIO
* @since 3
* @deprecated since 10
*/
success?: () => void;
/**
* Called when the deletion fails.
*
* @syscap SystemCapability.FileManagement.File.FileIO
* @since 3
* @deprecated since 10
*/
fail?: (data: string, code: number) => void;
/**
* Called when the execution is completed.
*
* @syscap SystemCapability.FileManagement.File.FileIO
* @since 3
* @deprecated since 10
*/
complete?: () => void;
}
@ -652,101 +845,138 @@ export interface FileRmdirOption {
/**
* @syscap SystemCapability.FileManagement.File.FileIO
* @since 3
* @deprecated since 10
*/
export default class File {
/**
* Moves the source file to a specified location.
*
* @param { FileMoveOption } options - Options.
* @syscap SystemCapability.FileManagement.File.FileIO
* @since 3
* @param options Options.
* @deprecated since 10
* @useinstead ohos.file.fs.moveFile
*/
static move(options: FileMoveOption): void;
/**
* Copies a source file and save the copy to a specified location.
*
* @param { FileCopyOption } options - Options.
* @syscap SystemCapability.FileManagement.File.FileIO
* @since 3
* @param options Options.
* @deprecated since 10
* @useinstead ohos.file.fs.copyFile
*/
static copy(options: FileCopyOption): void;
/**
* Obtains the list of files in a specified directory.
*
* @param { FileListOption } options - Options.
* @syscap SystemCapability.FileManagement.File.FileIO
* @since 3
* @param options Options.
* @deprecated since 10
* @useinstead ohos.file.fs.listFile
*/
static list(options: FileListOption): void;
/**
* Obtains information about a local file.
*
* @param { FileGetOption } options - Options.
* @syscap SystemCapability.FileManagement.File.FileIO
* @since 3
* @param options Options.
* @deprecated since 10
* @useinstead ohos.file.fs.stat
*/
static get(options: FileGetOption): void;
/**
* Deletes local files.
*
* @param { FileDeleteOption } options - Options.
* @syscap SystemCapability.FileManagement.File.FileIO
* @since 3
* @param options Options.
* @deprecated since 10
* @useinstead ohos.file.fs.unlink
*/
static delete(options: FileDeleteOption): void;
/**
* Writes texts into a file.
*
* @param { FileWriteTextOption } options - Options.
* @syscap SystemCapability.FileManagement.File.FileIO
* @since 3
* @param options Options.
* @deprecated since 10
* @useinstead ohos.file.fs.write
*/
static writeText(options: FileWriteTextOption): void;
/**
* Reads texts from a file.
*
* @param { FileReadTextOption } options - Options.
* @syscap SystemCapability.FileManagement.File.FileIO
* @since 3
* @param options Options.
* @deprecated since 10
* @useinstead ohos.file.fs.readText
*/
static readText(options: FileReadTextOption): void;
/**
* Writes data from a buffer into a file.
*
* @param { FileWriteArrayBufferOption } options - Options.
* @syscap SystemCapability.FileManagement.File.FileIO
* @since 3
* @param options Options.
* @deprecated since 10
* @useinstead ohos.file.fs.write
*/
static writeArrayBuffer(options: FileWriteArrayBufferOption): void;
/**
* Reads buffer data from a file.
*
* @param { FileReadArrayBufferOption } options - Options.
* @syscap SystemCapability.FileManagement.File.FileIO
* @since 3
* @param options Options.
* @deprecated since 10
* @useinstead ohos.file.fs.read
*/
static readArrayBuffer(options: FileReadArrayBufferOption): void;
/**
* Checks whether a file or directory exists.
*
* @param { FileAccessOption } options - Options.
* @syscap SystemCapability.FileManagement.File.FileIO
* @since 3
* @param options Options.
* @deprecated since 10
* @useinstead ohos.file.fs.access
*/
static access(options: FileAccessOption): void;
/**
* Creates a directory.
*
* @param { FileMkdirOption } options - Options.
* @syscap SystemCapability.FileManagement.File.FileIO
* @since 3
* @param options Options.
* @deprecated since 10
* @useinstead ohos.file.fs.mkdir
*/
static mkdir(options: FileMkdirOption): void;
/**
* Deletes a directory.
*
* @param { FileRmdirOption } options - Options.
* @syscap SystemCapability.FileManagement.File.FileIO
* @since 3
* @param options Options.
* @deprecated since 10
* @useinstead ohos.file.fs.rmdir
*/
static rmdir(options: FileRmdirOption): void;
}