目录

content_embed_document.h

Overview

Provides the data structures and corresponding operation APIs related to the embedded documents (OE documents) implemented using the OE technology.

File to include: <ContentEmbedKit/content_embed/content_embed_document.h>

Library: libcontent_embed_ndk.so

System capability: SystemCapability.ContentEmbed.ObjectEditor

Since: 24

Related module: ContentEmbed

Summary

[h2]Structs

Name typedef Keyword Description
ContentEmbed_Document ContentEmbed_Document Defines the structure type of an OE document. Encapsulates the metadata, content, and storage structure of an embedded document.
ContentEmbed_Storage ContentEmbed_Storage Defines the storage structure type of an OE document. Similar to a directory in the file system, the parent object of a storage object must be another storage object or the root storage object.
ContentEmbed_StorageElement ContentEmbed_StorageElement Defines the structure type of a storage element in an OE document. It contains information such as the name, type, and time.
ContentEmbed_StorageElements ContentEmbed_StorageElements Declares the ContentEmbed_StorageElements structure. Contains the ContentEmbed_StorageElement set information.
ContentEmbed_Stream ContentEmbed_Stream Declares the Stream structure type of an OE document. Similar to a file in the file system, a stream can be read or written. A stream object can exist only in a storage object.

[h2]Macros

Name Description
MAX_PATH_LENGTH (4 * 1024)

Indicates the maximum length of a file path.

Since: 24

[h2]Functions

Name Description
ContentEmbed_ErrorCode OH_ContentEmbed_CreateDocumentByOEid(const char *oeid, ContentEmbed_Document **document)

Creates a new ContentEmbed_Document instance using the provided identifier (OEID).

You can destroy the instance using OH_ContentEmbed_DestroyDocument to avoid memory leaks.

ContentEmbed_ErrorCode OH_ContentEmbed_CreateDocumentByFile(const char *srcFilePath, size_t length, bool isLinking, ContentEmbed_Document **document)

Creates a new ContentEmbed_Document instance from a source file.

You can destroy the instance using OH_ContentEmbed_DestroyDocument to avoid memory leaks.

ContentEmbed_ErrorCode OH_ContentEmbed_LoadDocumentFromFile(const char *srcFilePath, size_t length, ContentEmbed_Document **document)

Loads an ContentEmbed_Document instance from an existing .oe file.

You can destroy the instance using OH_ContentEmbed_DestroyDocument to avoid memory leaks.

ContentEmbed_ErrorCode OH_ContentEmbed_Document_Read(uint8_t *buffer, size_t length, ContentEmbed_Document *document, size_t offset, size_t *readSize) Reads the original binary data from the specified offset position of the.oe file to the buffer.
ContentEmbed_ErrorCode OH_ContentEmbed_Document_GetOEid(const ContentEmbed_Document *document, char *oeid) Obtains the identifier of an OE document object.
ContentEmbed_ErrorCode OH_ContentEmbed_Document_IsLinking(const ContentEmbed_Document *document, bool *isLinking) Checks whether an OE document is created in link mode.
ContentEmbed_ErrorCode OH_ContentEmbed_Document_GetNativeFilePath(const ContentEmbed_Document *document, char *nativeFilePath) Obtains the path of the embedded source file stored in the sandbox directory of the client from the OE document.
ContentEmbed_ErrorCode OH_ContentEmbed_Document_GetRootStorage(ContentEmbed_Document *document, ContentEmbed_Storage **storage)

Obtains the root ContentEmbed_Storage object from the OE document object.

You can destroy the instance using OH_ContentEmbed_DestroyStorage to avoid memory leaks.

ContentEmbed_ErrorCode OH_ContentEmbed_Document_Flush(const ContentEmbed_Document *document) Flushes data in an OE document to an OE file.
ContentEmbed_ErrorCode OH_ContentEmbed_Storage_CreateStorage(const ContentEmbed_Storage *parentStorage, const char *name, ContentEmbed_Storage **childStorage)

Creates a child ContentEmbed_Storage object based on the parent Storage object and name of the OE document.

You can destroy the instance using OH_ContentEmbed_DestroyStorage to avoid memory leaks.

ContentEmbed_ErrorCode OH_ContentEmbed_Storage_GetStorage(const ContentEmbed_Storage *parentStorage, const char *name, ContentEmbed_Storage **childStorage)

Obtains a child ContentEmbed_Storage object from the parent Storage object and name of the OE document.

You can destroy the instance using OH_ContentEmbed_DestroyStorage to avoid memory leaks.

ContentEmbed_ErrorCode OH_ContentEmbed_Storage_CreateStream(ContentEmbed_Storage *parentStorage, const char *name, ContentEmbed_Stream **childStream)

Creates a ContentEmbed_Stream object from the parent Storage object and name in the OE document.

You can destroy the instance using OH_ContentEmbed_DestroyStream to avoid memory leaks.

ContentEmbed_ErrorCode OH_ContentEmbed_Storage_GetStream(ContentEmbed_Storage *parentStorage, const char *name, ContentEmbed_Stream **childStream)

Obtains a child ContentEmbed_Stream object from the parent Storage object and name in the OE document.

You can destroy the instance using OH_ContentEmbed_DestroyStream to avoid memory leaks.

