2 * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
4 * Licensed under the Apache License, Version 2.0 (the License);
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an AS IS BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
24 #include <launcher_env.h>
26 #ifndef PATH_SEPARATOR
27 #define PATH_SEPARATOR '/'
31 * @brief get current executable path
32 * return std::string path
34 std::string readSelfPath();
37 * @brief concat path with PATH_SEPARATOR
38 * @param[in] destination path
39 * @param[in] source path
40 * return std::string result path
42 std::string concatPath(const std::string& path1, const std::string& path2);
45 * @brief get absolute Path
46 * @param[in] source path
47 * return std::string result path
49 std::string absolutePath(const std::string& path);
52 * @brief get the directory of file
53 * @param[in] source path
54 * return std::string result path
56 std::string baseName(const std::string& path);
59 * @brief split path with ":" delimiter and put that in the vector
60 * @param[in] source path
61 * @param[out] string vector
63 void splitPath(const std::string& path, std::vector<std::string>& out);
66 * @brief check file is exist
67 * @param[in] source path
70 bool isFileExist(const std::string& path);
73 * @brief check the file is managed assembly or not.
74 * @param[in] file path
75 * @return return true when the file is managed assembly.
76 * otherwise return false including native image case.
78 bool isManagedAssembly(const std::string& filePath);
81 * @brief check the file is native image or not.
82 * @param[in] file path
83 * @return return true when the file is native image.
85 bool isNativeImage(const std::string& filePath);
88 * @brief find assembly files in the directories
89 * @param[in] directories
90 * @param[out] ":" seperated assembly path list
92 void assembliesInDirectory(const std::vector<std::string>& directories, std::string& tpaList);
95 * @brief function pointer for file reader
97 typedef std::function<void (const std::string&, const char*)> FileReader;
100 * @brief scan files in the given directory and run file reader function for that
101 * @param[in] directory
102 * @param[in] file reader function
103 * @param[in] scan depth
105 void scanFilesInDir(const std::string& directory, FileReader reader, unsigned int depth);
107 #endif /* __UTILS_H__ */