oh_cloud_disk_manager.h
Overview
This file defines the APIs for the cloud disk management module.
File to include: <filemanagement/clouddiskmanager/oh_cloud_disk_manager.h>
Library: libohclouddiskmanager.so
System capability: SystemCapability.FileManagement.CloudDiskManager
Since: 21
Related module: CloudDisk
Summary
Structs
| Name | typedef Keyword | Description |
|---|---|---|
| CloudDisk_PathInfo | CloudDisk_PathInfo/CloudDisk_FileIdInfo/CloudDisk_SyncFolderPath | CloudDisk_PathInfo: a struct that encapsulates the file path information. CloudDisk_FileIdInfo: a struct that encapsulates the file ID. CloudDisk_SyncFolderPath: a struct that encapsulates the sync root path. |
| CloudDisk_FileSyncState | CloudDisk_FileSyncState | A struct that encapsulates the file sync state. |
| CloudDisk_ChangeData | CloudDisk_ChangeData | A struct that encapsulates the event data generated when a single file under the sync root path is changed. It includes the file's unique ID, the parent directory's unique ID, relative path, change type, file size, and timestamp. |
| CloudDisk_ChangesResult | CloudDisk_ChangesResult | A struct that encapsulates the file change result under the sync root path. It includes the next change sequence number, end flag, and an array of change data items. |
| CloudDisk_FailedList | CloudDisk_FailedList | A struct that encapsulates the list of files that failed to synchronize. It includes the file path information and the specific error cause. |
| CloudDisk_ResultList | CloudDisk_ResultList | A struct that encapsulates the file sync result. It includes the absolute path of the file, sync result, and sync state or failure cause. |
| CloudDisk_DisplayNameInfo | CloudDisk_DisplayNameInfo | A struct that encapsulates the display name of the sync root path. |
| CloudDisk_SyncFolder | CloudDisk_SyncFolder | A struct that encapsulates the sync root property information. |
Enums
| Name | typedef Keyword | Description |
|---|---|---|
| CloudDisk_SyncState | CloudDisk_SyncState | Enumerates the file sync states. |
| CloudDisk_OperationType | CloudDisk_OperationType | Enumerates the file change types. |
| CloudDisk_ErrorReason | CloudDisk_ErrorReason | Enumerates the file sync failure causes. |
| CloudDisk_SyncFolderState | CloudDisk_SyncFolderState | Enumerates the sync root path states. |
Function
Enum Description
CloudDisk_SyncState
enum CloudDisk_SyncState
Description
Enumerates the file sync states.
Since: 21
| Value | Description |
|---|---|
| IDLE = 0 | The file is idle, and no sync operation is performed. |
| SYNCING = 1 | The file is being synced. |
| SYNC_SUCCEEDED = 2 | The file is synced successfully. |
| SYNC_FAILED = 3 | The file fails to be synced. |
| SYNC_CANCELED = 4 | The file sync is canceled. |
| SYNC_CONFLICTED = 5 | The file sync conflicts. |
CloudDisk_OperationType
enum CloudDisk_OperationType
Description
Enumerates the file change types.
Since: 21
| Value | Description |
|---|---|
| CREATE = 0 | Create a file or directory. |
| DELETE = 1 | Delete a file or directory. |
| MOVE_FROM = 2 | Move this file or directory. |
| MOVE_TO = 3 | Move to this file or directory. |
| CLOSE_WRITE = 4 | Close the file after the write operation. |
| SYNC_FOLDER_INVALID = 5 | Invalid sync root path. |
CloudDisk_ErrorReason
enum CloudDisk_ErrorReason
Description
Enumerates the file sync failure causes.
Since: 21
| Value | Description |
|---|---|
| INVALID_ARGUMENT = 0 | The input parameter is invalid. |
| NO_SUCH_FILE = 1 | The file or directory does not exist. |
| NO_SPACE_LEFT = 2 | The remaining space on the device is insufficient. |
| OUT_OF_RANGE = 3 | The file is not in the sync root path. |
| NO_SYNC_STATE = 4 | The sync state is not set. |
CloudDisk_SyncFolderState
enum CloudDisk_SyncFolderState
Description
Enumerates the sync root path states.
Since: 21
| Value | Description |
|---|---|
| INACTIVE = 0 | The sync root path is inactive. |
| ACTIVE = 1 | The sync root path is active. |
Function Description
OH_CloudDisk_RegisterSyncFolderChanges()
CloudDisk_ErrorCode OH_CloudDisk_RegisterSyncFolderChanges(const CloudDisk_SyncFolderPath syncFolderPath, void (*callback)(const CloudDisk_SyncFolderPath syncFolderPath, const CloudDisk_ChangeData changeDatas[], size_t bufferLength))
Description
Registers a callback to obtain file changes in the sync root path.
Since: 21
Parameters
| Name | Description |
|---|---|
| const CloudDisk_SyncFolderPath syncFolderPath | Sync root path. For details, see CloudDisk_PathInfo. |
| callback | Registered callback. |
Returns
| Type | Description |
|---|---|
| CloudDisk_ErrorCode | Returns CLOUD_DISK_OK if the API is called successfully; returns CloudDisk_ErrorCode otherwise. |
OH_CloudDisk_UnregisterSyncFolderChanges()
CloudDisk_ErrorCode OH_CloudDisk_UnregisterSyncFolderChanges(const CloudDisk_SyncFolderPath syncFolderPath)
Description
Unregisters the callback for file changes in the sync root path.
Since: 21
Parameters
| Name | Description |
|---|---|
| const CloudDisk_SyncFolderPath syncFolderPath | Sync root path. For details, see CloudDisk_PathInfo. |
Returns
| Type | Description |
|---|---|
| CloudDisk_ErrorCode | Returns CLOUD_DISK_OK if the API is called successfully; returns CloudDisk_ErrorCode otherwise. |
OH_CloudDisk_GetSyncFolderChanges()
CloudDisk_ErrorCode OH_CloudDisk_GetSyncFolderChanges(const CloudDisk_SyncFolderPath syncFolderPath, uint64_t startUsn, size_t count, CloudDisk_ChangesResult **changesResult)
Description
Obtains the change history in the sync root path.
Since: 21
Parameters
| Name | Description |
|---|---|
| const CloudDisk_SyncFolderPath syncFolderPath | Sync root path. For details, see CloudDisk_PathInfo. |
| uint64_t startUsn | Start change sequence number. The value range is [0, 2^64 – 1]. |
| size_t count | Number of file changes. The value range is [1, 100]. |
| CloudDisk_ChangesResult **changesResult | File change result. For details, see CloudDisk_ChangesResult. |
Returns
| Type | Description |
|---|---|
| CloudDisk_ErrorCode | Returns CLOUD_DISK_OK if the API is called successfully; returns CloudDisk_ErrorCode otherwise. |
OH_CloudDisk_SetFileSyncStates()
CloudDisk_ErrorCode OH_CloudDisk_SetFileSyncStates(const CloudDisk_SyncFolderPath syncFolderPath, const CloudDisk_FileSyncState fileSyncStates[], size_t bufferLength, CloudDisk_FailedList **failedLists, size_t *failedCount)
Description
Sets the file sync state in the sync root path.
Since: 21
Parameters
| Name | Description |
|---|---|
| const CloudDisk_SyncFolderPath syncFolderPath | Sync root path. For details, see CloudDisk_PathInfo. |
| const CloudDisk_FileSyncState fileSyncStates[] | CloudDisk_FileSyncState array of the file path and its target sync state. |
| size_t bufferLength | Length of the sync state array to be set. The value range is [1, 100]. |
| CloudDisk_FailedList **failedLists | Double pointer to the CloudDisk_FailedList array that contains files whose sync states failed to be set. |
| size_t *failedCount | Pointer to the length of the file list array whose sync states failed to be set. |
Returns
| Type | Description |
|---|---|
| CloudDisk_ErrorCode | Returns CLOUD_DISK_OK if the API is called successfully; returns CloudDisk_ErrorCode otherwise. |
OH_CloudDisk_GetFileSyncStates()
CloudDisk_ErrorCode OH_CloudDisk_GetFileSyncStates(const CloudDisk_SyncFolderPath syncFolderPath, const CloudDisk_PathInfo paths[], size_t bufferLength, CloudDisk_ResultList **resultLists, size_t *resultCount)
Description
Obtains the file sync state in the sync root path.
Since: 21
Parameters
| Name | Description |
|---|---|
| const CloudDisk_SyncFolderPath syncFolderPath | Sync root path. For details, see CloudDisk_PathInfo. |
| const CloudDisk_PathInfo paths[] | CloudDisk_PathInfo array of the sync state. |
| size_t bufferLength | Length of the sync state array. The value range is [1, 100]. |
| CloudDisk_ResultList **resultLists | Double pointer to the file sync result. For details, see CloudDisk_ResultList. |
| size_t *resultCount | Pointer to the number of files that fail to be synchronized. |
Returns
| Type | Description |
|---|---|
| CloudDisk_ErrorCode | Returns CLOUD_DISK_OK if the API is called successfully; returns CloudDisk_ErrorCode otherwise. |
OH_CloudDisk_RegisterSyncFolder()
CloudDisk_ErrorCode OH_CloudDisk_RegisterSyncFolder(const CloudDisk_SyncFolder *syncFolder)
Description
Registers a sync root.
Since: 21
Parameters
| Name | Description |
|---|---|
| const CloudDisk_SyncFolder *syncFolder | Sync root path to be registered. For details, see CloudDisk_SyncFolder. |
Returns
| Type | Description |
|---|---|
| CloudDisk_ErrorCode | Returns CLOUD_DISK_OK if the API is called successfully; returns CloudDisk_ErrorCode otherwise. |
OH_CloudDisk_UnregisterSyncFolder()
CloudDisk_ErrorCode OH_CloudDisk_UnregisterSyncFolder(const CloudDisk_SyncFolderPath syncFolderPath)
Description
Unregisters the sync root.
Since: 21
Parameters
| Name | Description |
|---|---|
| const CloudDisk_SyncFolderPath syncFolderPath | Sync root path. For details, see CloudDisk_PathInfo. |
Returns
| Type | Description |
|---|---|
| CloudDisk_ErrorCode | Returns CLOUD_DISK_OK if the API is called successfully; returns CloudDisk_ErrorCode otherwise. |
OH_CloudDisk_ActiveSyncFolder()
CloudDisk_ErrorCode OH_CloudDisk_ActiveSyncFolder(const CloudDisk_SyncFolderPath syncFolderPath)
Description
Activates the sync root.
Since: 21
Parameters
| Name | Description |
|---|---|
| const CloudDisk_SyncFolderPath syncFolderPath | Sync root path. For details, see CloudDisk_PathInfo. |
Returns
| Type | Description |
|---|---|
| CloudDisk_ErrorCode | Returns CLOUD_DISK_OK if the API is called successfully; returns CloudDisk_ErrorCode otherwise. |
OH_CloudDisk_DeactiveSyncFolder()
CloudDisk_ErrorCode OH_CloudDisk_DeactiveSyncFolder(const CloudDisk_SyncFolderPath syncFolderPath)
Description
Deactivates the sync root.
Since: 21
Parameters
| Name | Description |
|---|---|
| const CloudDisk_SyncFolderPath syncFolderPath | Sync root path. For details, see CloudDisk_PathInfo. |
Returns
| Type | Description |
|---|---|
| CloudDisk_ErrorCode | Returns CLOUD_DISK_OK if the API is called successfully; returns CloudDisk_ErrorCode otherwise. |
OH_CloudDisk_GetSyncFolders()
CloudDisk_ErrorCode OH_CloudDisk_GetSyncFolders(CloudDisk_SyncFolder **syncFolders, size_t *count)
Description
Obtains all sync roots.
Since: 21
Parameters
| Name | Description |
|---|---|
| CloudDisk_SyncFolder **syncFolders | Double pointer to the sync root path array CloudDisk_SyncFolder. |
| size_t *count | Pointer to the number of sync roots registered by the current cloud disk. |
Returns
| Type | Description |
|---|---|
| CloudDisk_ErrorCode | Returns CLOUD_DISK_OK if the API is called successfully; returns CloudDisk_ErrorCode otherwise. |
OH_CloudDisk_UpdateCustomAlias()
CloudDisk_ErrorCode OH_CloudDisk_UpdateCustomAlias(const CloudDisk_SyncFolderPath syncFolderPath, const char *customAlias, size_t customAliasLength)
Description
Updates the sync root alias.
Since: 21
Parameters
| Name | Description |
|---|---|
| const CloudDisk_SyncFolderPath syncFolderPath | Sync root path. For details, see CloudDisk_PathInfo. |
| const char *customAlias | Pointer to the custom alias, which cannot contain the following characters: \/*?<>|:". Additionally, the full name cannot be composed solely of spaces, a single dot (.), or two consecutive dots (..). |
| size_t customAliasLength | Length of the custom alias. Value range: [0, 255]. |
Returns
| Type | Description |
|---|---|
| CloudDisk_ErrorCode | Returns CLOUD_DISK_OK if the API is called successfully; returns CloudDisk_ErrorCode otherwise. |
你可能感兴趣的鸿蒙文章
openharmony 鸿蒙 js-apis-file-environment-sys
openharmony 鸿蒙 js-apis-file-fs
openharmony 鸿蒙 capi-clouddisk-clouddisk-pathinfo
openharmony 鸿蒙 capi-clouddisk-clouddisk-changesresult
openharmony 鸿蒙 capi-clouddisk-clouddisk-syncfolder
openharmony 鸿蒙 js-apis-fileShare
openharmony 鸿蒙 js-apis-file-storage-statistics-sys