14514f5e3Sopenharmony_ci/*
24514f5e3Sopenharmony_ci * Copyright (c) 2023 Huawei Device Co., Ltd.
34514f5e3Sopenharmony_ci * Licensed under the Apache License, Version 2.0 (the "License");
44514f5e3Sopenharmony_ci * you may not use this file except in compliance with the License.
54514f5e3Sopenharmony_ci * You may obtain a copy of the License at
64514f5e3Sopenharmony_ci *
74514f5e3Sopenharmony_ci *     http://www.apache.org/licenses/LICENSE-2.0
84514f5e3Sopenharmony_ci *
94514f5e3Sopenharmony_ci * Unless required by applicable law or agreed to in writing, software
104514f5e3Sopenharmony_ci * distributed under the License is distributed on an "AS IS" BASIS,
114514f5e3Sopenharmony_ci * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
124514f5e3Sopenharmony_ci * See the License for the specific language governing permissions and
134514f5e3Sopenharmony_ci * limitations under the License.
144514f5e3Sopenharmony_ci */
154514f5e3Sopenharmony_ci
164514f5e3Sopenharmony_ci#ifndef OHOS_ABILITY_BASE_FILE_PATH_UTILS_H
174514f5e3Sopenharmony_ci#define OHOS_ABILITY_BASE_FILE_PATH_UTILS_H
184514f5e3Sopenharmony_ci
194514f5e3Sopenharmony_ci#include <string>
204514f5e3Sopenharmony_ci#include <vector>
214514f5e3Sopenharmony_ci#include <iostream>
224514f5e3Sopenharmony_ci
234514f5e3Sopenharmony_cinamespace panda {
244514f5e3Sopenharmony_cinamespace ecmascript {
254514f5e3Sopenharmony_ci    bool StringStartWith(const std::string& str, const char* startStr, size_t startStrLen);
264514f5e3Sopenharmony_ci    bool StringEndWith(const std::string& str, const char* endStr, size_t endStrLen);
274514f5e3Sopenharmony_ci    void SplitString(const std::string& str, std::vector<std::string>& out, size_t pos = 0, const char* seps = "\\/");
284514f5e3Sopenharmony_ci    std::string JoinString(const std::vector<std::string>& strs, char sep, size_t startIndex = 0);
294514f5e3Sopenharmony_ci    std::string StripString(const std::string& str, const char* charSet = " \t\n\r");
304514f5e3Sopenharmony_ci
314514f5e3Sopenharmony_ci    void FixExtName(std::string& path);
324514f5e3Sopenharmony_ci    std::string GetInstallPath(const std::string& curJsModulePath, bool module = true);
334514f5e3Sopenharmony_ci    std::string MakeNewJsModulePath(const std::string& curJsModulePath, const std::string& newJsModuleUri);
344514f5e3Sopenharmony_ci    std::string FindNpmPackageInPath(const std::string& npmPath);
354514f5e3Sopenharmony_ci    std::string FindNpmPackageInTopLevel(
364514f5e3Sopenharmony_ci        const std::string& moduleInstallPath, const std::string& npmPackage, size_t start = 0);
374514f5e3Sopenharmony_ci    std::string FindNpmPackage(const std::string& curJsModulePath, const std::string& npmPackage);
384514f5e3Sopenharmony_ci    std::string ParseOhmUri(const std::string& originBundleName, const std::string& curJsModulePath,
394514f5e3Sopenharmony_ci        const std::string& newJsModuleUri);
404514f5e3Sopenharmony_ci    std::string NormalizeUri(
414514f5e3Sopenharmony_ci        const std::string& bundleName, const std::string& curJsModulePath, const std::string& newJsModuleUri);
424514f5e3Sopenharmony_ci    bool MakeFilePath(const std::string& codePath, const std::string& modulePath, std::string& fileName);
434514f5e3Sopenharmony_ci    std::string GetLoadPath(const std::string& hapPath);
444514f5e3Sopenharmony_ci    std::string GetRelativePath(const std::string& srcPath);
454514f5e3Sopenharmony_ci}  // namespace AbilityBase
464514f5e3Sopenharmony_ci}  // namespace OHOS
474514f5e3Sopenharmony_ci#endif  // OHOS_ABILITY_BASE_FILE_PATH_UTILS_H
48