1 /*
2  * Copyright (c) 2022-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 
16 #include <iostream>
17 #include <sstream>
18 
19 #include "errors.h"
20 #include "service_proxy.h"
21 #include "tools_op.h"
22 #include "tools_op_check_sa.h"
23 
24 namespace OHOS::FileManagement::Backup {
25 using namespace std;
26 
GenHelpMsg()27 static string GenHelpMsg()
28 {
29     return "\tThis operation helps to check if the backup sa is available.";
30 }
31 
Exec(map<string,vector<string>> & mapArgToVal)32 static int Exec(map<string, vector<string>> &mapArgToVal)
33 {
34     auto proxy = ServiceProxy::GetInstance();
35     if (!proxy) {
36         fprintf(stderr, "Get an empty backup sa proxy\n");
37         return -EFAULT;
38     }
39 
40     printf("successful\n");
41     return 0;
42 }
43 
44 
CheckSaRegister()45 bool CheckSaRegister()
46 {
47     return ToolsOp::Register(ToolsOp{ ToolsOp::Descriptor {
48         .opName = {"check", "sa"},
49         .funcGenHelpMsg = GenHelpMsg,
50         .funcExec = Exec,
51     } });
52 }
53 } // namespace OHOS::FileManagement::Backup