• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1/*
2 * Copyright (c) 2023 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 * Provides the recycling ability to the file manager.
18 *
19 * @namespace trash
20 * @syscap SystemCapability.FileManagement.UserFileService
21 * @systemapi
22 * @StageModelOnly
23 * @since 10
24 */
25declare namespace trash {
26  /**
27   * FileInfo Object
28   *
29   * @interface FileInfo
30   * @syscap SystemCapability.FileManagement.UserFileService
31   * @systemapi
32   * @StageModelOnly
33   * @since 10
34   */
35  interface FileInfo {
36    /**
37     * Indicates the uri of the file.
38     *
39     * @type { string }
40     * @readonly
41     * @syscap SystemCapability.FileManagement.UserFileService
42     * @systemapi
43     * @StageModelOnly
44     * @since 10
45     */
46    readonly uri: string;
47
48    /**
49     * Indicates the source path of the file.
50     *
51     * @type { string }
52     * @readonly
53     * @syscap SystemCapability.FileManagement.UserFileService
54     * @systemapi
55     * @StageModelOnly
56     * @since 10
57     */
58    readonly srcPath: string;
59
60    /**
61     * Indicates the name of the file.
62     *
63     * @type { string }
64     * @readonly
65     * @syscap SystemCapability.FileManagement.UserFileService
66     * @systemapi
67     * @StageModelOnly
68     * @since 10
69     */
70    readonly fileName: string;
71
72    /**
73     * Indicates the mode of the file.
74     *
75     * @type { number }
76     * @readonly
77     * @syscap SystemCapability.FileManagement.UserFileService
78     * @systemapi
79     * @StageModelOnly
80     * @since 10
81     */
82    readonly mode: number;
83
84    /**
85     * Indicates the size of the file.
86     *
87     * @type { number }
88     * @readonly
89     * @syscap SystemCapability.FileManagement.UserFileService
90     * @systemapi
91     * @StageModelOnly
92     * @since 10
93     */
94    readonly size: number;
95
96    /**
97     * Indicates the mtime of the file.
98     *
99     * @type { number }
100     * @readonly
101     * @syscap SystemCapability.FileManagement.UserFileService
102     * @systemapi
103     * @StageModelOnly
104     * @since 10
105     */
106    readonly mtime: number;
107
108    /**
109     * Indicates the ctime of the file.
110     *
111     * @type { number }
112     * @readonly
113     * @syscap SystemCapability.FileManagement.UserFileService
114     * @systemapi
115     * @StageModelOnly
116     * @since 10
117     */
118    readonly ctime: number;
119  }
120
121  /**
122     * List files in the trash.
123     *
124     * @permission ohos.permission.FILE_ACCESS_MANAGER
125     * @returns { Array<FileInfo> } Returns the next level FileInfo Object.
126     * @throws { BusinessError } 13900002 - No such file or directory
127     * @throws { BusinessError } 13900020 - Invalid argument
128     * @throws { BusinessError } 13900042 - Unknown error
129     * @syscap SystemCapability.FileManagement.UserFileService
130     * @systemapi
131     * @StageModelOnly
132     * @since 10
133     */
134  function listFile(): Array<FileInfo>;
135
136  /**
137   * Recover a file from the trash.
138   *
139   * @permission ohos.permission.FILE_ACCESS_MANAGER
140   * @param { string } uri - The identity of a file.
141   * @throws { BusinessError } 13900002 - No such file or directory
142   * @throws { BusinessError } 13900020 - Invalid argument
143   * @throws { BusinessError } 13900042 - Unknown error
144   * @syscap SystemCapability.FileManagement.UserFileService
145   * @systemapi
146   * @StageModelOnly
147   * @since 10
148   */
149  function recover(uri: string): void;
150
151  /**
152   * Delete a file completely from th trash.
153   *
154   * @permission ohos.permission.FILE_ACCESS_MANAGER
155   * @param { string } uri - The identity of a file.
156   * @throws { BusinessError } 13900002 - No such file or directory
157   * @throws { BusinessError } 13900020 - Invalid argument
158   * @throws { BusinessError } 13900042 - Unknown error
159   * @syscap SystemCapability.FileManagement.UserFileService
160   * @systemapi
161   * @StageModelOnly
162   * @since 10
163   */
164  function completelyDelete(uri: string): void;
165}
166
167export default trash;
168