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 
16 #ifndef FOUNDATION_APPEXECFWK_SERVICES_BUNDLEMGR_INCLUDE_INNER_BUNDLE_CLONE_COMMON_H
17 #define FOUNDATION_APPEXECFWK_SERVICES_BUNDLEMGR_INCLUDE_INNER_BUNDLE_CLONE_COMMON_H
18 
19 #include <string>
20 #include "bundle_constants.h"
21 
22 namespace OHOS {
23 namespace AppExecFwk {
24 namespace {
25 constexpr const char* CLONE_DIR_PATH_PREFIX = "clone";
26 constexpr const char* PLUS_SIGN = "+";
27 constexpr const char* MINUS_SIGN = "-";
28 }
29 
30 class BundleCloneCommonHelper {
31 public:
GetCloneDataDir(const std::string &bundleName, const int32_t appIndex)32     static std::string GetCloneDataDir(const std::string &bundleName, const int32_t appIndex)
33     {
34         return std::string(PLUS_SIGN) + CLONE_DIR_PATH_PREFIX +
35             MINUS_SIGN + std::to_string(appIndex) + PLUS_SIGN + bundleName;
36     }
37 
GetCloneBundleIdKey(const std::string &bundleName, const int32_t appIndex)38     static std::string GetCloneBundleIdKey(const std::string &bundleName, const int32_t appIndex)
39     {
40         return std::to_string(appIndex) + CLONE_DIR_PATH_PREFIX + Constants::FILE_UNDERLINE + bundleName;
41     }
42 };
43 } // namespace AppExecFwk
44 } // namespace OHOS
45 #endif // FOUNDATION_APPEXECFWK_SERVICES_BUNDLEMGR_INCLUDE_INNER_BUNDLE_CLONE_COMMON_H