• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2022 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 #include "adaptor_file.h"
17 #include <stddef.h>
18 #include "adaptor_log.h"
19 #include "file_operator.h"
20 
IsFileOperatorValid(const FileOperator * fileOperator)21 bool IsFileOperatorValid(const FileOperator *fileOperator)
22 {
23     if (fileOperator == NULL) {
24         LOG_ERROR("get null file operator");
25         return false;
26     }
27     if (fileOperator->isFileExist == NULL) {
28         LOG_ERROR("get null exist file operator");
29         return false;
30     }
31     if (fileOperator->getFileLen == NULL) {
32         LOG_ERROR("get null size file operator");
33         return false;
34     }
35     if (fileOperator->readFile == NULL) {
36         LOG_ERROR("get null read file operator");
37         return false;
38     }
39     if (fileOperator->writeFile == NULL) {
40         LOG_ERROR("get null write file operator");
41         return false;
42     }
43     if (fileOperator->deleteFile == NULL) {
44         LOG_ERROR("get null delete file operator");
45         return false;
46     }
47     return true;
48 }
49 
GetFileOperator(const FileOperatorType type)50 FileOperator *GetFileOperator(const FileOperatorType type)
51 {
52     if (type == DEFAULT_FILE_OPERATOR) {
53         LOG_INFO("Get default file operator");
54         return GetDefaultFileOperator();
55     }
56     return NULL;
57 }
58 
59