diff --git a/api/@ohos.fileManager.d.ts b/api/@ohos.fileManager.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..443fa646a5ef4a308ed9007cf4f1f68bd7ca77e4 --- /dev/null +++ b/api/@ohos.fileManager.d.ts @@ -0,0 +1,142 @@ + /* + * 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; + +/** + * @devices phone, tablet, tv, wearable + */ +declare namespace filemanager { + export { listFile }; + export { getRoot }; + export { createFile }; + export { FileInfo }; + export { DevInfo }; +} + +/** + * listFile. + * + * @note N/A + * @sysCap SystemCapability.FileManagement.FileManagerService + * @since 8 + * @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 + */ +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}, AsyncCallback): void; + +/** + * getRoot. + * + * @note N/A + * @sysCap SystemCapability.FileManagement.FileManagerService + * @since 8 + * @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 + */ +declare function getRoot(options?: {dev?: DevInfo}): Promise; +declare function getRoot(options?: {dev?: DevInfo}, callback: AsyncCallback): void; + +/** + * createFile. + * + * @note N/A + * @sysCap SystemCapability.FileManagement.FileManagerService + * @since 8 + * @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 + */ +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.FileManagerService + * @since 8 + * @permission N/A + * @devices phone, tablet, tv, wearable + */ +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.FileManagerService + * @since 8 + * @permission N/A + * @devices phone, tablet, tv, wearable + */ + declare interface DevInfo { + /** + * @type {string} + */ + name: string; + }