ContentEmbed_ErrorCode OH_ContentEmbed_Storage_DeleteEntry(ContentEmbed_Storage *parentStorage, const char *name) Deletes a child Storage object or Stream object with a specified name from the parent Storage object in the HarmonyOS document.
ContentEmbed_ErrorCode OH_ContentEmbed_Storage_DeleteAllEntry(ContentEmbed_Storage *storage) Deletes all entries from the storage object of an OpenEdge document, including the sub-storage objects and sub-stream objects.
ContentEmbed_ErrorCode OH_ContentEmbed_DestroyStorage(ContentEmbed_Storage *storage) Destroys the ContentEmbed_Storage object instance of an OpenEdge document and reclaims the memory.
ContentEmbed_ErrorCode OH_ContentEmbed_Stream_Read(ContentEmbed_Stream *stream, unsigned char **buffer, size_t length, size_t *num) Reads data of a specified length from the current position of the stream object of an OpenEdge document to the buffer. After the data is successfully read, the offset of the stream object increases by the number of actually read bytes.
ContentEmbed_ErrorCode OH_ContentEmbed_Stream_Write(ContentEmbed_Stream *stream, const unsigned char *data, size_t length, size_t *num) Writes data of a specified length from the buffer to the current position of the stream object of an OpenEdge document. After the data is successfully written, the offset of the stream object increases by the number of actually written bytes.
ContentEmbed_ErrorCode OH_ContentEmbed_Stream_Seek(ContentEmbed_Stream *stream, size_t position) Sets the current read location of the stream object in an OE document to the specified offset.
ContentEmbed_ErrorCode OH_ContentEmbed_Stream_GetPosition(ContentEmbed_Stream *stream, size_t *position) Obtains the current position offset of the stream object in an OE document.
ContentEmbed_ErrorCode OH_ContentEmbed_Stream_GetSize(ContentEmbed_Stream *stream, size_t *size) Obtains the total size of the stream object in an OE document, in bytes.
ContentEmbed_ErrorCode OH_ContentEmbed_DestroyStream(ContentEmbed_Stream *stream) Destroys the ContentEmbed_Stream object instance of an OE document and reclaims the memory.
ContentEmbed_ErrorCode OH_ContentEmbed_DestroyDocument(ContentEmbed_Document *document) Destroys the ContentEmbed_Document object instance and reclaims the memory.
ContentEmbed_ErrorCode OH_ContentEmbed_Storage_GetOEid(ContentEmbed_Storage *storage, char *oeid, size_t oeidSize) Obtains the identifier (OEID) of the storage object in an OE document.
ContentEmbed_ErrorCode OH_ContentEmbed_Storage_SetOEid(ContentEmbed_Storage *storage, char *oeid, size_t oeidSize) Sets the identifier of the storage object in the OE document.
ContentEmbed_ErrorCode OH_ContentEmbed_StorageElements_Create(ContentEmbed_StorageElements **storageElements)

Creates and initializes an ContentEmbed_StorageElements instance.

You can destroy the instance using OH_ContentEmbed_StorageElements_Destroy to avoid memory leaks.

ContentEmbed_ErrorCode OH_ContentEmbed_StorageElements_Destroy(ContentEmbed_StorageElements *storageElements) Destroys the ContentEmbed_StorageElements instance and reclaims the occupied memory.
ContentEmbed_ErrorCode OH_ContentEmbed_Storage_GetElements(const ContentEmbed_Storage *storage, ContentEmbed_StorageElements *storageElements) Obtains the element list in the Storage object of the OE document.
ContentEmbed_ErrorCode OH_ContentEmbed_StorageElements_GetCount(const ContentEmbed_StorageElements *storageElements, size_t *count) Obtains the number of elements in the ContentEmbed_StorageElements instance.
ContentEmbed_ErrorCode OH_ContentEmbed_StorageElements_GetElement(const ContentEmbed_StorageElements *storageElements, size_t index, ContentEmbed_StorageElement **storageElement) Obtains the element at the specified index position in the ContentEmbed_StorageElements instance.
ContentEmbed_ErrorCode OH_ContentEmbed_StorageElement_GetName(const ContentEmbed_StorageElement *storageElement, char *name, size_t nameSize) Obtains the name of the ContentEmbed_StorageElement instance.
ContentEmbed_ErrorCode OH_ContentEmbed_StorageElement_GetCTime(const ContentEmbed_StorageElement *element, uint64_t *ctime) Obtains the creation timestamp of the ContentEmbed_StorageElement instance, in milliseconds.
ContentEmbed_ErrorCode OH_ContentEmbed_StorageElement_GetMTime(const ContentEmbed_StorageElement *element, uint64_t *mtime) Obtains the last modification timestamp of the ContentEmbed_StorageElement instance, in milliseconds.
ContentEmbed_ErrorCode OH_ContentEmbed_StorageElement_IsStorage(const ContentEmbed_StorageElement *storageElement, bool *isStorage) Checks whether the ContentEmbed_StorageElement instance is an object of the Storage class in the OE document.
ContentEmbed_ErrorCode OH_ContentEmbed_StorageElement_IsStream(const ContentEmbed_StorageElement *element, bool *isStream) Checks whether the ContentEmbed_StorageElement instance is a stream object of the OE document.
ContentEmbed_ErrorCode OH_ContentEmbed_Storage_CopyTo(ContentEmbed_Storage *srcStorage, ContentEmbed_Storage *destStorage) Copies all sub-storage objects and stream objects from the source OE document storage object to the target OE document storage object.

Function Description

[h2]OH_ContentEmbed_CreateDocumentByOEid()

ContentEmbed_ErrorCode OH_ContentEmbed_CreateDocumentByOEid(const char *oeid, ContentEmbed_Document **document)

Description

Creates a new ContentEmbed_Document instance using the provided identifier OEID.

You can destroy the instance using OH_ContentEmbed_DestroyDocument to avoid memory leaks.

Since: 24

Parameters:

Name Description
const char *oeid Identifier of the OE document, which is used to uniquely identify the OE document. It is recommended that the array length be MAX_OEID_LENGTH.
ContentEmbed_Document **document Output parameter. This pointer points to the newly created OE document object.

Returns:

Type Description
ContentEmbed_ErrorCode

The following error codes are returned:

CE_ERR_OK: The operation is successful.

CE_ERR_PARAM_INVALID: Failed to check the parameter.

CE_ERR_NULL_POINTER: A null pointer is returned.

CE_ERR_DEVICE_NOT_SUPPORTED: The device is not supported.

CE_ERR_IN_DLP_SANDBOX: This operation is not supported because the application is in the DLP sandbox.

[h2]OH_ContentEmbed_CreateDocumentByFile()

ContentEmbed_ErrorCode OH_ContentEmbed_CreateDocumentByFile(const char *srcFilePath, size_t length, bool isLinking, ContentEmbed_Document **document)

Description

Creates a new ContentEmbed_Document instance from a source file.

You can destroy the instance using OH_ContentEmbed_DestroyDocument to avoid memory leakage.

Since: 24

Parameters:

Name Description
const char *srcFilePath Source file path.
size_t length Length of the source file path string, excluding the terminator.
bool isLinking

Whether to create an OE document in link mode. true: The OE document is created in link mode. When the server edits the OE document, the source file is also modified.

false: The OE document is created in embedded mode. When the server edits the OE document in response to a client request, a temporary file is copied to the sandbox directory of the client app.

ContentEmbed_Document **document Output parameter. This pointer points to the newly created OE document object.

