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 23 namespace OHOS { 24 namespace AppFileService { 25 class SandboxHelper { 26 private: 27 static std::mutex mapMutex_; 28 static bool GetSandboxPathMap(); 29 static bool GetBackupSandboxPathMap(); 30 static void* libMediaHandle_; 31 public: 32 static std::string Encode(const std::string &uri); 33 static std::string Decode(const std::string &uri); 34 static bool CheckValidPath(const std::string &filePath); 35 static int32_t GetMediaSharePath(const std::vector<std::string> &fileUris, std::vector<std::string> &physicalPaths); 36 static int32_t GetPhysicalPath(const std::string &fileUri, const std::string &userId, 37 std::string &physicalPath); 38 static int32_t GetPhysicalDir(const std::string &fileUri, const std::string &userId, std::string &physicalDir); 39 static int32_t GetBackupPhysicalPath(const std::string &fileUri, const std::string &userId, 40 std::string &physicalPath); 41 static bool IsValidPath(const std::string &path); 42 static void GetNetworkIdFromUri(const std::string &fileUri, std::string &networkId); 43 static std::string GetLowerDir(std::string &lowerPathHead, const std::string &userId, const std::string &bundleName, 44 const std::string &networkId); 45 }; 46 } // namespace AppFileService 47 } // namespace OHOS 48 49 #endif // FILEMANAGEMENT_APP_FILE_SERVICE_INTERFACES_INNERKITS_NATIVE_COMMON_INCLUDE_SANDBOX_HELPER_H