• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 #include "base_interface_lib_mock.h"
16 
17 namespace OHOS {
18 namespace FileManagement {
GetDentryfileByPath(uint32_t userId,const string & path,bool caseSense)19 string GetDentryfileByPath(uint32_t userId, const string &path, bool caseSense)
20 {
21     if (BaseInterfaceLib::baseInterfaceLib_ == nullptr) {
22         if (path == "") {
23             caseSense = true;
24             return "";
25         }
26         caseSense = false;
27         return "";
28     }
29 
30     return BaseInterfaceLib::baseInterfaceLib_->GetDentryfileByPath(userId, path, caseSense);
31 }
32 
GetDentryfileName(const std::string & path,bool caseSense)33 string GetDentryfileName(const std::string &path, bool caseSense)
34 {
35     if (BaseInterfaceLib::baseInterfaceLib_ == nullptr) {
36         return "";
37     }
38 
39     return BaseInterfaceLib::baseInterfaceLib_->GetDentryfileName(path, caseSense);
40 }
41 
GetOverallBucket(uint32_t level)42 uint32_t GetOverallBucket(uint32_t level)
43 {
44     if (BaseInterfaceLib::baseInterfaceLib_ == nullptr) {
45         if (level >= MAX_BUCKET_LEVEL) {
46             return E_SUCCESS;
47         }
48         return E_SUCCESS;
49     }
50 
51     return BaseInterfaceLib::baseInterfaceLib_->GetOverallBucket(level);
52 }
53 
GetBucketaddr(uint32_t level,uint32_t buckoffset)54 uint32_t GetBucketaddr(uint32_t level, uint32_t buckoffset)
55 {
56     if (BaseInterfaceLib::baseInterfaceLib_ == nullptr) {
57         if (level >= MAX_BUCKET_LEVEL) {
58             return E_SUCCESS;
59         }
60 
61         uint64_t curLevelMaxBucks = level;
62         if (buckoffset >= curLevelMaxBucks) {
63             return E_FAIL;
64         }
65 
66         return MAX_BUCKET_LEVEL;
67     }
68 
69     return BaseInterfaceLib::baseInterfaceLib_->GetBucketaddr(level, buckoffset);
70 }
71 
GetBucketByLevel(uint32_t level)72 uint32_t GetBucketByLevel(uint32_t level)
73 {
74     if (BaseInterfaceLib::baseInterfaceLib_ == nullptr) {
75         if (level >= MAX_BUCKET_LEVEL) {
76             return E_SUCCESS;
77         } else {
78             return MAX_BUCKET_LEVEL;
79         }
80     }
81 
82     return BaseInterfaceLib::baseInterfaceLib_->GetBucketByLevel(level);
83 }
84 
RoomForFilename(const uint8_t bitmap[],size_t slots,uint32_t maxSlots)85 uint32_t RoomForFilename(const uint8_t bitmap[], size_t slots, uint32_t maxSlots)
86 {
87     if (BaseInterfaceLib::baseInterfaceLib_ == nullptr) {
88         if (maxSlots == E_SUCCESS) {
89             return E_SUCCESS;
90         } else {
91             return MAX_BUCKET_LEVEL;
92         }
93     }
94 
95     return BaseInterfaceLib::baseInterfaceLib_->RoomForFilename(bitmap, slots, maxSlots);
96 }
97 
FindNextZeroBit(const uint8_t addr[],uint32_t maxSlots,uint32_t start)98 uint32_t FindNextZeroBit(const uint8_t addr[], uint32_t maxSlots, uint32_t start)
99 {
100     if (BaseInterfaceLib::baseInterfaceLib_ == nullptr) {
101         if (maxSlots == DENTRY_PER_GROUP) {
102             return DENTRY_PER_GROUP;
103         } else {
104             return MAX_BUCKET_LEVEL;
105         }
106     }
107 
108     return BaseInterfaceLib::baseInterfaceLib_->FindNextZeroBit(addr, maxSlots, start);
109 }
110 
FindNextBit(const uint8_t addr[],uint32_t maxSlots,uint32_t start)111 uint32_t FindNextBit(const uint8_t addr[], uint32_t maxSlots, uint32_t start)
112 {
113     if (BaseInterfaceLib::baseInterfaceLib_ == nullptr) {
114         if (maxSlots == DENTRY_PER_GROUP) {
115             return DENTRY_PER_GROUP;
116         } else {
117             return MAX_BUCKET_LEVEL;
118         }
119     }
120 
121     return BaseInterfaceLib::baseInterfaceLib_->FindNextBit(addr, maxSlots, start);
122 }
123 
DoLookup(MetaBase & base)124 int32_t DoLookup(MetaBase &base)
125 {
126     return E_SUCCESS;
127 }
128 
DoCreate(const MetaBase & base)129 int32_t DoCreate(const MetaBase &base)
130 {
131     return E_SUCCESS;
132 }
133 
DoLookupAndRemove(MetaBase & metaBase)134 int32_t DoLookupAndRemove(MetaBase &metaBase)
135 {
136     return E_SUCCESS;
137 }
138 } // FileManagement
139 } // OHOS