openharmony 鸿蒙 capi-raw-file-h

2026-08-25 浏览 (1)

raw_file.h

Overview

Provides functions related to rawfiles, including searching for, reading, and closing rawfiles.

File to include: <rawfile/raw_file.h>

Library: librawfile.z.so

System capability: SystemCapability.Global.ResourceManager

Since: 8

Related module: rawfile

Summary

Structs

Nametypedef KeywordDescription
RawFileDescriptorRawFileDescriptorDefines the file descriptor information of a file in the rawfile directory. RawFileDescriptor is an output parameter of OH_ResourceManager_GetRawFileDescriptor. It contains the file descriptor of a rawfile and the start position and length of the rawfile in the HAP.
RawFileDescriptor64RawFileDescriptor64Defines the file descriptor of a large rawfile. RawFileDescriptor64 is an output parameter of OH_ResourceManager_GetRawFileDescriptor64. It contains the file descriptor of a rawfile and the start position and length of the rawfile in the HAP.
RawFileRawFileProvides access to rawfiles.
RawFile64RawFile64Provides access to large rawfiles.

Functions

NameDescription
int OH_ResourceManager_ReadRawFile(const RawFile *rawFile, void *buf, size_t length)Reads data of the specified length from the current position in a rawfile.
int OH_ResourceManager_SeekRawFile(const RawFile *rawFile, long offset, int whence)Searches for the data read/write position in a rawfile based on the specified offset.
long OH_ResourceManager_GetRawFileSize(RawFile *rawFile)Obtains the length of the rawfile, in long.
long OH_ResourceManager_GetRawFileRemainingLength(const RawFile *rawFile)Obtains the remaining length of the rawfile, in long.
void OH_ResourceManager_CloseRawFile(RawFile *rawFile)Closes a RawFile and releases all associated resources.
long OH_ResourceManager_GetRawFileOffset(const RawFile *rawFile)Obtains the current offset of a rawfile, in long.
bool OH_ResourceManager_GetRawFileDescriptor(const RawFile *rawFile, RawFileDescriptor &descriptor)Opens a rawfile based on the specified offset (in long) and file length (in long) and obtains the file descriptor. The file descriptor obtained can be used to read the file. (It is deprecated in API version 12.)
bool OH_ResourceManager_GetRawFileDescriptorData(const RawFile *rawFile, RawFileDescriptor *descriptor)Opens a rawfile based on the specified offset (in long) and file length (in long) and obtains the file descriptor. The file descriptor obtained can be used to read the file.
bool OH_ResourceManager_ReleaseRawFileDescriptor(const RawFileDescriptor &descriptor)Releases the file descriptor of a rawfile. To prevent file descriptor leakage, you are advised to release a rawfile descriptor immediately after use. (It is deprecated in API version 12.)
bool OH_ResourceManager_ReleaseRawFileDescriptorData(const RawFileDescriptor *descriptor)Releases the file descriptor of a rawfile. To prevent file descriptor leakage, you are advised to release a rawfile descriptor immediately after use.
int64_t OH_ResourceManager_ReadRawFile64(const RawFile64 *rawFile, void *buf, int64_t length)Reads data of the specified length from the current position in a large rawfile.
int OH_ResourceManager_SeekRawFile64(const RawFile64 *rawFile, int64_t offset, int whence)Searches for the data read/write position in a large rawfile based on the specified offset.
int64_t OH_ResourceManager_GetRawFileSize64(RawFile64 *rawFile)Obtains the length of a large rawfile, in int64_t.
int64_t OH_ResourceManager_GetRawFileRemainingLength64(const RawFile64 *rawFile)Obtains the remaining length of a large rawfile, in int64_t.
void OH_ResourceManager_CloseRawFile64(RawFile64 *rawFile)Closes an opened RawFile64 and releases all associated resources.
int64_t OH_ResourceManager_GetRawFileOffset64(const RawFile64 *rawFile)Obtains the offset of a large rawfile, in int64_t.
bool OH_ResourceManager_GetRawFileDescriptor64(const RawFile64 *rawFile, RawFileDescriptor64 *descriptor)Opens a large rawfile based on the specified offset (in int64_t) and file length (in int64_t) and obtains the file descriptor. The file descriptor obtained can be used to read the file.
bool OH_ResourceManager_ReleaseRawFileDescriptor64(const RawFileDescriptor64 *descriptor)Releases the file descriptor of a rawfile. To prevent file descriptor leakage, you are advised to release a rawfile descriptor immediately after use.

Function Description

OH_ResourceManager_ReadRawFile()

int OH_ResourceManager_ReadRawFile(const RawFile *rawFile, void *buf, size_t length)

Description

Reads data of the specified length from the current position in a rawfile.

Since: 8

Parameters

NameDescription
const RawFile *rawFilePointer to RawFile.
void *bufPointer to the buffer for receiving the read data.
size_t lengthLength of the data to read.

Returns

