harmony 鸿蒙oh_file_uri.h

  • 2025-06-12
  • 浏览 (4)

oh_file_uri.h

Overview

FileUri provides APIs for URI operations, including performing URI-path conversion, obtaining directory URIs, and verifying URIs.

Library: libohfileuri.so

System capability: SystemCapability.FileManagement.AppFileService

Since: 12

Related module: FileUri

Summary

Functions

Name Description
FileManagement_ErrCode OH_FileUri_GetUriFromPath (const char *path, unsigned int length, char **result) Converts the input path to the URI of the application.
In this process, Chinese characters and non-digit characters in the path are compiled into the corresponding ASCII code and concatenated to the URI.
FileManagement_ErrCode OH_FileUri_GetPathFromUri (const char *uri, unsigned int length, char **result) Converts the URI to the corresponding sandbox path.
1. In this process, the ASCII code in the URI is decoded and then concatenated to the original position. If the URI generated by a non-system API contains special characters that cannot be decoded, the string will not be concatenated.
2. Since strings are replaced based on specific rules that may evolve with the system, and no verification is performed, the converted path may not be accessible.
FileManagement_ErrCode 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.
If the file specified by the URI does not exist or the property fails to be obtained, an empty string is returned.
bool 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.
FileManagement_ErrCode OH_FileUri_GetFileName (const char *uri, unsigned int length, char **result) Obtains the file name based on the URI.
The ASCII code in the file name will be decoded and concatenated to the original position.

你可能感兴趣的鸿蒙文章

harmony 鸿蒙Core File Kit

harmony 鸿蒙Environment

harmony 鸿蒙FileIO

harmony 鸿蒙FileShare_PolicyErrorResult

harmony 鸿蒙FileShare_PolicyInfo

harmony 鸿蒙error_code.h

harmony 鸿蒙File Management Error Codes

harmony 鸿蒙FileShare

harmony 鸿蒙FileUri

harmony 鸿蒙@ohos.application.BackupExtensionAbility (Backup and Restore Extension Capability) (System API)

0  赞