• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2023 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 #ifndef CLOUD_FILE_DAEMON_CLOUD_FILE_UTILS_H
16 #define CLOUD_FILE_DAEMON_CLOUD_FILE_UTILS_H
17 
18 #include <string>
19 
20 namespace OHOS {
21 namespace FileManagement {
22 namespace CloudDisk {
23 struct CloudDiskFileInfo {
24     std::string fileName;
25     std::string cloudId;
26     std::string parentCloudId;
27     uint32_t location{1};
28     unsigned long long size{0};
29     unsigned long long atime{0};
30     unsigned long long ctime{0};
31     unsigned long long mtime{0};
32     bool IsDirectory{false};
33     off_t nextOff{0};
34 };
35 
36 namespace {
37     static const std::string CLOUD_CLOUD_ID_XATTR = "user.cloud.cloudid";
38     static const std::string CLOUD_FILE_LOCATION = "user.cloud.location";
39     static const std::string HMDFS_PERMISSION_XATTR = "user.hmdfs.perm";
40 }
41 
42 class CloudFileUtils final {
43 public:
44     static bool CheckIsCloud(const std::string &key);
45     static bool CheckIsCloudLocation(const std::string &key);
46     static bool CheckIsHmdfsPermission(const std::string &key);
47     static std::string GetLocalBucketPath(std::string cloudId, std::string bundleName,
48                                           int32_t userId);
49     static std::string GetLocalFilePath(std::string cloudId, std::string bundleName,
50                                         int32_t userId);
51     static std::string GetPathWithoutTmp(const std::string &path);
52     static std::string GetCloudId(const std::string &path);
53     static bool LocalWriteOpen(const std::string &dfsPath);
54     static const std::string TMP_SUFFIX;
55 private:
56     static bool EndsWith(const std::string &fullString, const std::string &ending);
57 };
58 } // namespace CloudDisk
59 } // namespace FileManagement
60 } // namespace OHOS
61 #endif // CLOUD_FILE_DAEMON_CLOUD_FILE_UTILS_H
62