• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# oh_file_uri.h
2
3
4## Overview
5
6FileUri provides basic operations related to file URIs, such as converting URIs to sandbox paths, converting application sandbox paths to application URIs, and obtaining URIs of the directory paths where URIs are located, facilitating URI access in file sharing services.
7
8**Library**: **libohfileuri.so**
9
10**Since**: 12
11
12**Related module**: [Fileuri](fileuri.md)
13
14
15## Summary
16
17
18### Functions
19
20| Name| Description|
21|---------------|--------------|
22| [FileManagement_ErrCode](_file_i_o.md#filemanagement_errcode) [OH_FileUri_GetUriFromPath](fileuri.md#oh_fileuri_geturifrompath) (const char \*path, unsigned int length, char \*\*result) | Generates the application URI based on the input path. When a path is converted to a URI, Chinese characters and non-digit characters in the path are compiled into the corresponding ASCII code and combined into the URI.|
23| [FileManagement_ErrCode](_file_i_o.md#filemanagement_errcode) [OH_FileUri_GetPathFromUri](fileuri.md#oh_fileuri_getpathfromuri) (const char \*uri, unsigned int length, char \*\*result) | Converts the URI to the corresponding sandbox path. 1. During URI-to-path conversion, the ASCII code in the URI is decoded and then concatenated to the original position. The URI generated by a non-system interface may contain characters beyond the ASCII code parsing range. As a result, the string cannot be concatenated. 2. The conversion is performed based on the string replacement rule specified by the system (the rule may change with the system evolution). During the conversion, the path is not verified, and the conversion result may not be accessible.|
24| [FileManagement_ErrCode](_file_i_o.md#filemanagement_errcode) [OH_FileUri_GetFullDirectoryUri](fileuri.md#oh_fileuri_getfulldirectoryuri) (const char \*uri, unsigned int length, char \*\*result) | Obtains the URI of the path. If the URI points to a file, the URI of the path is returned. If the URI points to a directory, the original string is returned without processing. If the file specified by the URI does not exist or the attribute fails to be obtained, an empty string is returned.|
25| bool [OH_FileUri_IsValidUri](fileuri.md#oh_fileuri_isvaliduri) (const char \*uri, unsigned int length)  | Checks whether the format of the input URI is correct. The system only checks whether the URI meets the format specifications defined by the system. The validity of the URI is not verified.|
26| [FileManagement_ErrCode](_file_i_o.md#filemanagement_errcode) [OH_FileUri_GetFileName](fileuri.md#oh_fileuri_getfilename) (const char \*uri, unsigned int length, char \*\*result) | Obtains the file name based on the given URI. (If the ASCII code exists in the file name, the ASCII code will be decoded and concatenated to the original position.)|
27