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