1 /*
2  * Copyright (c) 2024 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 #ifndef FILE_MANAGEMENT_OH_FILE_URI_H
17 #define FILE_MANAGEMENT_OH_FILE_URI_H
18 
19 /**
20  * @file oh_file_uri.h
21  *
22  * @brief uri verification and conversion
23  * @library libohfileuri.so
24  * @syscap SystemCapability.FileManagement.AppFileService
25  * @since 12
26  */
27 
28 #include "error_code.h"
29 #include "stdbool.h"
30 #ifdef __cplusplus
31 extern "C" {
32 #endif
33 
34 /**
35  * @brief Get uri From path.
36  *
37  * @param path Input a pointer to the path string.
38  * @param length The length of the input path.
39  * @param result Output a pointer to a uri string. Please use free() to clear the resource.
40  * @return Returns the status code of the execution.
41  * @syscap SystemCapability.FileManagement.AppFileService
42  * @since 12
43  */
44 FileManagement_ErrCode OH_FileUri_GetUriFromPath(const char *path, unsigned int length, char **result);
45 
46 /**
47  * @brief Get path From uri.
48  *
49  * @param uri Input a pointer to the uri string.
50  * @param length The length of the input uri.
51  * @param result Output a pointer to a path string. Please use free() to clear the resource.
52  * @return Returns the status code of the execution.
53  * @syscap SystemCapability.FileManagement.AppFileService
54  * @since 12
55  */
56 FileManagement_ErrCode OH_FileUri_GetPathFromUri(const char *uri, unsigned int length, char **result);
57 
58 /**
59  * @brief Gets the uri of the path or directory where the uri is located.
60  *
61  * @param uri Input a pointer to the uri string.
62  * @param length  The length of the input uri.
63  * @param result Output a pointer to a uri string. Please use free() to clear the resource.
64  * @return Returns the status code of the execution.
65  * @syscap SystemCapability.FileManagement.AppFileService
66  * @since 12
67  */
68 FileManagement_ErrCode OH_FileUri_GetFullDirectoryUri(const char *uri, unsigned int length, char **result);
69 
70 /**
71  * @brief Check that the incoming uri is valid
72  *
73  * @param uri Input a pointer to the uri string.
74  * @param length The length of the input uri.
75  * @return Returns true: Valid incoming uri, false: Invalid incoming uri.
76  * @syscap SystemCapability.FileManagement.AppFileService
77  * @since 12
78  */
79 bool OH_FileUri_IsValidUri(const char *uri, unsigned int length);
80 
81 /**
82 * @brief Gets the fileName From uri.
83 *
84 * @param uri Input a pointer to the uri string.
85 * @param length  The length of the input uri.
86 * @param result Output a pointer to a FileName string or FolderName string. Please use free() to clear the resource.
87 * @return Returns the status code of the execution.
88 * @syscap SystemCapability.FileManagement.AppFileService
89 * @since 13
90  */
91 FileManagement_ErrCode OH_FileUri_GetFileName(const char *uri, unsigned int length, char **result);
92 #ifdef __cplusplus
93 };
94 #endif
95 #endif // FILE_MANAGEMENT_OH_FILE_URI_H
96