Returns:

Type Description
ContentEmbed_ErrorCode

The following error codes are returned:

CE_ERR_OK: indicates that the operation is successful.

CE_ERR_PARAM_INVALID: indicates that the parameter check fails.

CE_ERR_NULL_POINTER: indicates that a null pointer is returned.

CE_ERR_DEVICE_NOT_SUPPORTED: indicates that the device is not supported.

CE_ERR_IN_DLP_SANDBOX: indicates that the operation is not supported because the application is in the DLP sandbox.

CE_ERR_INVALID_LINKING_PATH: indicates that the link file is in the app sandbox and the link cannot be created.

[h2]OH_ContentEmbed_LoadDocumentFromFile()

ContentEmbed_ErrorCode OH_ContentEmbed_LoadDocumentFromFile(const char *srcFilePath, size_t length, ContentEmbed_Document **document)

Description

Loads an ContentEmbed_Document instance using an existing file in the OE format.

You can destroy the instance using OH_ContentEmbed_DestroyDocument to avoid memory leaks.

Since: 24

Parameters:

Name Description
const char *srcFilePath Source file path, which points to the file to be loaded in the OE format.
size_t length Length of the source file path string, excluding the terminator.
ContentEmbed_Document **document Output parameter. This pointer points to the newly created OE document object.

Returns:

Type Description
ContentEmbed_ErrorCode

The following error codes are returned:

CE_ERR_OK: The operation is successful.

CE_ERR_PARAM_INVALID: Parameter check failed.

CE_ERR_NULL_POINTER: A null pointer is returned.

CE_ERR_DEVICE_NOT_SUPPORTED: The device is not supported.

CE_ERR_IN_DLP_SANDBOX: This operation is not supported because the application is in the DLP sandbox.

[h2]OH_ContentEmbed_Document_Read()

ContentEmbed_ErrorCode OH_ContentEmbed_Document_Read(uint8_t *buffer, size_t length, ContentEmbed_Document *document, size_t offset, size_t *readSize)

Description

Reads the original binary data from the specified offset position of the OE document object to the buffer.

Since: 24

Parameters:

Name Description
uint8_t *buffer Output parameter. Buffer for storing the data read from the OE document.
size_t length Size of the buffer, in bytes.
ContentEmbed_Document *document Pointer to the OE document object.
size_t offset Offset position from which the data is read in the OE document, starting from 0.
size_t *readSize Output parameter. Length of the actually read data, in bytes.

Returns:

Type Description
ContentEmbed_ErrorCode

A specific error code is returned.

CE_ERR_OK: The operation is successful.

CE_ERR_PARAM_INVALID: Parameter check failed.

CE_ERR_NULL_POINTER: A null pointer is returned.

CE_ERR_DEVICE_NOT_SUPPORTED: The device is not supported.

CE_ERR_STORAGE_OPERATION_FAILED: Operations related to the OE file directory failed.

CE_ERR_IN_DLP_SANDBOX: This operation is not supported because the application is in the DLP sandbox.

[h2]OH_ContentEmbed_Document_GetOEid()

ContentEmbed_ErrorCode OH_ContentEmbed_Document_GetOEid(const ContentEmbed_Document *document, char *oeid)

Description

Obtains the identifier OEID from the OE document object.

Since: 24

Parameters:

Name Description
const ContentEmbed_Document *document Pointer to the OE document object.
char *oeid Output parameter. Character array for storing the OEID value. The recommended array length is MAX_OEID_LENGTH.

Returns:

Type Description
ContentEmbed_ErrorCode

A specific error code is returned.

CE_ERR_OK: The operation is successful.

CE_ERR_PARAM_INVALID: The parameter check fails.

CE_ERR_DEVICE_NOT_SUPPORTED: The device is not supported.

CE_ERR_IN_DLP_SANDBOX: This operation is not supported because the application is in the DLP sandbox.

[h2]OH_ContentEmbed_Document_IsLinking()

ContentEmbed_ErrorCode OH_ContentEmbed_Document_IsLinking(const ContentEmbed_Document *document, bool *isLinking)

Description

Checks whether an OE document is created in link mode.

Since: 24

Parameters:

Name Description
const ContentEmbed_Document *document Pointer to the OE document object.
bool *isLinking Output parameter. true indicates that the OE document is created in link mode. false indicates that the OE document is created in embedded mode.

Returns:

Type Description
ContentEmbed_ErrorCode

The following error codes are returned:

CE_ERR_OK: The operation is successful.

CE_ERR_PARAM_INVALID: Parameter check failed.

CE_ERR_DEVICE_NOT_SUPPORTED: The device is not supported.

CE_ERR_IN_DLP_SANDBOX: This operation is not supported because the application is in the DLP sandbox.

[h2]OH_ContentEmbed_Document_GetNativeFilePath()

ContentEmbed_ErrorCode OH_ContentEmbed_Document_GetNativeFilePath(const ContentEmbed_Document *document, char *nativeFilePath)

Description

Obtains the embedded source file path stored in the client sandbox directory from the OE document.

Since: 24

Parameters:

Name Description
const ContentEmbed_Document *document Pointer to the OE document object.
char *nativeFilePath Output parameter. Character array for storing the source file path. It is recommended that the array length be MAX_PATH_LENGTH.

Returns:

Type Description
ContentEmbed_ErrorCode

The following error codes are returned:

CE_ERR_OK: The operation is successful.

CE_ERR_PARAM_INVALID: Parameter check failed.

CE_ERR_DEVICE_NOT_SUPPORTED: The device is not supported.

CE_ERR_IN_DLP_SANDBOX: This operation is not supported because the application is in the DLP sandbox.

[h2]OH_ContentEmbed_Document_GetRootStorage()

ContentEmbed_ErrorCode OH_ContentEmbed_Document_GetRootStorage(ContentEmbed_Document *document, ContentEmbed_Storage **storage)

Description

Obtains the root ContentEmbed_Storage object from an HarmonyOS document object.

You can destroy the instance using OH_ContentEmbed_DestroyStorage to avoid memory leaks.

Since: 24

Parameters:

Name Description
ContentEmbed_Document *document Pointer to the HarmonyOS document object.
ContentEmbed_Storage **storage Output parameter. After the API is successfully called, this pointer points to the root storage object of the HarmonyOS document.

Returns:

Type Description
ContentEmbed_ErrorCode

Result code:

