openharmony 鸿蒙 capi-oh-cloud-disk-manager-h

2026-08-25 浏览 (1)

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

Nametypedef KeywordDescription
CloudDisk_PathInfoCloudDisk_PathInfo/CloudDisk_FileIdInfo/CloudDisk_SyncFolderPathCloudDisk_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_FileSyncStateCloudDisk_FileSyncStateA struct that encapsulates the file sync state.
CloudDisk_ChangeDataCloudDisk_ChangeDataA 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_ChangesResultCloudDisk_ChangesResultA 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_FailedListCloudDisk_FailedListA struct that encapsulates the list of files that failed to synchronize. It includes the file path information and the specific error cause.
CloudDisk_ResultListCloudDisk_ResultListA struct that encapsulates the file sync result. It includes the absolute path of the file, sync result, and sync state or failure cause.
CloudDisk_DisplayNameInfoCloudDisk_DisplayNameInfoA struct that encapsulates the display name of the sync root path.
CloudDisk_SyncFolderCloudDisk_SyncFolderA struct that encapsulates the sync root property information.

Enums

Nametypedef KeywordDescription
CloudDisk_SyncStateCloudDisk_SyncStateEnumerates the file sync states.
CloudDisk_OperationTypeCloudDisk_OperationTypeEnumerates the file change types.
CloudDisk_ErrorReasonCloudDisk_ErrorReasonEnumerates the file sync failure causes.
CloudDisk_SyncFolderStateCloudDisk_SyncFolderStateEnumerates the sync root path states.

Function

NameDescription
CloudDisk_ErrorCode OH_CloudDisk_RegisterSyncFolderChanges(const CloudDisk_SyncFolderPath syncFolderPath, void (*callback)(const CloudDisk_SyncFolderPath syncFolderPath, const CloudDisk_ChangeData changeDatas[], size_t bufferLength))Registers a callback to obtain file changes in the sync root path.
CloudDisk_ErrorCode OH_CloudDisk_UnregisterSyncFolderChanges(const CloudDisk_SyncFolderPath syncFolderPath)Unregisters the callback for file changes in the sync root path.
CloudDisk_ErrorCode OH_CloudDisk_GetSyncFolderChanges(const CloudDisk_SyncFolderPath syncFolderPath, uint64_t startUsn, size_t count, CloudDisk_ChangesResult **changesResult)Obtains the change history in the sync root path.
CloudDisk_ErrorCode OH_CloudDisk_SetFileSyncStates(const CloudDisk_SyncFolderPath syncFolderPath, const CloudDisk_FileSyncState fileSyncStates[], size_t bufferLength, CloudDisk_FailedList **failedLists, size_t *failedCount)Sets the file sync state in the sync root path.
CloudDisk_ErrorCode OH_CloudDisk_GetFileSyncStates(const CloudDisk_SyncFolderPath syncFolderPath, const CloudDisk_PathInfo paths[], size_t bufferLength, CloudDisk_ResultList **resultLists, size_t *resultCount)Obtains the file sync state in the sync root path.
CloudDisk_ErrorCode OH_CloudDisk_RegisterSyncFolder(const CloudDisk_SyncFolder *syncFolder)Registers a sync root.
CloudDisk_ErrorCode OH_CloudDisk_UnregisterSyncFolder(const CloudDisk_SyncFolderPath syncFolderPath)Unregisters the sync root.
CloudDisk_ErrorCode OH_CloudDisk_ActiveSyncFolder(const CloudDisk_SyncFolderPath syncFolderPath)Activates the sync root.
CloudDisk_ErrorCode OH_CloudDisk_DeactiveSyncFolder(const CloudDisk_SyncFolderPath syncFolderPath)Deactivates the sync root.
CloudDisk_ErrorCode OH_CloudDisk_GetSyncFolders(CloudDisk_SyncFolder **syncFolders, size_t *count)Obtains all sync roots.
CloudDisk_ErrorCode OH_CloudDisk_UpdateCustomAlias(const CloudDisk_SyncFolderPath syncFolderPath, const char *customAlias, size_t customAliasLength)Updates the sync root alias.

Enum Description

CloudDisk_SyncState

enum CloudDisk_SyncState

Description

Enumerates the file sync states.

Since: 21

ValueDescription
IDLE = 0The file is idle, and no sync operation is performed.
SYNCING = 1The file is being synced.
SYNC_SUCCEEDED = 2The file is synced successfully.
SYNC_FAILED = 3The file fails to be synced.
SYNC_CANCELED = 4The file sync is canceled.
SYNC_CONFLICTED = 5The file sync conflicts.

CloudDisk_OperationType

enum CloudDisk_OperationType

Description

