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
23 namespace OHOS::FileManagement::Backup {
24 using namespace std;
25
GenHelpMsg()26 static string GenHelpMsg()
27 {
28 return "\tThis operation helps to check if the backup sa is available.";
29 }
30
Exec(map<string,vector<string>> & mapArgToVal)31 static int Exec(map<string, vector<string>> &mapArgToVal)
32 {
33 auto proxy = ServiceProxy::GetInstance();
34 if (!proxy) {
35 fprintf(stderr, "Get an empty backup sa proxy\n");
36 return -EFAULT;
37 }
38
39 printf("successful\n");
40 return 0;
41 }
42
43 /**
44 * @brief The hack behind is that "variable with static storage duration has initialization or a destructor with side
45 * effects; it shall not be eliminated even if it appears to be unused" -- point 2.[basic.stc.static].c++ draft
46 *
47 */
48 static bool g_autoRegHack = ToolsOp::Register(ToolsOp {ToolsOp::Descriptor {
49 .opName = {"check", "sa"},
50 .funcGenHelpMsg = GenHelpMsg,
51 .funcExec = Exec,
52 }});
53 } // namespace OHOS::FileManagement::Backup