CE_ERR_OK: The operation is successful.

CE_ERR_PARAM_INVALID: Failed to check the parameters.

CE_ERR_NULL_POINTER: A null pointer is returned.

CE_ERR_DEVICE_NOT_SUPPORTED: The device is not supported.

CE_ERR_IN_DLP_SANDBOX: The operation is not supported because the application is in the DLP sandbox.

[h2]OH_ContentEmbed_Document_Flush()

ContentEmbed_ErrorCode OH_ContentEmbed_Document_Flush(const ContentEmbed_Document *document)

Description

Flushes data in an HarmonyOS document to an HarmonyOS file.

Since: 24

Parameters:

Name Description
const ContentEmbed_Document *document Pointer to the OE document object.

Returns:

Type Description
ContentEmbed_ErrorCode

The specific error code is returned:

CE_ERR_OK: The operation is successful.

CE_ERR_PARAM_INVALID: Failed to check the parameter.

CE_ERR_DEVICE_NOT_SUPPORTED: The device is not supported.

CE_ERR_FILE_OPERATION_FAILED: Failed to perform the file operation.

CE_ERR_IN_DLP_SANDBOX: This operation is not supported because the application is in the DLP sandbox.

[h2]OH_ContentEmbed_Storage_CreateStorage()

ContentEmbed_ErrorCode OH_ContentEmbed_Storage_CreateStorage(const ContentEmbed_Storage *parentStorage, const char *name, ContentEmbed_Storage **childStorage)

Description

Creates a child ContentEmbed_Storage object based on the parent storage object and name of the OE document.

You can destroy the instance using OH_ContentEmbed_DestroyStorage to avoid memory leaks.

Since: 24

Parameters:

Name Description
const ContentEmbed_Storage *parentStorage

Pointer to the parent storage object of the OE document.

To delete a specified child storage object from the parent storage object, call OH_ContentEmbed_Storage_DeleteEntry.

To delete all child storage objects from the parent storage object, call OH_ContentEmbed_Storage_DeleteAllEntry.

const char *name Name of the child storage object to be created. The value cannot be an empty string. It can contain a maximum of 31 characters and cannot contain invalid characters, such as '/', '', ':', and '!'.
ContentEmbed_Storage **childStorage Output parameter. After the function is successfully called, the pointer points to the newly created child storage object of the OpenEuler document.

Returns:

Type Description
ContentEmbed_ErrorCode

The specific error code is returned:

CE_ERR_OK: The operation is successful.

CE_ERR_PARAM_INVALID: The parameter check fails. The possible cause is that the parentStorage or name is invalid.

CE_ERR_NULL_POINTER: The returned pointer is null. The possible cause is that the childStorage fails to be created.

CE_ERR_DEVICE_NOT_SUPPORTED: The device is not supported.

CE_ERR_STORAGE_OPERATION_FAILED: The storage operation fails. The possible cause is that the disk space is insufficient.

CE_ERR_IN_DLP_SANDBOX: This operation is not supported because the application is in the DLP sandbox.

[h2]OH_ContentEmbed_Storage_GetStorage()

ContentEmbed_ErrorCode OH_ContentEmbed_Storage_GetStorage(const ContentEmbed_Storage *parentStorage, const char *name, ContentEmbed_Storage **childStorage)

Description

Obtains the child ContentEmbed_Storage object from the parent Storage object and name of the OE document.

You can destroy the instance by calling OH_ContentEmbed_DestroyStorage to avoid memory leaks.

Since: 24

Parameters:

Name Description
const ContentEmbed_Storage *parentStorage Pointer to the parent Storage object of the OE document.
const char *name Name of the child Storage object to be obtained. The value cannot be an empty string. It can contain a maximum of 31 characters and cannot contain invalid characters such as '/', '', ':', and '!'.
ContentEmbed_Storage **childStorage Output parameter. After the API is successfully called, the pointer points to the found child Storage object of the OE document.

Returns:

Type Description
ContentEmbed_ErrorCode

The specific error code is returned:

CE_ERR_OK: indicates that the operation is successful.

CE_ERR_PARAM_INVALID: indicates that the parameter check fails.

CE_ERR_NULL_POINTER: indicates that a null pointer is returned.

CE_ERR_DEVICE_NOT_SUPPORTED: indicates that the device is not supported.

CE_ERR_STORAGE_OPERATION_FAILED: indicates that the operation related to the directory of the OE document fails.

CE_ERR_IN_DLP_SANDBOX: The application is in the DLP sandbox and this operation is not supported.

[h2]OH_ContentEmbed_Storage_CreateStream()

ContentEmbed_ErrorCode OH_ContentEmbed_Storage_CreateStream(ContentEmbed_Storage *parentStorage, const char *name, ContentEmbed_Stream **childStream)

Description

Creates a ContentEmbed_Stream object for the parent storage object and name of an OE document.

You can destroy the instance using OH_ContentEmbed_DestroyStream to avoid memory leaks.

Since: 24

Parameters:

Name Description
ContentEmbed_Storage *parentStorage

Pointer to the parent storage object of an OE document.

You can call OH_ContentEmbed_Storage_DeleteEntry to delete a specified child stream object from the parent storage object.

You can call OH_ContentEmbed_Storage_DeleteAllEntry to delete all child stream objects from the parent storage object.

const char *name Name of the stream to be created, which is used to identify and search for the stream. The value cannot be an empty string. It can contain a maximum of 31 characters and cannot contain invalid characters, such as '/', '', ':', and '!'.
ContentEmbed_Stream **childStream Output parameter. After the call is successful, the pointer points to the newly created stream object of the OE document.

Returns:

Type Description
ContentEmbed_ErrorCode

The specific error code is returned:

CE_ERR_OK: The operation is successful.

CE_ERR_PARAM_INVALID: Failed to check the parameter.

CE_ERR_NULL_POINTER: A null pointer is returned.

CE_ERR_DEVICE_NOT_SUPPORTED: The device is not supported.

CE_ERR_STORAGE_OPERATION_FAILED: Operations related to the directory of the OE document failed.

CE_ERR_STREAM_OPERATION_FAILED: Operations related to the stream of the OE document failed.

CE_ERR_IN_DLP_SANDBOX: This operation is not supported because the application is in the DLP sandbox.

[h2]OH_ContentEmbed_Storage_GetStream()