Enumerates the file change types.

Since: 21

ValueDescription
CREATE = 0Create a file or directory.
DELETE = 1Delete a file or directory.
MOVE_FROM = 2Move this file or directory.
MOVE_TO = 3Move to this file or directory.
CLOSE_WRITE = 4Close the file after the write operation.
SYNC_FOLDER_INVALID = 5Invalid sync root path.

CloudDisk_ErrorReason

enum CloudDisk_ErrorReason

Description

Enumerates the file sync failure causes.

Since: 21

ValueDescription
INVALID_ARGUMENT = 0The input parameter is invalid.
NO_SUCH_FILE = 1The file or directory does not exist.
NO_SPACE_LEFT = 2The remaining space on the device is insufficient.
OUT_OF_RANGE = 3The file is not in the sync root path.
NO_SYNC_STATE = 4The sync state is not set.

CloudDisk_SyncFolderState

enum CloudDisk_SyncFolderState

Description

Enumerates the sync root path states.

Since: 21

ValueDescription
INACTIVE = 0The sync root path is inactive.
ACTIVE = 1The 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

NameDescription
const CloudDisk_SyncFolderPath syncFolderPathSync root path. For details, see CloudDisk_PathInfo.
callbackRegistered callback.

Returns

TypeDescription
CloudDisk_ErrorCodeReturns 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

NameDescription
const CloudDisk_SyncFolderPath syncFolderPathSync root path. For details, see CloudDisk_PathInfo.

Returns

TypeDescription
CloudDisk_ErrorCodeReturns 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

NameDescription
const CloudDisk_SyncFolderPath syncFolderPathSync root path. For details, see CloudDisk_PathInfo.
uint64_t startUsnStart change sequence number. The value range is [0, 2^64 – 1].
size_t countNumber of file changes. The value range is [1, 100].
CloudDisk_ChangesResult **changesResultFile change result. For details, see CloudDisk_ChangesResult.

Returns

TypeDescription
CloudDisk_ErrorCodeReturns 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

NameDescription
const CloudDisk_SyncFolderPath syncFolderPathSync 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 bufferLengthLength of the sync state array to be set. The value range is [1, 100].
CloudDisk_FailedList **failedListsDouble pointer to the CloudDisk_FailedList array that contains files whose sync states failed to be set.
size_t *failedCountPointer to the length of the file list array whose sync states failed to be set.

Returns

TypeDescription
CloudDisk_ErrorCodeReturns 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

NameDescription
const CloudDisk_SyncFolderPath syncFolderPathSync root path. For details, see CloudDisk_PathInfo.
const CloudDisk_PathInfo paths[]CloudDisk_PathInfo array of the sync state.
size_t bufferLengthLength of the sync state array. The value range is [1, 100].
CloudDisk_ResultList **resultListsDouble pointer to the file sync result. For details, see CloudDisk_ResultList.
size_t *resultCountPointer to the number of files that fail to be synchronized.

Returns

TypeDescription
CloudDisk_ErrorCodeReturns 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

NameDescription
const CloudDisk_SyncFolder *syncFolderSync root path to be registered. For details, see CloudDisk_SyncFolder.

Returns

TypeDescription
CloudDisk_ErrorCodeReturns 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

NameDescription
const CloudDisk_SyncFolderPath syncFolderPathSync root path. For details, see CloudDisk_PathInfo.

Returns

TypeDescription
CloudDisk_ErrorCodeReturns 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

NameDescription
const CloudDisk_SyncFolderPath syncFolderPathSync root path. For details, see CloudDisk_PathInfo.

Returns

TypeDescription
CloudDisk_ErrorCodeReturns 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

NameDescription
const CloudDisk_SyncFolderPath syncFolderPathSync root path. For details, see CloudDisk_PathInfo.

Returns

TypeDescription
CloudDisk_ErrorCodeReturns 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

NameDescription
CloudDisk_SyncFolder **syncFoldersDouble pointer to the sync root path array CloudDisk_SyncFolder.
size_t *countPointer to the number of sync roots registered by the current cloud disk.

Returns

TypeDescription
CloudDisk_ErrorCodeReturns 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

NameDescription
const CloudDisk_SyncFolderPath syncFolderPathSync root path. For details, see CloudDisk_PathInfo.
const char *customAliasPointer 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 customAliasLengthLength of the custom alias. Value range: [0, 255].

Returns

TypeDescription
CloudDisk_ErrorCodeReturns 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 鸿蒙 capi-fileio

openharmony 鸿蒙 js-apis-file-storage-statistics-sys

openharmony 鸿蒙 js-apis-file-cloudsyncmanager

openharmony 鸿蒙 js-apis-file-environment

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