1 /* 2 * Copyright (c) 2022 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 OHOS_ABILITY_BASE_FILE_PATH_UTILS_H 17 #define OHOS_ABILITY_BASE_FILE_PATH_UTILS_H 18 19 #include <string> 20 21 namespace OHOS { 22 namespace AbilityBase { 23 bool StringStartWith(const std::string& str, const char* startStr, size_t startStrLen); 24 bool StringEndWith(const std::string& str, const char* endStr, size_t endStrLen); 25 void SplitString(const std::string& str, std::vector<std::string>& out, size_t pos = 0, const char* seps = "\\/"); 26 std::string JoinString(const std::vector<std::string>& strs, char sep, size_t startIndex = 0); 27 std::string StripString(const std::string& str, const char* charSet = " \t\n\r"); 28 29 void FixExtName(std::string& path); 30 std::string GetInstallPath(const std::string& curJsModulePath, bool module = true); 31 std::string MakeNewJsModulePath(const std::string& curJsModulePath, const std::string& newJsModuleUri); 32 std::string FindNpmPackageInPath(const std::string& npmPath); 33 std::string FindNpmPackageInTopLevel( 34 const std::string& moduleInstallPath, const std::string& npmPackage, size_t start = 0); 35 std::string FindNpmPackage(const std::string& curJsModulePath, const std::string& npmPackage); 36 std::string ParseOhmUri(const std::string& originBundleName, const std::string& curJsModulePath, 37 const std::string& newJsModuleUri); 38 std::string NormalizeUri( 39 const std::string& bundleName, const std::string& curJsModulePath, const std::string& newJsModuleUri); 40 bool MakeFilePath(const std::string& codePath, const std::string& modulePath, std::string& fileName); 41 std::string GetLoadPath(const std::string& hapPath); 42 std::string GetRelativePath(const std::string& srcPath); 43 } // namespace AbilityBase 44 } // namespace OHOS 45 #endif // OHOS_ABILITY_BASE_FILE_PATH_UTILS_H 46