ContentEmbed_ErrorCode OH_ContentEmbed_Storage_GetStream(ContentEmbed_Storage *parentStorage, const char *name, ContentEmbed_Stream **childStream)

Description

Obtains the child ContentEmbed_Stream object from the parent storage object and name of the OE document.

You can destroy the instance using OH_ContentEmbed_DestroyStream to avoid memory leaks.

Since: 24

Parameters:

Name Description
ContentEmbed_Storage *parentStorage Pointer to the parent storage object of the OE document.
const char *name Name of the stream object of the OE document to be obtained. The parameter cannot be an empty string. The name can contain a maximum of 31 characters and cannot contain invalid characters, such as '/', '', ':', and '!'.
ContentEmbed_Stream **childStream Output parameter. After the call succeeds, the pointer points to the found stream object of the OE document.

Returns:

Type Description
ContentEmbed_ErrorCode

A specific error code is returned:

CE_ERR_OK: The operation is successful.

CE_ERR_PARAM_INVALID: The parameter check fails.

CE_ERR_NULL_POINTER: A null pointer is returned.

CE_ERR_DEVICE_NOT_SUPPORTED: The device is not supported.

CE_ERR_STORAGE_OPERATION_FAILED: Operations related to the directory of the OE document fail.

CE_ERR_STREAM_OPERATION_FAILED: Operations related to the stream of the OE document fail.

CE_ERR_IN_DLP_SANDBOX: This operation is not supported because the application is in the DLP sandbox.

[h2]OH_ContentEmbed_Storage_DeleteEntry()

ContentEmbed_ErrorCode OH_ContentEmbed_Storage_DeleteEntry(ContentEmbed_Storage *parentStorage, const char *name)

Description

Deletes a child storage object or stream object with a specified name from the parent storage object of the OE document.

Since: 24

Parameters:

Name Description
ContentEmbed_Storage *parentStorage Pointer to the parent storage object of the OE document.
const char *name Name of the child storage object or stream object to be deleted. The parameter cannot be an empty string. The name can contain a maximum of 31 characters and cannot contain invalid characters, such as '/', '', ':', and '!'.

Returns:

Type Description
ContentEmbed_ErrorCode

The following error codes are returned:

CE_ERR_OK: The operation is successful.

CE_ERR_PARAM_INVALID: Failed to check the parameter.

CE_ERR_NULL_POINTER: A null pointer is returned.

CE_ERR_DEVICE_NOT_SUPPORTED: The device is not supported.

CE_ERR_STORAGE_OPERATION_FAILED: Operations related to the directory of the OE file failed.

CE_ERR_FILE_OPERATION_FAILED: Operations on the OE file failed.

CE_ERR_IN_DLP_SANDBOX: This operation is not supported because the application is in the DLP sandbox.

[h2]OH_ContentEmbed_Storage_DeleteAllEntry()

ContentEmbed_ErrorCode OH_ContentEmbed_Storage_DeleteAllEntry(ContentEmbed_Storage *storage)

Description

Deletes all entries from the storage object of an OpenEuler document, including the sub-storage objects and sub-stream objects.

Since: 24

Parameters:

Name Description
ContentEmbed_Storage *storage Pointer to the storage object of an OpenEuler document.

Returns:

Type Description
ContentEmbed_ErrorCode

The following error codes are returned:

CE_ERR_OK: The operation is successful.

CE_ERR_PARAM_INVALID: Failed to check the parameter.

CE_ERR_NULL_POINTER: A null pointer is returned.

CE_ERR_DEVICE_NOT_SUPPORTED: The device is not supported.

CE_ERR_STORAGE_OPERATION_FAILED: Operations related to the directory of the OE file failed.

CE_ERR_IN_DLP_SANDBOX: This operation is not supported because the application is in the DLP sandbox.

[h2]OH_ContentEmbed_DestroyStorage()

ContentEmbed_ErrorCode OH_ContentEmbed_DestroyStorage(ContentEmbed_Storage *storage)

Description

Destroys the ContentEmbed_Storage object instance of an HarmonyOS document and reclaims the memory.

Since: 24

Parameters:

Name Description
ContentEmbed_Storage *storage Pointer to the storage object of an HarmonyOS document.

Returns:

Type Description
ContentEmbed_ErrorCode

The specific error code is returned:

CE_ERR_OK: The operation is successful.

CE_ERR_PARAM_INVALID: Failed to check the parameter.

CE_ERR_DEVICE_NOT_SUPPORTED: The device is not supported.

CE_ERR_IN_DLP_SANDBOX: This operation is not supported because the application is in the DLP sandbox.

[h2]OH_ContentEmbed_Stream_Read()

ContentEmbed_ErrorCode OH_ContentEmbed_Stream_Read(ContentEmbed_Stream *stream, unsigned char **buffer, size_t length, size_t *num)

Description

Reads data of a specified length from the current position of the stream object of an HarmonyOS document to the buffer. After the data is successfully read, the offset of the stream object increases by the number of actually read bytes.

Since: 24

Parameters:

Name Description
ContentEmbed_Stream *stream Pointer to the stream object of an HarmonyOS document.
unsigned char **buffer Output parameter. Pointer to the buffer for storing the read data. The memory is allocated internally in the function. The caller needs to release the memory.
size_t length Maximum number of bytes of data to be read.
size_t *num Output parameter. Number of actually read data items, in bytes.

Returns:

Type Description
ContentEmbed_ErrorCode

The following error codes are returned:

CE_ERR_OK: The operation is successful.

CE_ERR_PARAM_INVALID: Failed to check the parameter.

CE_ERR_NULL_POINTER: A null pointer is returned.

CE_ERR_DEVICE_NOT_SUPPORTED: The device is not supported.

CE_ERR_STREAM_OPERATION_FAILED: Failed to perform the stream operation.

CE_ERR_IN_DLP_SANDBOX: This operation is not supported because the application is in the DLP sandbox.

[h2]OH_ContentEmbed_Stream_Write()

ContentEmbed_ErrorCode OH_ContentEmbed_Stream_Write(ContentEmbed_Stream *stream, const unsigned char *data, size_t length, size_t *num)

Description

Writes data of a specified length from the buffer to the current position of the stream object in the OE document. After the data is successfully written, the offset of the stream object increases by the number of actually written bytes.

Since: 24

Parameters:

