raw_file_manager.h

Overview

Provides file management functions for the rawfile directory. You can use the ResourceManager to open a rawfile and perform operations such as data search and reading.

File to include: <rawfile/raw_file_manager.h>

Library: librawfile.z.so

System capability: SystemCapability.Global.ResourceManager

Since: 8

Related module: rawfile

Summary

Structs

Name typedef Keyword Description
NativeResourceManager NativeResourceManager Represents the native ResourceManager. This class encapsulates the native implementation of the JavaScript resource manager. The ResourceManager pointer can be obtained by using OH_ResourceManager_InitNativeResourceManager.

Functions

Name Description
NativeResourceManager *OH_ResourceManager_InitNativeResourceManager(napi_env env, napi_value jsResMgr) Obtains the native ResourceManager based on the JavaScript ResourceManager to implement rawfile-specific functions.
void OH_ResourceManager_ReleaseNativeResourceManager(NativeResourceManager *resMgr) Releases the native ResourceManager.
RawDir *OH_ResourceManager_OpenRawDir(const NativeResourceManager *mgr, const char *dirName) Traverses all files in the rawfile directory.
RawFile *OH_ResourceManager_OpenRawFile(const NativeResourceManager *mgr, const char *fileName) Opens a rawfile and reads the data in it.
RawFile64 *OH_ResourceManager_OpenRawFile64(const NativeResourceManager *mgr, const char *fileName) Opens a large rawfile and reads the data in it.
bool OH_ResourceManager_IsRawDir(const NativeResourceManager *mgr, const char *path) Checks whether the path of a rawfile is a subdirectory in the rawfile directory.

Function Description

OH_ResourceManager_InitNativeResourceManager()

NativeResourceManager *OH_ResourceManager_InitNativeResourceManager(napi_env env, napi_value jsResMgr)

Description

Obtains the native ResourceManager based on the JavaScript ResourceManager to implement rawfile-specific functions.

Since: 8

Parameters

Name Description
napi_env env Pointer to the JavaScript Native API (napi) environment.
napi_value jsResMgr JavaScript ResourceManager object.

Returns

Type Description
NativeResourceManager * Pointer to NativeResourceManager. If the operation fails, a null pointer is returned.

OH_ResourceManager_ReleaseNativeResourceManager()

void OH_ResourceManager_ReleaseNativeResourceManager(NativeResourceManager *resMgr)

Description

Releases the native ResourceManager.

Since: 8

Parameters

Name Description
NativeResourceManager *resMgr Pointer to NativeResourceManager.

OH_ResourceManager_OpenRawDir()

RawDir *OH_ResourceManager_OpenRawDir(const NativeResourceManager *mgr, const char *dirName)

Description

Traverses all files in the rawfile directory.

Since: 8

Parameters

Name Description
const NativeResourceManager *mgr Pointer to NativeResourceManager, which is obtained by calling OH_ResourceManager_InitNativeResourceManager.
const char *dirName Pointer to the name of the directory to open. If this field is left empty, the root directory will be opened.

Returns

Type Description
RawDir * Pointer to RawDir. After using the pointer, call OH_ResourceManager_CloseRawDir to release it. If the operation fails or mgr is empty, a null pointer is returned.

Reference

OH_ResourceManager_InitNativeResourceManager

OH_ResourceManager_CloseRawDir

OH_ResourceManager_OpenRawFile()

RawFile *OH_ResourceManager_OpenRawFile(const NativeResourceManager *mgr, const char *fileName)

Description

Opens a rawfile and reads the data in it.

Since: 8

Parameters

Name Description
const NativeResourceManager *mgr Pointer to NativeResourceManager, which is obtained by calling OH_ResourceManager_InitNativeResourceManager.
const char *fileName Pointer to the name of the file in the relative path of the rawfile root directory.

Returns

Type Description
RawFile * Pointer to RawFile. After using the pointer, call OH_ResourceManager_CloseRawFile to release it. If the operation fails or mgr or fileName is empty, a null pointer is returned.

Reference

OH_ResourceManager_InitNativeResourceManager

OH_ResourceManager_CloseRawFile

OH_ResourceManager_OpenRawFile64()

RawFile64 *OH_ResourceManager_OpenRawFile64(const NativeResourceManager *mgr, const char *fileName)

Description

Opens a large rawfile and reads the data in it.

Since: 11

Parameters

Name Description
const NativeResourceManager *mgr Pointer to NativeResourceManager, which is obtained by calling OH_ResourceManager_InitNativeResourceManager.
const char *fileName Pointer to the name of the file in the relative path of the rawfile root directory.

Returns

Type Description
RawFile64 * Pointer to RawFile64. After using this pointer, call OH_ResourceManager_CloseRawFile64 to release it. If the operation fails or mgr or fileName is empty, a null pointer is returned.

Reference

OH_ResourceManager_InitNativeResourceManager

OH_ResourceManager_CloseRawFile64

OH_ResourceManager_IsRawDir()

bool OH_ResourceManager_IsRawDir(const NativeResourceManager *mgr, const char *path)

Description

Checks whether the path of a raw file is a subdirectory in the rawfile directory.

Since: 12

Parameters

Name Description
const NativeResourceManager *mgr Pointer to NativeResourceManager, which is obtained by calling OH_ResourceManager_InitNativeResourceManager.
const char *path Path of a rawfile.

Returns

Type Description
bool true if the path is a subdirectory in the rawfile directory; false otherwise.