diff --git a/global/resource_management/include/raw_file.h b/global/resource_management/include/raw_file.h
index 71c9f2bcce674cc35a0d0f85dcdf7aa913b10b38..c45a947d64263a97fc61ab2b6b759d310e66458f 100644
--- a/global/resource_management/include/raw_file.h
+++ b/global/resource_management/include/raw_file.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2022 Huawei Device Co., Ltd.
+ * Copyright (c) 2022-2023 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
@@ -46,6 +46,14 @@ extern "C" {
struct RawFile;
+/**
+ * @brief Provides access to a raw file.
+ *
+ * @since 11
+ * @version 1.0
+ */
+struct RawFile64;
+
/**
* @brief Provides access to a raw file.
*
@@ -56,6 +64,14 @@ struct RawFile;
*/
typedef struct RawFile RawFile;
+/**
+ * @brief Provides access to a raw file.
+ *
+ * @since 11
+ * @version 1.0
+ */
+typedef struct RawFile64 RawFile64;
+
/**
* @brief Represent the raw file descriptor's info.
*
@@ -76,6 +92,26 @@ typedef struct {
long length;
} RawFileDescriptor;
+/**
+ * @brief Represent the raw file descriptor's info.
+ *
+ * The RawFileDescriptor64 is an output parameter in the {@link OH_ResourceManager_GetRawFileDescriptor64},
+ * and describes the raw file's file descriptor, start position and the length in the HAP.
+ *
+ * @since 11
+ * @version 1.0
+ */
+typedef struct {
+ /** the raw file fd */
+ int fd;
+
+ /** the offset from where the raw file starts in the HAP */
+ int64_t start;
+
+ /** the length of the raw file in the HAP. */
+ int64_t length;
+} RawFileDescriptor64;
+
/**
* @brief Reads a raw file.
*
@@ -107,7 +143,7 @@ int OH_ResourceManager_ReadRawFile(const RawFile *rawFile, void *buf, size_t len
int OH_ResourceManager_SeekRawFile(const RawFile *rawFile, long offset, int whence);
/**
- * @brief Obtains the raw file length represented by an int32_t.
+ * @brief Obtains the raw file length represented by an long.
*
* @param rawFile Indicates the pointer to {@link RawFile}.
* @return Returns the total length of the raw file.
@@ -117,14 +153,14 @@ int OH_ResourceManager_SeekRawFile(const RawFile *rawFile, long offset, int when
long OH_ResourceManager_GetRawFileSize(RawFile *rawFile);
/**
- * @brief Obtains the remaining raw file length represented by an int64_t.
+ * @brief Obtains the remaining raw file length represented by an long.
*
* @param rawFile Indicates the pointer to {@link RawFile}.
* @return Returns the remaining length of the raw file.
* @since 11
* @version 1.0
*/
-int64_t OH_ResourceManager_GetRawFileRemainingLength(const RawFile *rawFile);
+long OH_ResourceManager_GetRawFileRemainingLength(const RawFile *rawFile);
/**
* @brief Closes an opened {@link RawFile} and releases all associated resources.
@@ -139,7 +175,7 @@ int64_t OH_ResourceManager_GetRawFileRemainingLength(const RawFile *rawFile);
void OH_ResourceManager_CloseRawFile(RawFile *rawFile);
/**
- * @brief Obtains the current offset of a raw file, represented by an int32_t.
+ * @brief Obtains the current offset of a raw file, represented by an long.
*
* The current offset of a raw file.
*
@@ -151,7 +187,7 @@ void OH_ResourceManager_CloseRawFile(RawFile *rawFile);
long OH_ResourceManager_GetRawFileOffset(const RawFile *rawFile);
/**
- * @brief Opens the file descriptor of a raw file based on the int32_t offset and file length.
+ * @brief Opens the file descriptor of a raw file based on the long offset and file length.
*
* The opened raw file descriptor is used to read the raw file.
*
@@ -175,6 +211,105 @@ bool OH_ResourceManager_GetRawFileDescriptor(const RawFile *rawFile, RawFileDesc
*/
bool OH_ResourceManager_ReleaseRawFileDescriptor(const RawFileDescriptor &descriptor);
+/**
+ * @brief Reads a raw file.
+ *
+ * This function attempts to read data of length bytes from the current offset. using a 64-bit
+ *
+ * @param rawFile Indicates the pointer to {@link RawFile64}.
+ * @param buf Indicates the pointer to the buffer for receiving the data read.
+ * @param length Indicates the number of bytes to read.
+ * @return Returns the number of bytes read if any; returns 0 if the number reaches the end of file (EOF).
+ * @since 11
+ * @version 1.0
+ */
+int64_t OH_ResourceManager_ReadRawFile64(const RawFile64 *rawFile, void *buf, size_t length);
+
+/**
+ * @brief Uses the 64-bit data type to seek a data read position based on the specified offset within a raw file.
+ *
+ * @param rawFile Indicates the pointer to {@link RawFile64}.
+ * @param offset Indicates the specified offset.
+ * @param whence Indicates the new read position, which can be one of the following values: \n
+ * 0: The new read position is set to offset. \n
+ * 1: The read position is set to the current position plus offset. \n
+ * 2: The read position is set to the end of file (EOF) plus offset.
+ * @return Returns (int) 0 if the operation is successful; returns (int) -1 if an error
+ * occurs.
+ * @since 11
+ * @version 1.0
+ */
+int OH_ResourceManager_SeekRawFile64(const RawFile64 *rawFile, long offset, int whence);
+
+/**
+ * @brief Obtains the raw file length represented by an int64_t.
+ *
+ * @param rawFile Indicates the pointer to {@link RawFile64}.
+ * @return Returns the total length of the raw file.
+ * @since 11
+ * @version 1.0
+ */
+int64_t OH_ResourceManager_GetRawFileSize64(RawFile64 *rawFile);
+
+/**
+ * @brief Obtains the remaining raw file length represented by an int64_t.
+ *
+ * @param rawFile Indicates the pointer to {@link RawFile64}.
+ * @return Returns the remaining length of the raw file.
+ * @since 11
+ * @version 1.0
+ */
+int64_t OH_ResourceManager_GetRawFileRemainingLength64(const RawFile64 *rawFile);
+
+/**
+ * @brief Closes an opened {@link RawFile64} and releases all associated resources.
+ *
+ *
+ *
+ * @param rawFile Indicates the pointer to {@link RawFile64}.
+ * @see OH_ResourceManager_OpenRawFile64
+ * @since 11
+ * @version 1.0
+ */
+void OH_ResourceManager_CloseRawFile64(RawFile64 *rawFile);
+
+/**
+ * @brief Obtains the current offset of a raw file, represented by an int64_t.
+ *
+ * The current offset of a raw file.
+ *
+ * @param rawFile Indicates the pointer to {@link RawFile64}.
+ * @return Returns the current offset of a raw file.
+ * @since 11
+ * @version 1.0
+ */
+int64_t OH_ResourceManager_GetRawFileOffset64(const RawFile64 *rawFile);
+
+/**
+ * @brief Opens the file descriptor of a raw file based on the int64_t offset and file length.
+ *
+ * The opened raw file descriptor is used to read the raw file.
+ *
+ * @param rawFile Indicates the pointer to {@link RawFile64}.
+ * @param descriptor Indicates the raw file's file descriptor, start position and the length in the HAP.
+ * @return Returns true: open the raw file descriptor successfully, false: the raw file is not allowed to access.
+ * @since 11
+ * @version 1.0
+ */
+bool OH_ResourceManager_GetRawFileDescriptor64(const RawFile64 *rawFile, RawFileDescriptor64 *descriptor);
+
+/**
+ * @brief Closes the file descriptor of a raw file.
+ *
+ * The opened raw file descriptor must be released after used to avoid the file descriptor leak.
+ *
+ * @param descriptor Indicates the raw file's file descriptor, start position and the length in the HAP.
+ * @return Returns true: closes the raw file descriptor successfully, false: closes the raw file descriptor failed.
+ * @since 11
+ * @version 1.0
+ */
+bool OH_ResourceManager_ReleaseRawFileDescriptor64(const RawFileDescriptor64 *descriptor);
+
#ifdef __cplusplus
};
#endif
diff --git a/global/resource_management/include/raw_file_manager.h b/global/resource_management/include/raw_file_manager.h
index f76a9c8cf1b45ab0abfe30f5949a2a0ec14ed120..9003923aebfc22c6de6a31feb961c4fff088f06a 100644
--- a/global/resource_management/include/raw_file_manager.h
+++ b/global/resource_management/include/raw_file_manager.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2022 Huawei Device Co., Ltd.
+ * Copyright (c) 2022-2023 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
@@ -118,6 +118,23 @@ RawDir *OH_ResourceManager_OpenRawDir(const NativeResourceManager *mgr, const ch
*/
RawFile *OH_ResourceManager_OpenRawFile(const NativeResourceManager *mgr, const char *fileName);
+/**
+ * @brief Opens a raw file.
+ *
+ * After it is opened, you can read its data.
+ *
+ * @param mgr Indicates the pointer to {@link NativeResourceManager} obtained by calling
+ * {@link OH_ResourceManager_InitNativeResourceManager}.
+ * @param fileName Indicates the file path relative to the top-level raw file directory.
+ * @return Returns the pointer to {@link RawFile64}. After you finish using the pointer, call
+ * {@link OH_ResourceManager_CloseRawFile64} to release it.
+ * @see OH_ResourceManager_InitNativeResourceManager
+ * @see OH_ResourceManager_CloseRawFile64
+ * @since 11
+ * @version 1.0
+ */
+RawFile64 *OH_ResourceManager_OpenRawFile64(const NativeResourceManager *mgr, const char *fileName);
+
#ifdef __cplusplus
};
#endif
diff --git a/global/resource_management/librawfile.ndk.json b/global/resource_management/librawfile.ndk.json
index 743d7513c7e7980d5507a0ea12d8ab052201f5cd..54f8c0a3559708965b3038bf41c1d766b059c5a7 100644
--- a/global/resource_management/librawfile.ndk.json
+++ b/global/resource_management/librawfile.ndk.json
@@ -43,5 +43,32 @@
},
{
"name": "OH_ResourceManager_ReleaseRawFileDescriptor"
+ },
+ {
+ "name": "OH_ResourceManager_OpenRawFile64"
+ },
+ {
+ "name": "OH_ResourceManager_ReadRawFile64"
+ },
+ {
+ "name": "OH_ResourceManager_SeekRawFile64"
+ },
+ {
+ "name": "OH_ResourceManager_GetRawFileSize64"
+ },
+ {
+ "name": "OH_ResourceManager_GetRawFileRemainingLength64"
+ },
+ {
+ "name": "OH_ResourceManager_CloseRawFile64"
+ },
+ {
+ "name": "OH_ResourceManager_GetRawFileOffset64"
+ },
+ {
+ "name": "OH_ResourceManager_GetRawFileDescriptor64"
+ },
+ {
+ "name": "OH_ResourceManager_ReleaseRawFileDescriptor64"
}
]
\ No newline at end of file