Name Description
ContentEmbed_Stream *stream Pointer to the stream object in the OE document.
const unsigned char *data Input parameter. Pointer to the buffer where data is to be written.
size_t length Number of bytes of data to be written.
size_t *num Output parameter. Number of actually written data items, in bytes.

Returns:

Type Description
ContentEmbed_ErrorCode

The following error codes are returned:

CE_ERR_OK: The operation is successful.

CE_ERR_PARAM_INVALID: Failed to check the parameter.

CE_ERR_NULL_POINTER: A null pointer is returned.

CE_ERR_DEVICE_NOT_SUPPORTED: The device is not supported.

CE_ERR_STREAM_OPERATION_FAILED: The stream operation fails.

CE_ERR_IN_DLP_SANDBOX: The operation is not supported because the application is in the DLP sandbox.

[h2]OH_ContentEmbed_Stream_Seek()

ContentEmbed_ErrorCode OH_ContentEmbed_Stream_Seek(ContentEmbed_Stream *stream, size_t position)

Description

Sets the current read location of the stream object in an OE document to the specified offset.

Since: 24

Parameters:

Name Description
ContentEmbed_Stream *stream Pointer to the stream object in an OE document.
size_t position Offset of the stream object relative to the start position, in bytes. The value starts from 0.

Returns:

Type Description
ContentEmbed_ErrorCode

A specific error code is returned.

CE_ERR_OK: The operation is successful.

CE_ERR_PARAM_INVALID: Failed to check the parameter.

CE_ERR_NULL_POINTER: A null pointer is returned.

CE_ERR_DEVICE_NOT_SUPPORTED: The device is not supported.

CE_ERR_STREAM_OPERATION_FAILED: Failed to perform operations on the stream object in an OE document.

CE_ERR_IN_DLP_SANDBOX: The operation is not supported because the application is in the DLP sandbox.

[h2]OH_ContentEmbed_Stream_GetPosition()

ContentEmbed_ErrorCode OH_ContentEmbed_Stream_GetPosition(ContentEmbed_Stream *stream, size_t *position)

Description

Obtains the current position offset of the stream object in an OpenEuler document.

Since: 24

Parameters:

Name Description
ContentEmbed_Stream *stream Pointer to the stream object of the OE document.
size_t *position Output parameter. Offset of the stream object relative to the start position, in bytes. The value starts from 0.

Returns:

Type Description
ContentEmbed_ErrorCode

Returned error code:

CE_ERR_OK: The operation is successful.

CE_ERR_PARAM_INVALID: Failed to check the parameter.

CE_ERR_NULL_POINTER: A null pointer is returned.

CE_ERR_DEVICE_NOT_SUPPORTED: The device is not supported.

CE_ERR_STREAM_OPERATION_FAILED: Operations related to the stream object of the OE document failed.

CE_ERR_FILE_OPERATION_FAILED: The file operation failed.

CE_ERR_IN_DLP_SANDBOX: This operation is not supported because the application is in the DLP sandbox.

[h2]OH_ContentEmbed_Stream_GetSize()

ContentEmbed_ErrorCode OH_ContentEmbed_Stream_GetSize(ContentEmbed_Stream *stream, size_t *size)

Description

Obtains the total size of the stream object of the OE document, in bytes.

Since: 24

Parameters:

Name Description
ContentEmbed_Stream *stream Pointer to the stream object of the OE document.
size_t *size Output parameter. Total size of the stream object of the OE document, in bytes.

Returns:

Type Description
ContentEmbed_ErrorCode

Returned error code:

CE_ERR_OK: The operation is successful.

CE_ERR_PARAM_INVALID: Failed to check the parameter.

CE_ERR_NULL_POINTER: A null pointer is returned.

CE_ERR_DEVICE_NOT_SUPPORTED: The device is not supported.

CE_ERR_STREAM_OPERATION_FAILED: Operations related to the stream of the OE file failed.

CE_ERR_FILE_OPERATION_FAILED: The file operation failed.

CE_ERR_IN_DLP_SANDBOX: This operation is not supported because the application is in the DLP sandbox.

[h2]OH_ContentEmbed_DestroyStream()

ContentEmbed_ErrorCode OH_ContentEmbed_DestroyStream(ContentEmbed_Stream *stream)

Description

Destroys the ContentEmbed_Stream object instance of an OE document and reclaims the memory.

Since: 24

Parameters:

Name Description
ContentEmbed_Stream *stream Pointer to the stream object of an OE document.

Returns:

Type Description
ContentEmbed_ErrorCode

A specific error code is returned.

CE_ERR_OK: The operation is successful.

CE_ERR_PARAM_INVALID: The parameter check failed.

CE_ERR_DEVICE_NOT_SUPPORTED: The device is not supported.

CE_ERR_IN_DLP_SANDBOX: This operation is not supported because the application is in the DLP sandbox.

[h2]OH_ContentEmbed_DestroyDocument()

ContentEmbed_ErrorCode OH_ContentEmbed_DestroyDocument(ContentEmbed_Document *document)

Description

Destroys the ContentEmbed_Document object instance and reclaims the memory.

Since: 24

Parameters:

Name Description
ContentEmbed_Document *document Pointer to the OE document object.

Returns:

Type Description
ContentEmbed_ErrorCode

The following error codes are returned:

CE_ERR_OK: The operation is successful.

CE_ERR_PARAM_INVALID: The parameter check fails.

CE_ERR_DEVICE_NOT_SUPPORTED: The device is not supported.

CE_ERR_IN_DLP_SANDBOX: This operation is not supported because the application is in the DLP sandbox.

[h2]OH_ContentEmbed_Storage_GetOEid()

ContentEmbed_ErrorCode OH_ContentEmbed_Storage_GetOEid(ContentEmbed_Storage *storage, char *oeid, size_t oeidSize)

Description

Obtains the identifier (OEID) of the storage object of an OE document.

Since: 24

Parameters:

Name Description
ContentEmbed_Storage *storage Pointer to the storage object of an OE document.
char *oeid Output parameter. Character array for storing the identifier OEID. It is recommended that the array length be MAX_OEID_LENGTH.
size_t oeidSize Length of the OEID array, in bytes.

Returns:

Type Description
ContentEmbed_ErrorCode

The following error codes are returned:

CE_ERR_OK: The operation is successful.

CE_ERR_PARAM_INVALID: The parameter check fails.

CE_ERR_NULL_POINTER: A null pointer is returned.

