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 #include "ext_backup_context.h" 17 18 #include "b_filesystem/b_file.h" 19 #include "b_resources/b_constants.h" 20 21 namespace OHOS::FileManagement::Backup { GetBackupDir()22const std::string ExtBackupContext::GetBackupDir() 23 { 24 int area = GetArea(); 25 if (area > 1) { // 1 : el2 area 26 return ""; 27 } 28 29 std::string path = std::string(BConstants::BACKUP_DIR_PRE) + std::string(BConstants::CONTEXT_ELS[area]) + 30 std::string(BConstants::BACKUP_DIR_END); 31 std::string bundleName = GetBundleName(); 32 if (BFile::EndsWith(bundleName, BConstants::BUNDLE_FILE_MANAGER) && bundleName.size() == BConstants::FM_LEN) { 33 path = std::string(BConstants::PATH_FILEMANAGE_BACKUP_HOME) + BConstants::FILE_SEPARATOR_CHAR; 34 } else if (bundleName == BConstants::BUNDLE_MEDIAL_DATA) { 35 path = std::string(BConstants::PATH_MEDIALDATA_BACKUP_HOME) + BConstants::FILE_SEPARATOR_CHAR; 36 } 37 38 return path; 39 } 40 } // namespace OHOS::FileManagement::Backup