1/* 2 * Copyright (c) 2023-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 FILEMANAGEMENT_APP_FILE_SERVICE_INTERFACES_INNERKITS_NATIVE_COMMON_INCLUDE_SANDBOX_HELPER_H 17#define FILEMANAGEMENT_APP_FILE_SERVICE_INTERFACES_INNERKITS_NATIVE_COMMON_INCLUDE_SANDBOX_HELPER_H 18 19#include <mutex> 20#include <string> 21#include <unordered_map> 22 23namespace OHOS { 24namespace AppFileService { 25class SandboxHelper { 26private: 27 static std::mutex mapMutex_; 28 static std::unordered_map<std::string, std::string> sandboxPathMap_; 29 static std::unordered_map<std::string, std::string> backupSandboxPathMap_; 30 static bool GetSandboxPathMap(); 31 static bool GetBackupSandboxPathMap(); 32public: 33 static std::string Encode(const std::string &uri); 34 static std::string Decode(const std::string &uri); 35 static bool CheckValidPath(const std::string &filePath); 36 static int32_t GetPhysicalPath(const std::string &fileUri, const std::string &userId, 37 std::string &physicalPath); 38 static int32_t GetBackupPhysicalPath(const std::string &fileUri, const std::string &userId, 39 std::string &physicalPath); 40 static bool IsValidPath(const std::string &path); 41}; 42} // namespace AppFileService 43} // namespace OHOS 44 45#endif // FILEMANAGEMENT_APP_FILE_SERVICE_INTERFACES_INNERKITS_NATIVE_COMMON_INCLUDE_SANDBOX_HELPER_H