CE_ERR_STORAGE_OPERATION_FAILED: Operations related to the directory of the OE document fail.

CE_ERR_DEVICE_NOT_SUPPORTED: The device is not supported.

CE_ERR_IN_DLP_SANDBOX: The operation is not supported because the application is in the DLP sandbox.

[h2]OH_ContentEmbed_Storage_SetOEid()

ContentEmbed_ErrorCode OH_ContentEmbed_Storage_SetOEid(ContentEmbed_Storage *storage, char *oeid, size_t oeidSize)

Description

Sets the identifier of the storage object in an OE document.

Since: 24

Parameters:

Name Description
ContentEmbed_Storage *storage Pointer to the storage object in an OE document.
char *oeid Character array of the identifier OEID to be set. It is recommended that the array length be MAX_OEID_LENGTH.
size_t oeidSize Length of the OEID array, in bytes.

Returns:

Type Description
ContentEmbed_ErrorCode

A specific error code is returned.

CE_ERR_OK: The operation is successful.

CE_ERR_PARAM_INVALID: Failed to check the parameter.

CE_ERR_NULL_POINTER: A null pointer is returned.

CE_ERR_STORAGE_OPERATION_FAILED: Failed to perform operations related to the directory of the OE document.

CE_ERR_DEVICE_NOT_SUPPORTED: The device is not supported.

CE_ERR_IN_DLP_SANDBOX: The operation is not supported because the application is in the DLP sandbox.

[h2]OH_ContentEmbed_StorageElements_Create()

ContentEmbed_ErrorCode OH_ContentEmbed_StorageElements_Create(ContentEmbed_StorageElements **storageElements)

Description

Creates and initializes a ContentEmbed_StorageElements instance.

You can destroy the instance using OH_ContentEmbed_StorageElements_Destroy to avoid memory leaks.

Since: 24

Parameters:

Name Description
ContentEmbed_StorageElements **storageElements Output parameter. After the call is successful, the pointer points to the ContentEmbed_StorageElements instance.

Returns:

Type Description
ContentEmbed_ErrorCode

The specific error code is returned.

CE_ERR_OK: The operation is successful.

CE_ERR_PARAM_INVALID: Failed to check the parameter.

CE_ERR_NULL_POINTER: A null pointer is returned.

CE_ERR_DEVICE_NOT_SUPPORTED: The device is not supported.

CE_ERR_IN_DLP_SANDBOX: This operation is not supported because the application is in the DLP sandbox.

[h2]OH_ContentEmbed_StorageElements_Destroy()

ContentEmbed_ErrorCode OH_ContentEmbed_StorageElements_Destroy(ContentEmbed_StorageElements *storageElements)

Description

Destroys a ContentEmbed_StorageElements instance and reclaims the memory occupied by it.

Since: 24

Parameters:

Name Description
ContentEmbed_StorageElements *storageElements Pointer to the ContentEmbed_StorageElements instance.

Returns:

Type Description
ContentEmbed_ErrorCode

The specific error code is returned:

CE_ERR_OK: The operation is successful.

CE_ERR_PARAM_INVALID: Failed to check the parameter.

CE_ERR_NULL_POINTER: A null pointer is returned.

CE_ERR_DEVICE_NOT_SUPPORTED: The device is not supported.

CE_ERR_IN_DLP_SANDBOX: This operation is not supported because the application is in the DLP sandbox.

[h2]OH_ContentEmbed_Storage_GetElements()

ContentEmbed_ErrorCode OH_ContentEmbed_Storage_GetElements(const ContentEmbed_Storage *storage, ContentEmbed_StorageElements *storageElements)

Description

Obtains the element list in the storage object of an OE document.

Since: 24

Parameters:

Name Description
const ContentEmbed_Storage *storage Pointer to the storage object of an OE document.
ContentEmbed_StorageElements *storageElements Element list in the storage object of an OE document.

Returns:

Type Description
ContentEmbed_ErrorCode

The following error codes are returned:

CE_ERR_OK: indicates that the operation is successful.

CE_ERR_PARAM_INVALID: indicates that the parameter check fails.

CE_ERR_NULL_POINTER: indicates that a null pointer is returned.

CE_ERR_STORAGE_OPERATION_FAILED: indicates that the operation related to the directory of the OE format file fails.

CE_ERR_DEVICE_NOT_SUPPORTED: indicates that the device is not supported.

CE_ERR_IN_DLP_SANDBOX: indicates that the operation is not supported because the application is in the DLP sandbox.

[h2]OH_ContentEmbed_StorageElements_GetCount()

ContentEmbed_ErrorCode OH_ContentEmbed_StorageElements_GetCount(const ContentEmbed_StorageElements *storageElements, size_t *count)

Description

Obtains the number of elements in a ContentEmbed_StorageElements instance.

Since: 24

Parameters:

Name Description
const ContentEmbed_StorageElements *storageElements Pointer to the ContentEmbed_StorageElements instance.
size_t *count Output parameter. Number of elements in the element set.

Returns:

Type Description
ContentEmbed_ErrorCode

The following error codes are returned:

CE_ERR_OK: indicates that the operation is successful.

CE_ERR_PARAM_INVALID: indicates that the parameter check fails.

CE_ERR_NULL_POINTER: A null pointer is returned.

CE_ERR_DEVICE_NOT_SUPPORTED: The device is not supported.

CE_ERR_IN_DLP_SANDBOX: The operation is not supported because the application is in the DLP sandbox.

[h2]OH_ContentEmbed_StorageElements_GetElement()

ContentEmbed_ErrorCode OH_ContentEmbed_StorageElements_GetElement(const ContentEmbed_StorageElements *storageElements, size_t index, ContentEmbed_StorageElement **storageElement)

Description

Obtains the element at the specified index position of the ContentEmbed_StorageElements instance.

Since: 24

Parameters:

Name Description
const ContentEmbed_StorageElements *storageElements Pointer to the ContentEmbed_StorageElements instance.
size_t index Index position of the element to be obtained, starting from 0.
ContentEmbed_StorageElement **storageElement Output parameter. Pointer to the ContentEmbed_StorageElement instance.

Returns:

Type Description
ContentEmbed_ErrorCode

A specific error code is returned.

CE_ERR_OK: The operation is successful.

CE_ERR_PARAM_INVALID: Failed to check the parameter.

CE_ERR_NULL_POINTER: A null pointer is returned.

