1e41f4b71Sopenharmony_ci# Fileuri
2e41f4b71Sopenharmony_ci
3e41f4b71Sopenharmony_ci
4e41f4b71Sopenharmony_ci## Overview
5e41f4b71Sopenharmony_ci
6e41f4b71Sopenharmony_ciProvides APIs for operating a file Uniform Resource Identifier (URI), including performing URI-path conversion, obtaining a URI, and verifying a URI.
7e41f4b71Sopenharmony_ci
8e41f4b71Sopenharmony_ci**System capability**: SystemCapability.FileManagement.AppFileService
9e41f4b71Sopenharmony_ci
10e41f4b71Sopenharmony_ci**Since**: 12
11e41f4b71Sopenharmony_ci
12e41f4b71Sopenharmony_ci
13e41f4b71Sopenharmony_ci## Summary
14e41f4b71Sopenharmony_ci
15e41f4b71Sopenharmony_ci
16e41f4b71Sopenharmony_ci### Files
17e41f4b71Sopenharmony_ci
18e41f4b71Sopenharmony_ci| Name| Description| 
19e41f4b71Sopenharmony_ci| -------- | -------- |
20e41f4b71Sopenharmony_ci| [oh_file_uri.h](oh__file__uri_8h.md) | Provides APIs for URI operations, including performing URI-path conversion, obtaining a URI, and verifying a URI.| 
21e41f4b71Sopenharmony_ci
22e41f4b71Sopenharmony_ci
23e41f4b71Sopenharmony_ci### Functions
24e41f4b71Sopenharmony_ci
25e41f4b71Sopenharmony_ci| Name| Description| 
26e41f4b71Sopenharmony_ci| -------- | -------- |
27e41f4b71Sopenharmony_ci| [FileManagement_ErrCode](_file_i_o.md#filemanagement_errcode) [OH_FileUri_GetUriFromPath](#oh_fileuri_geturifrompath) (const char \*path, unsigned int length, char \*\*result) | Obtains the URI from a path.| 
28e41f4b71Sopenharmony_ci| [FileManagement_ErrCode](_file_i_o.md#filemanagement_errcode) [OH_FileUri_GetPathFromUri](#oh_fileuri_getpathfromuri) (const char \*uri, unsigned int length, char \*\*result) | Obtains the path from a URI.| 
29e41f4b71Sopenharmony_ci| [FileManagement_ErrCode](_file_i_o.md#filemanagement_errcode) [OH_FileUri_GetFullDirectoryUri](#oh_fileuri_getfulldirectoryuri) (const char \*uri, unsigned int length, char \*\*result) | Obtains the URI of the directory, in which a URI is located. If the specified URI points to a file, the URI of the parent directory is returned. If the specified URI points to a folder, the URI of the folder is returned.| 
30e41f4b71Sopenharmony_ci| bool [OH_FileUri_IsValidUri](#oh_fileuri_isvaliduri) (const char \*uri, unsigned int length) | Checks whether a URI is valid.| 
31e41f4b71Sopenharmony_ci
32e41f4b71Sopenharmony_ci
33e41f4b71Sopenharmony_ci## Function Description
34e41f4b71Sopenharmony_ci
35e41f4b71Sopenharmony_ci
36e41f4b71Sopenharmony_ci### OH_FileUri_GetFullDirectoryUri()
37e41f4b71Sopenharmony_ci
38e41f4b71Sopenharmony_ci```
39e41f4b71Sopenharmony_ciFileManagement_ErrCode OH_FileUri_GetFullDirectoryUri (const char * uri, unsigned int length, char ** result )
40e41f4b71Sopenharmony_ci```
41e41f4b71Sopenharmony_ci
42e41f4b71Sopenharmony_ci**Description**
43e41f4b71Sopenharmony_ci
44e41f4b71Sopenharmony_ciObtains the URI of the directory, in which a URI is located. If the specified URI points to a file, the URI of the parent directory is returned. If the specified URI points to a folder, the URI of the folder is returned.
45e41f4b71Sopenharmony_ci
46e41f4b71Sopenharmony_ci**System capability**: SystemCapability.FileManagement.AppFileService
47e41f4b71Sopenharmony_ci
48e41f4b71Sopenharmony_ci**Since**: 12
49e41f4b71Sopenharmony_ci
50e41f4b71Sopenharmony_ci**Parameters**
51e41f4b71Sopenharmony_ci
52e41f4b71Sopenharmony_ci| Name| Description| 
53e41f4b71Sopenharmony_ci| -------- | -------- |
54e41f4b71Sopenharmony_ci| uri | Pointer to the target URI.| 
55e41f4b71Sopenharmony_ci| length | Length of the URI, in bytes.| 
56e41f4b71Sopenharmony_ci| result | Double pointer to the URI obtained. You also need to use **free()** of the standard library to release the memory allocated.| 
57e41f4b71Sopenharmony_ci
58e41f4b71Sopenharmony_ci**Returns**
59e41f4b71Sopenharmony_ci
60e41f4b71Sopenharmony_ciReturns [FileManagement_ErrCode](_file_i_o.md#filemanagement_errcode).
61e41f4b71Sopenharmony_ci
62e41f4b71Sopenharmony_ci
63e41f4b71Sopenharmony_ci### OH_FileUri_GetPathFromUri()
64e41f4b71Sopenharmony_ci
65e41f4b71Sopenharmony_ci```
66e41f4b71Sopenharmony_ciFileManagement_ErrCode OH_FileUri_GetPathFromUri (const char * uri, unsigned int length, char ** result )
67e41f4b71Sopenharmony_ci```
68e41f4b71Sopenharmony_ci
69e41f4b71Sopenharmony_ci**Description**
70e41f4b71Sopenharmony_ci
71e41f4b71Sopenharmony_ciObtains the path from a URI.
72e41f4b71Sopenharmony_ci
73e41f4b71Sopenharmony_ci**System capability**: SystemCapability.FileManagement.AppFileService
74e41f4b71Sopenharmony_ci
75e41f4b71Sopenharmony_ci**Since**: 12
76e41f4b71Sopenharmony_ci
77e41f4b71Sopenharmony_ci**Parameters**
78e41f4b71Sopenharmony_ci
79e41f4b71Sopenharmony_ci| Name| Description| 
80e41f4b71Sopenharmony_ci| -------- | -------- |
81e41f4b71Sopenharmony_ci| uri | Pointer to the URI to convert.| 
82e41f4b71Sopenharmony_ci| length | Length of the URI to convert.| 
83e41f4b71Sopenharmony_ci| result | Double pointer to the path obtained. You also need to use **free()** of the standard library to release the memory allocated.| 
84e41f4b71Sopenharmony_ci
85e41f4b71Sopenharmony_ci**Returns**
86e41f4b71Sopenharmony_ci
87e41f4b71Sopenharmony_ciReturns [FileManagement_ErrCode](_file_i_o.md#filemanagement_errcode).
88e41f4b71Sopenharmony_ci
89e41f4b71Sopenharmony_ci
90e41f4b71Sopenharmony_ci### OH_FileUri_GetUriFromPath()
91e41f4b71Sopenharmony_ci
92e41f4b71Sopenharmony_ci```
93e41f4b71Sopenharmony_ciFileManagement_ErrCode OH_FileUri_GetUriFromPath (const char * path, unsigned int length, char ** result )
94e41f4b71Sopenharmony_ci```
95e41f4b71Sopenharmony_ci
96e41f4b71Sopenharmony_ci**Description**
97e41f4b71Sopenharmony_ci
98e41f4b71Sopenharmony_ciObtains the URI from a path.
99e41f4b71Sopenharmony_ci
100e41f4b71Sopenharmony_ci**System capability**: SystemCapability.FileManagement.AppFileService
101e41f4b71Sopenharmony_ci
102e41f4b71Sopenharmony_ci**Since**: 12
103e41f4b71Sopenharmony_ci
104e41f4b71Sopenharmony_ci**Parameters**
105e41f4b71Sopenharmony_ci
106e41f4b71Sopenharmony_ci| Name| Description| 
107e41f4b71Sopenharmony_ci| -------- | -------- |
108e41f4b71Sopenharmony_ci| path | Pointer to the path to convert.| 
109e41f4b71Sopenharmony_ci| length | Length of the path to convert.| 
110e41f4b71Sopenharmony_ci| result | Double pointer to the URI obtained. You also need to use **free()** of the standard library to release the memory allocated.| 
111e41f4b71Sopenharmony_ci
112e41f4b71Sopenharmony_ci**Returns**
113e41f4b71Sopenharmony_ci
114e41f4b71Sopenharmony_ciReturns [FileManagement_ErrCode](_file_i_o.md#filemanagement_errcode).
115e41f4b71Sopenharmony_ci
116e41f4b71Sopenharmony_ci
117e41f4b71Sopenharmony_ci### OH_FileUri_IsValidUri()
118e41f4b71Sopenharmony_ci
119e41f4b71Sopenharmony_ci```
120e41f4b71Sopenharmony_cibool OH_FileUri_IsValidUri (const char * uri, unsigned int length )
121e41f4b71Sopenharmony_ci```
122e41f4b71Sopenharmony_ci
123e41f4b71Sopenharmony_ci**Description**
124e41f4b71Sopenharmony_ci
125e41f4b71Sopenharmony_ciChecks whether a URI is valid.
126e41f4b71Sopenharmony_ci
127e41f4b71Sopenharmony_ci**System capability**: SystemCapability.FileManagement.AppFileService
128e41f4b71Sopenharmony_ci
129e41f4b71Sopenharmony_ci**Since**: 12
130e41f4b71Sopenharmony_ci
131e41f4b71Sopenharmony_ci**Parameters**
132e41f4b71Sopenharmony_ci
133e41f4b71Sopenharmony_ci| Name| Description| 
134e41f4b71Sopenharmony_ci| -------- | -------- |
135e41f4b71Sopenharmony_ci| uri | Pointer to the URI to check.| 
136e41f4b71Sopenharmony_ci| length | Length of the URI to check.| 
137e41f4b71Sopenharmony_ci
138e41f4b71Sopenharmony_ci**Returns**
139e41f4b71Sopenharmony_ci
140e41f4b71Sopenharmony_ciReturns **true** if the URI is valid; returns **false** otherwise.
141