1 /* 2 * Copyright (c) 2024 Huawei Device Co., Ltd. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15 16 #ifndef OHOS_CLOUD_DISK_SERVICE_NOTIFY_UTILS_H 17 #define OHOS_CLOUD_DISK_SERVICE_NOTIFY_UTILS_H 18 19 #include <list> 20 #include <unordered_map> 21 22 #include "clouddisk_db_const.h" 23 #include "clouddisk_notify_const.h" 24 25 namespace OHOS::FileManagement::CloudDisk { 26 using namespace std; 27 class CloudDiskNotifyUtils final { 28 public: 29 using FindCloudDiskInodeFunc = std::function<std::shared_ptr<CloudDiskInode>(CloudDiskFuseData*, int64_t)>; 30 /* cloud disk */ 31 static int32_t GetNotifyData(CloudDiskFuseData* data, FindCloudDiskInodeFunc func, const fuse_ino_t &ino, 32 NotifyData ¬ifyData); 33 static int32_t GetNotifyData(CloudDiskFuseData* data, FindCloudDiskInodeFunc func, const fuse_ino_t &parent, 34 const string &name, 35 NotifyData ¬ifyData); 36 static int32_t GetNotifyData(CloudDiskFuseData* data, FindCloudDiskInodeFunc func, 37 shared_ptr<CloudDiskInode> inoPtr, NotifyData ¬ifyData); 38 static int32_t GetNotifyData(CloudDiskFuseData* data, FindCloudDiskInodeFunc func, 39 shared_ptr<CloudDiskInode> inoPtr, const string &name, NotifyData ¬ifyData); 40 /* cloud disk syncer */ 41 static int32_t GetCacheNode(const string &cloudId, CacheNode &cacheNode); 42 static void PutCacheNode(const string &cloudId, const CacheNode &cacheNode); 43 static int32_t 44 GetUriFromCache(const string &bundleName, const string &rootId, const CacheNode &cacheNode, string &uri); 45 private: 46 static const int32_t maxCacheCnt_ = 50; 47 static list<pair<string, CacheNode>> cacheList_; 48 static unordered_map<string, list<pair<string, CacheNode>>::iterator> cacheMap_; 49 static mutex cacheMutex_; 50 static string rootId_; 51 }; 52 } // namespace OHOS::FileManagement::CloudDisk 53 54 #endif // OHOS_CLOUD_DISK_SERVICE_NOTIFY_UTILS_H