From d01c8fcecfec92378d04610b2a17048fedac7cad Mon Sep 17 00:00:00 2001 From: wangjianqiang Date: Fri, 15 Jul 2022 09:30:20 +0800 Subject: [PATCH] add fileAccess.d.ts Signed-off-by: wangjianqiang --- api/@ohos.data.fileAccess.d.ts | 180 +++++++++++++++++++++++++++++++++ api/@ohos.fileManager.d.ts | 142 -------------------------- 2 files changed, 180 insertions(+), 142 deletions(-) create mode 100644 api/@ohos.data.fileAccess.d.ts delete mode 100644 api/@ohos.fileManager.d.ts diff --git a/api/@ohos.data.fileAccess.d.ts b/api/@ohos.data.fileAccess.d.ts new file mode 100644 index 0000000000..8b059f19d8 --- /dev/null +++ b/api/@ohos.data.fileAccess.d.ts @@ -0,0 +1,180 @@ +/* +* Copyright (C) 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. +*/ + +import { AsyncCallback, Callback } from "./basic"; +import { Want } from './ability/want'; +import Context from './application/Context'; + +declare namespace fileaccess { + /** + * Obtains the fileAccessHelper. + * @since 9 + * @syscap SystemCapability.FileManagement.UserFileService + * @param context Indicates the application context. + * @param want Represents the connected data provider. + * @return Returns the fileAccessHelper. + * @StageModelOnly + * @systemapi + */ + function createFileAccessHelper(context: Context, want: Want, callback: AsyncCallback): void; + function createFileAccessHelper(context: Context, want: Want): Promise; + + /** + * Obtains the HAP Information for Registering FileAccessExtensionAbility in the System. + * @since 9 + * @syscap SystemCapability.FileManagement.UserFileService + * @return Returns the want information of configuring FileAccess in the package. + * @StageModelOnly + * @systemapi + */ + function getFileAccessAbilityInfo(): Promise>; + function getFileAccessAbilityInfo(callback: AsyncCallback>): void; + + /** + * File Object + * @since 9 + * @syscap SystemCapability.FileManagement.UserFileService + * @StageModelOnly + * @systemapi + */ + interface FileIterator { + uri: string; + fileName: string; + mode: string; + size: number; + mtime: number; + mimetype: string; + [Symbol.iterator](): IterableIterator; + listFile(): FileIterator; + } + + /** + * Root Object + * @since 9 + * @syscap SystemCapability.FileManagement.UserFileService + * @StageModelOnly + * @systemapi + */ + interface Root { + deviceId: string; + uri: string; + displayName: string; + flags: number; + listFile(): FileIterator; + } + + /** + * flags is the parameter in openfile + * @since 9 + * @syscap SystemCapability.FileManagement.UserFileService + * @StageModelOnly + * @systemapi + */ + enum FLAGS { + /** file is openFile only_read */ + READ = 0o0, + /** file is openFile only_write */ + WRITE = 0o1, + /** file is openFile write_read */ + WRITE_READ = 0o2 + } + + /** + * FileAccessHelper + * + * @since 9 + * @syscap SystemCapability.FileManagement.UserFileService + * @StageModelOnly + * @systemapi + * @permission ohos.permission.FILE_ACCESS_MANAGER + */ + interface FileAccessHelper { + /** + * Open a file in a specified path. + * + * @since 9 + * @param uri Indicates the path of the file to open. + * @param flags Indicate options of opening a file. The default value is read-only. + * @param callback Indicate the callback when openfile success. + * @return Returns the file descriptor. + */ + openFile(uri: string, flags: FLAGS) : Promise; + openFile(uri: string, flags: FLAGS, callback: AsyncCallback) : void; + + /** + * Create a file in a specified path. + * + * @since 9 + * @param uri Represents a specific parent directory. + * @param displayName Indicates the new file name. + * @return Returns the new file's URI. + */ + createFile(uri: string, displayName: string) : Promise; + createFile(uri: string, displayName: string, callback: AsyncCallback) : void; + + /** + * Create a Directory in a specified path. + * + * @since 9 + * @param uri parentUri Represents a specific parent directory. + * @param displayName displayName Indicates the new file name. + * @return Returns the new directory's URI. + */ + mkdir(uri: string, displayName: string) : Promise; + mkdir(uri: string, displayName: string, callback: AsyncCallback) : void; + + /** + * Delete a file or delete a directory recursively. + * + * @since 9 + * @param uri Indicates the file or directory to be deleted. + * @return Returns Exections Success or Failure. + * @StageModelOnly + */ + delete(uri: string) : Promise; + delete(uri: string, callback: AsyncCallback) : void; + + /** + * Move a file or move a directory recursively. + * + * @since 9 + * @param sourceUri Indicates the file or directory to be moved. + * @param destUri Represents the destonation folder. + * @return URI of the generated new file or directory. + */ + move(sourceUri: string, destUri: string) : Promise; + move(sourceUri: string, destUri: string, callback: AsyncCallback) : void; + + /** + * Rename the selected file or directory. + * + * @since 9 + * @param uri Indicates the selected file or directory. + * @param displayName Indicates the new directory or file name. + * @return URI of the generated new file or directory. + */ + rename(uri: string, displayName: string) : Promise; + rename(uri: string, displayName: string, callback: AsyncCallback) : void; + + /** + * Get root objects from all data providers. + * + * @since 9 + * @return Array of root objects. + */ + getRoots(): Promise>; + getRoots(callback:AsyncCallback>) : void; + } +} \ No newline at end of file diff --git a/api/@ohos.fileManager.d.ts b/api/@ohos.fileManager.d.ts deleted file mode 100644 index e9676f7e97..0000000000 --- a/api/@ohos.fileManager.d.ts +++ /dev/null @@ -1,142 +0,0 @@ - /* - * Copyright (c) 2021 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 './basic' - -export default filemanager; - -declare namespace filemanager { - export { listFile }; - export { getRoot }; - export { createFile }; - export { FileInfo }; - export { DevInfo }; -} - -/** - * listFile. - * - * @note N/A - * @syscap SystemCapability.FileManagement.UserFileService - * @since 9 - * @permission N/A - * @function listFile - * @param {string} path - path. - * @param {string} type - type. - * @param {Object} options - options - * @param {DevInfo} [options.dev = {name: "local"}] - dev name. - * @param {number} [options.offset = 0] - offset. - * @param {number} [options.count = 0] - count. - * @param {AsyncCallback} [callback] - callback. - * @returns {void | Promise} no callback return Promise otherwise return void - * @throws {TypedError} Parameter check failed - * @systemapi - */ -declare function listFile(path: string, type: string, options?: {dev?: DevInfo, offset?: number, count?: number}): Promise; -declare function listFile(path: string, type: string, options?: {dev?: DevInfo, offset?: number, count?: number}, callback: AsyncCallback): void; - -/** - * getRoot. - * - * @note N/A - * @syscap SystemCapability.FileManagement.UserFileService - * @since 9 - * @permission N/A - * @function getRoot - * @param {Object} options - options - * @param {DevInfo} [options.dev = {name: "local"}] - dev name. - * @param {AsyncCallback} [callback] - callback. - * @returns {void | Promise} no callback return Promise otherwise return void - * @throws {TypedError} Parameter check failed - * @systemapi - */ -declare function getRoot(options?: {dev?: DevInfo}): Promise; -declare function getRoot(options?: {dev?: DevInfo}, callback: AsyncCallback): void; - -/** - * createFile. - * - * @note N/A - * @syscap SystemCapability.FileManagement.UserFileService - * @since 9 - * @permission N/A - * @function createFile - * @param {string} path - album uri. - * @param {string} filename- file name. - * @param {Object} options - options - * @param {DevInfo} [options.dev = {name: "local"}] - dev name. - * @param {AsyncCallback} [callback] - callback. - * @returns {void | Promise} no callback return Promise otherwise return void - * @throws {TypedError} Parameter check failed - * @systemapi - */ -declare function createFile(path: string, filename: string, options?: {dev?: DevInfo}): Promise; -declare function createFile(path: string, filename: string, options?: {dev?: DevInfo}, callback: AsyncCallback): void; - -/** - * FileInfo - * @note N/A - * @syscap SystemCapability.FileManagement.UserFileService - * @since 9 - * @permission N/A - * @systemapi - */ -declare interface FileInfo { - /** - * @type {string} - * @readonly - */ - name: string; - /** - * @type {string} - * @readonly - */ - path: string; - /** - * @type {string} - * @readonly - */ - type: string; - /** - * @type {string} - * @readonly - */ - size: number; - /** - * @type {string} - * @readonly - */ - addedTime: number; - /** - * @type {string} - * @readonly - */ - modifiedTime: number; -} - -/** - * DevInfo - * @note N/A - * @syscap SystemCapability.FileManagement.UserFileService - * @since 9 - * @permission N/A - * @systemapi - */ - declare interface DevInfo { - /** - * @type {string} - */ - name: string; - } -- Gitee