CE_ERR_DEVICE_NOT_SUPPORTED: The device is not supported.

CE_ERR_IN_DLP_SANDBOX: This operation is not supported because the application is in the DLP sandbox.

[h2]OH_ContentEmbed_StorageElement_GetName()

ContentEmbed_ErrorCode OH_ContentEmbed_StorageElement_GetName(const ContentEmbed_StorageElement *storageElement, char *name, size_t nameSize)

Description

Obtains the name of a ContentEmbed_StorageElement instance.

Since: 24

Parameters:

Name Description
const ContentEmbed_StorageElement *storageElement Pointer to the ContentEmbed_StorageElement instance.
char *name Output parameter. Used to store the element name string.
size_t nameSize Size of the name buffer, in bytes.

Returns:

Type Description
ContentEmbed_ErrorCode

The specific error code is returned.

CE_ERR_OK: The operation is successful.

CE_ERR_PARAM_INVALID: Failed to check the parameter.

CE_ERR_NULL_POINTER: A null pointer is returned.

CE_ERR_DEVICE_NOT_SUPPORTED: The device is not supported.

CE_ERR_IN_DLP_SANDBOX: This operation is not supported because the application is in the DLP sandbox.

[h2]OH_ContentEmbed_StorageElement_GetCTime()

ContentEmbed_ErrorCode OH_ContentEmbed_StorageElement_GetCTime(const ContentEmbed_StorageElement *element, uint64_t *ctime)

Description

Obtains the creation timestamp of a ContentEmbed_StorageElement instance, in milliseconds.

Since: 24

Parameters:

Name Description
const ContentEmbed_StorageElement *element Pointer to the ContentEmbed_StorageElement instance.
uint64_t *ctime Output parameter. Pointer to the creation timestamp of the element, in milliseconds.

Returns:

Type Description
ContentEmbed_ErrorCode

A specific error code is returned.

CE_ERR_OK: The operation is successful.

CE_ERR_PARAM_INVALID: Failed to check the parameter.

CE_ERR_NULL_POINTER: The returned pointer is null.

CE_ERR_DEVICE_NOT_SUPPORTED: The device is not supported.

CE_ERR_IN_DLP_SANDBOX: This operation is not supported because the application is in the DLP sandbox.

[h2]OH_ContentEmbed_StorageElement_GetMTime()

ContentEmbed_ErrorCode OH_ContentEmbed_StorageElement_GetMTime(const ContentEmbed_StorageElement *element, uint64_t *mtime)

Description

Obtains the last modification timestamp of an ContentEmbed_StorageElement instance, in milliseconds.

Since: 24

Parameters:

Name Description
const ContentEmbed_StorageElement *element Pointer to the ContentEmbed_StorageElement instance.
uint64_t *mtime Output parameter. Pointer to the last modification timestamp of the element, in milliseconds.

Returns:

Type Description
ContentEmbed_ErrorCode

The specific error code is returned:

CE_ERR_OK: The operation is successful.

CE_ERR_PARAM_INVALID: Failed to check the parameter.

CE_ERR_NULL_POINTER: A null pointer is returned.

CE_ERR_DEVICE_NOT_SUPPORTED: The device is not supported.

CE_ERR_IN_DLP_SANDBOX: This operation is not supported because the application is in the DLP sandbox.

[h2]OH_ContentEmbed_StorageElement_IsStorage()

ContentEmbed_ErrorCode OH_ContentEmbed_StorageElement_IsStorage(const ContentEmbed_StorageElement *storageElement, bool *isStorage)

Description

Checks whether the ContentEmbed_StorageElement instance is the storage object of an OE document.

Since: 24

Parameters:

Name Description
const ContentEmbed_StorageElement *storageElement Pointer to the ContentEmbed_StorageElement instance.
bool *isStorage Output parameter. The value true indicates that the instance is an OE document storage object, and the value false indicates that it is not.

Returns:

Type Description
ContentEmbed_ErrorCode

Specific error codes are returned:

CE_ERR_OK: Operations are successful.

CE_ERR_PARAM_INVALID: Failed to check the parameter.

CE_ERR_NULL_POINTER: A null pointer is returned.

CE_ERR_DEVICE_NOT_SUPPORTED: The device is not supported.

CE_ERR_IN_DLP_SANDBOX: This operation is not supported because the application is in the DLP sandbox.

[h2]OH_ContentEmbed_StorageElement_IsStream()

ContentEmbed_ErrorCode OH_ContentEmbed_StorageElement_IsStream(const ContentEmbed_StorageElement *element, bool *isStream)

Description

Checks whether the ContentEmbed_StorageElement instance is an OE document stream object.

Since: 24

Parameters:

Name Description
const ContentEmbed_StorageElement *element Pointer to the ContentEmbed_StorageElement instance.
bool *isStream Output parameter. The value true indicates that the object is an OE document stream object, and the value false indicates that the object is not an OE document stream object.

Returns:

Type Description
ContentEmbed_ErrorCode

Specific error code:

CE_ERR_OK: Operations are successful.

CE_ERR_PARAM_INVALID: Parameter check failed.

CE_ERR_NULL_POINTER: A null pointer is returned.

CE_ERR_DEVICE_NOT_SUPPORTED: The device is not supported.

CE_ERR_IN_DLP_SANDBOX: This operation is not supported because the application is in the DLP sandbox.

[h2]OH_ContentEmbed_Storage_CopyTo()

ContentEmbed_ErrorCode OH_ContentEmbed_Storage_CopyTo(ContentEmbed_Storage *srcStorage, ContentEmbed_Storage *destStorage)

Description

Copies all sub-storage objects and stream objects from the source OE document storage object to the target OE document storage object.

Since: 24

Parameters:

Name Description
ContentEmbed_Storage *srcStorage Pointer to the source OE document storage object.
ContentEmbed_Storage *destStorage Pointer to the target OE document storage object.

Returns:

Type Description
ContentEmbed_ErrorCode

Specific error code:

CE_ERR_OK: Operations are successful.

CE_ERR_PARAM_INVALID: The parameter check fails.

CE_ERR_NULL_POINTER: A null pointer is returned.

CE_ERR_STORAGE_OPERATION_FAILED: The storage operation fails.

CE_ERR_DEVICE_NOT_SUPPORTED: The device is not supported.

CE_ERR_IN_DLP_SANDBOX: The operation is not supported because the application is in the DLP sandbox.