TypeDescription
intNumber of read bytes. If the read length exceeds the length of the file end or rawfile is empty, 0 is returned.

OH_ResourceManager_SeekRawFile()

int OH_ResourceManager_SeekRawFile(const RawFile *rawFile, long offset, int whence)

Description

Searches for the data read/write position in a rawfile based on the specified offset.

Since: 8

Parameters

NameDescription
const RawFile *rawFilePointer to RawFile.
long offsetSpecified offset.
int whenceRead/Write position. The options are as follows:
0: The read/write position is the start position of the file plus the offset.
1: The read/write position is the current position plus the offset.
2: The read/write position is the end position of the file plus the offset.

Returns

TypeDescription
int0 if the search is successful; -1 otherwise.

OH_ResourceManager_GetRawFileSize()

long OH_ResourceManager_GetRawFileSize(RawFile *rawFile)

Description

Obtains the length of the rawfile, in long.

Since: 8

Parameters

NameDescription
RawFile *rawFilePointer to RawFile.

Returns

TypeDescription
longOverall length of the rawfile. If the rawfile is empty, 0 is returned.

OH_ResourceManager_GetRawFileRemainingLength()

long OH_ResourceManager_GetRawFileRemainingLength(const RawFile *rawFile)

Description

Obtains the remaining length of the rawfile, in long.

Since: 11

Parameters

NameDescription
const RawFile *rawFilePointer to RawFile.

Returns

TypeDescription
longRemaining length of the rawfile. If the rawfile is empty, 0 is returned.

OH_ResourceManager_CloseRawFile()

void OH_ResourceManager_CloseRawFile(RawFile *rawFile)

Description

Closes a RawFile and releases all associated resources.

Since: 8

Parameters

NameDescription
RawFile *rawFilePointer to RawFile.

Reference

OH_ResourceManager_OpenRawFile

OH_ResourceManager_GetRawFileOffset()

long OH_ResourceManager_GetRawFileOffset(const RawFile *rawFile)

Description

Obtains the current offset of a rawfile, in long.

Since: 8

Parameters

NameDescription
const RawFile *rawFilePointer to RawFile.

Returns

TypeDescription
longCurrent offset of the rawfile. If the rawfile is empty, 0 is returned.

OH_ResourceManager_GetRawFileDescriptor()

bool OH_ResourceManager_GetRawFileDescriptor(const RawFile *rawFile, RawFileDescriptor &descriptor)

Description

Opens a rawfile based on the specified offset (in long) and file length (in long) and obtains the file descriptor. The file descriptor obtained can be used to read the file.

Since: 8

Deprecated from: 12

Substitute: OH_ResourceManager_GetRawFileDescriptorData

Parameters

NameDescription
const RawFile *rawFilePointer to RawFile.
RawFileDescriptor &descriptorFile descriptor of the rawfile, start position of the rawfile in the HAP, and length of the rawfile.

Returns

TypeDescription
booltrue if the file is opened; returns false if the access to the file is rejected.

OH_ResourceManager_GetRawFileDescriptorData()

bool OH_ResourceManager_GetRawFileDescriptorData(const RawFile *rawFile, RawFileDescriptor *descriptor)

Description

Opens a rawfile based on the specified offset (in long) and file length (in long) and obtains the file descriptor. The file descriptor obtained can be used to read the file.

Since: 12

Parameters

NameDescription
const RawFile *rawFilePointer to RawFile.
RawFileDescriptor *descriptorFile descriptor of the rawfile, start position of the rawfile in the HAP, and length of the rawfile.

Returns

TypeDescription
booltrue if the file is opened; returns false if the access to the file is rejected.

OH_ResourceManager_ReleaseRawFileDescriptor()

bool OH_ResourceManager_ReleaseRawFileDescriptor(const RawFileDescriptor &descriptor)

Description

Releases the file descriptor of a rawfile. To prevent file descriptor leakage, you are advised to release a rawfile descriptor immediately after use.

Since: 8

Deprecated from: 12

Substitute: OH_ResourceManager_ReleaseRawFileDescriptorData

Parameters

NameDescription
const RawFileDescriptor &descriptorFile descriptor of the rawfile. It contains the file descriptor, start position in the HAP, and file length.

Returns

TypeDescription
boolReturns true if the file descriptor is released; returns false otherwise.

OH_ResourceManager_ReleaseRawFileDescriptorData()

bool OH_ResourceManager_ReleaseRawFileDescriptorData(const RawFileDescriptor *descriptor)

Description

Releases the file descriptor of a rawfile. To prevent file descriptor leakage, you are advised to release a rawfile descriptor immediately after use.

Since: 12

Parameters

NameDescription
const RawFileDescriptor *descriptorFile descriptor of the rawfile. It contains the file descriptor, start position in the HAP, and file length.

Returns

TypeDescription
boolReturns true if the file descriptor is released; returns false otherwise.

OH_ResourceManager_ReadRawFile64()

