1/*
2 * Copyright (C) 2022-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 * @file
18 * @kit CoreFileKit
19 */
20
21import type { AsyncCallback } from './@ohos.base';
22
23/**
24 * Provides filesystem statistics APIs
25 *
26 * @namespace statfs
27 * @syscap SystemCapability.FileManagement.File.FileIO
28 * @since 9
29 */
30declare namespace statfs {
31  /**
32   * Get the number of free bytes on the specified path.
33   *
34   * @param { string } path - path
35   * @returns { Promise<number> } return Promise
36   * @throws { BusinessError } 13900002 - No such file or directory
37   * @throws { BusinessError } 13900004 - Interrupted system call
38   * @throws { BusinessError } 13900005 - I/O error
39   * @throws { BusinessError } 13900008 - Bad file descriptor
40   * @throws { BusinessError } 13900011 - Out of memory
41   * @throws { BusinessError } 13900012 - Permission denied
42   * @throws { BusinessError } 13900013 - Bad address
43   * @throws { BusinessError } 13900018 - Not a directory
44   * @throws { BusinessError } 13900030 - File name too long
45   * @throws { BusinessError } 13900031 - Function not implemented
46   * @throws { BusinessError } 13900033 - Too many symbolic links encountered
47   * @throws { BusinessError } 13900038 - Value too large for defined data type
48   * @throws { BusinessError } 13900042 - Unknown error
49   * @syscap SystemCapability.FileManagement.File.FileIO
50   * @since 9
51   */
52  function getFreeSize(path: string): Promise<number>;
53
54  /**
55   * Get the number of free bytes on the specified path.
56   *
57   * @param { string } path - path
58   * @param { AsyncCallback<number> } [callback] - callback
59   * @throws { BusinessError } 13900002 - No such file or directory
60   * @throws { BusinessError } 13900004 - Interrupted system call
61   * @throws { BusinessError } 13900005 - I/O error
62   * @throws { BusinessError } 13900008 - Bad file descriptor
63   * @throws { BusinessError } 13900011 - Out of memory
64   * @throws { BusinessError } 13900012 - Permission denied
65   * @throws { BusinessError } 13900013 - Bad address
66   * @throws { BusinessError } 13900018 - Not a directory
67   * @throws { BusinessError } 13900030 - File name too long
68   * @throws { BusinessError } 13900031 - Function not implemented
69   * @throws { BusinessError } 13900033 - Too many symbolic links encountered
70   * @throws { BusinessError } 13900038 - Value too large for defined data type
71   * @throws { BusinessError } 13900042 - Unknown error
72   * @syscap SystemCapability.FileManagement.File.FileIO
73   * @since 9
74   */
75  function getFreeSize(path: string, callback: AsyncCallback<number>): void;
76
77  /**
78   * Get the number of free bytes on the specified path with sync interface.
79   *
80   * @param { string } path - path
81   * @returns { number } return the number of free bytes on the specified path
82   * @throws { BusinessError } 13900002 - No such file or directory
83   * @throws { BusinessError } 13900004 - Interrupted system call
84   * @throws { BusinessError } 13900005 - I/O error
85   * @throws { BusinessError } 13900008 - Bad file descriptor
86   * @throws { BusinessError } 13900011 - Out of memory
87   * @throws { BusinessError } 13900012 - Permission denied
88   * @throws { BusinessError } 13900013 - Bad address
89   * @throws { BusinessError } 13900018 - Not a directory
90   * @throws { BusinessError } 13900030 - File name too long
91   * @throws { BusinessError } 13900031 - Function not implemented
92   * @throws { BusinessError } 13900033 - Too many symbolic links encountered
93   * @throws { BusinessError } 13900038 - Value too large for defined data type
94   * @throws { BusinessError } 13900042 - Unknown error
95   * @syscap SystemCapability.FileManagement.File.FileIO
96   * @since 10
97   */
98  function getFreeSizeSync(path: string): number;
99
100  /**
101   * Get the number of total bytes on the specified path.
102   *
103   * @param { string } path - path
104   * @returns { Promise<number> } return Promise
105   * @throws { BusinessError } 13900002 - No such file or directory
106   * @throws { BusinessError } 13900004 - Interrupted system call
107   * @throws { BusinessError } 13900005 - I/O error
108   * @throws { BusinessError } 13900008 - Bad file descriptor
109   * @throws { BusinessError } 13900011 - Out of memory
110   * @throws { BusinessError } 13900012 - Permission denied
111   * @throws { BusinessError } 13900013 - Bad address
112   * @throws { BusinessError } 13900018 - Not a directory
113   * @throws { BusinessError } 13900030 - File name too long
114   * @throws { BusinessError } 13900031 - Function not implemented
115   * @throws { BusinessError } 13900033 - Too many symbolic links encountered
116   * @throws { BusinessError } 13900038 - Value too large for defined data type
117   * @throws { BusinessError } 13900042 - Unknown error
118   * @syscap SystemCapability.FileManagement.File.FileIO
119   * @since 9
120   */
121  function getTotalSize(path: string): Promise<number>;
122
123  /**
124   * Get the number of total bytes on the specified path.
125   *
126   * @param { string } path - path
127   * @param { AsyncCallback<number> } [callback] - callback
128   * @throws { BusinessError } 13900002 - No such file or directory
129   * @throws { BusinessError } 13900004 - Interrupted system call
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 } 13900030 - File name too long
137   * @throws { BusinessError } 13900031 - Function not implemented
138   * @throws { BusinessError } 13900033 - Too many symbolic links encountered
139   * @throws { BusinessError } 13900038 - Value too large for defined data type
140   * @throws { BusinessError } 13900042 - Unknown error
141   * @syscap SystemCapability.FileManagement.File.FileIO
142   * @since 9
143   */
144  function getTotalSize(path: string, callback: AsyncCallback<number>): void;
145
146  /**
147   * Get the number of total bytes on the specified path with sync interface.
148   *
149   * @param { string } path - path
150   * @returns { number } return the number of total bytes
151   * @throws { BusinessError } 13900002 - No such file or directory
152   * @throws { BusinessError } 13900004 - Interrupted system call
153   * @throws { BusinessError } 13900005 - I/O error
154   * @throws { BusinessError } 13900008 - Bad file descriptor
155   * @throws { BusinessError } 13900011 - Out of memory
156   * @throws { BusinessError } 13900012 - Permission denied
157   * @throws { BusinessError } 13900013 - Bad address
158   * @throws { BusinessError } 13900018 - Not a directory
159   * @throws { BusinessError } 13900030 - File name too long
160   * @throws { BusinessError } 13900031 - Function not implemented
161   * @throws { BusinessError } 13900033 - Too many symbolic links encountered
162   * @throws { BusinessError } 13900038 - Value too large for defined data type
163   * @throws { BusinessError } 13900042 - Unknown error
164   * @syscap SystemCapability.FileManagement.File.FileIO
165   * @since 10
166   */
167  function getTotalSizeSync(path: string): number;
168}
169
170export default statfs;
171