int64_t OH_ResourceManager_ReadRawFile64(const RawFile64 *rawFile, void *buf, int64_t length)

Description

Reads data of the specified length from the current position in a large rawfile.

Since: 11

Parameters

NameDescription
const RawFile64 *rawFilePointer to RawFile64.
void *bufPointer to the buffer for receiving the read data.
int64_t lengthLength of the data to read.

Returns

TypeDescription
int64_tNumber of read bytes. If the read length exceeds the length of the file end or rawfile is empty, 0 is returned.

OH_ResourceManager_SeekRawFile64()

int OH_ResourceManager_SeekRawFile64(const RawFile64 *rawFile, int64_t offset, int whence)

Description

Searches for the data read/write position in a large rawfile based on the specified offset.

Since: 11

Parameters

NameDescription
const RawFile64 *rawFilePointer to RawFile64.
int64_t offsetSpecified offset.
int whenceRead/Write position. The options are as follows:
0: The read/write position is the start position of the file plus the offset.
1: The read/write position is the current position plus the offset.
2: The read/write position is the end position of the file plus the offset.

Returns

TypeDescription
int0 if the search is successful; -1 otherwise.

OH_ResourceManager_GetRawFileSize64()

int64_t OH_ResourceManager_GetRawFileSize64(RawFile64 *rawFile)

Description

Obtains the length of a large rawfile, in int64_t.

Since: 11

Parameters

NameDescription
RawFile64 *rawFilePointer to RawFile64.

Returns

TypeDescription
int64_tOverall length of the rawfile. If the rawfile is empty, 0 is returned.

OH_ResourceManager_GetRawFileRemainingLength64()

int64_t OH_ResourceManager_GetRawFileRemainingLength64(const RawFile64 *rawFile)

Description

Obtains the remaining length of a large rawfile, in int64_t.

Since: 11

Parameters

NameDescription
const RawFile64 *rawFilePointer to RawFile64.

Returns

TypeDescription
int64_tRemaining length of the rawfile. If the rawfile is empty, 0 is returned.

OH_ResourceManager_CloseRawFile64()

void OH_ResourceManager_CloseRawFile64(RawFile64 *rawFile)

Description

Closes an opened RawFile64 and releases all associated resources.

Since: 11

Parameters

NameDescription
RawFile64 *rawFilePointer to RawFile64.

Reference

OH_ResourceManager_OpenRawFile64

OH_ResourceManager_GetRawFileOffset64()

int64_t OH_ResourceManager_GetRawFileOffset64(const RawFile64 *rawFile)

Description

Obtains the offset of a large rawfile, in int64_t.

Since: 11

Parameters

NameDescription
const RawFile64 *rawFilePointer to RawFile64.

Returns

TypeDescription
int64_tCurrent offset of the rawfile. If the rawfile is empty, 0 is returned.

OH_ResourceManager_GetRawFileDescriptor64()

bool OH_ResourceManager_GetRawFileDescriptor64(const RawFile64 *rawFile, RawFileDescriptor64 *descriptor)

Description

Opens a large rawfile based on the specified offset (in int64_t) and file length (in int64_t) and obtains the file descriptor. The file descriptor obtained can be used to read the file.

Since: 11

Parameters

NameDescription
const RawFile64 *rawFilePointer to RawFile64.
RawFileDescriptor64 *descriptorFile descriptor of the rawfile, start position of the rawfile in the HAP, and length of the rawfile.

Returns

TypeDescription
booltrue if the file is opened; returns false if the access to the file is rejected.

OH_ResourceManager_ReleaseRawFileDescriptor64()

bool OH_ResourceManager_ReleaseRawFileDescriptor64(const RawFileDescriptor64 *descriptor)

Description

Releases the file descriptor of a rawfile. To prevent file descriptor leakage, you are advised to release a rawfile descriptor immediately after use.

Since: 11

Parameters

NameDescription
const RawFileDescriptor64 *descriptorFile descriptor of the rawfile. It contains the file descriptor, start position in the HAP, and file length.

Returns

TypeDescription
boolReturns true if the file descriptor is released; returns false otherwise.

你可能感兴趣的鸿蒙文章

openharmony 鸿蒙 capi-i18n-initialtimezonerule

openharmony 鸿蒙 capi-i18n-timezonerules

openharmony 鸿蒙 capi-resmgr-common-h

openharmony 鸿蒙 capi-i18n-annualtimezonerule

openharmony 鸿蒙 errorcode-font-manager

openharmony 鸿蒙 capi-raw-dir-h

openharmony 鸿蒙 capi-i18n-timezonerulequery

openharmony 鸿蒙 capi-errorcode-h

openharmony 鸿蒙 js-apis-resource-manager

openharmony 鸿蒙 js-apis-sendableResource

  • 所属分类: 后端技术
  • 本文标签: 鸿蒙 软件
  • 版权声明: 本文链接 https://seaxiang.com/blog/o6Nf2jYL