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 #ifndef PATH_SEPARATOR
25 #define PATH_SEPARATOR '/'
29 * @brief get current executable path
30 * return std::string path
32 std::string readSelfPath();
35 * @brief concat path with PATH_SEPARATOR
36 * @param[in] destination path
37 * @param[in] source path
38 * return std::string result path
40 std::string concatPath(const std::string& path1, const std::string& path2);
43 * @brief get absolute Path
44 * @param[in] source path
45 * return std::string result path
47 std::string absolutePath(const std::string& path);
50 * @brief get the directory of file
51 * @param[in] source path
52 * return std::string result path
54 std::string baseName(const std::string& path);
57 * @brief split path with ":" delimiter and put that in the vector
58 * @param[in] source path
59 * @param[out] string vector
61 void splitPath(const std::string& path, std::vector<std::string>& out);
64 * @brief check file is exist
65 * @param[in] source path
68 bool isFileExist(const std::string& path);
71 * @brief check the file is managed assembly or not.
72 * @param[in] file path
73 * @return return true when the file is managed assembly.
74 * otherwise return false including native image case.
76 bool isManagedAssembly(const std::string& filePath);
79 * @brief check the file is native image or not.
80 * @param[in] file path
81 * @return return true when the file is native image.
83 bool isNativeImage(const std::string& filePath);
86 * @brief find assembly files in the directories
87 * @param[in] directories
88 * @param[out] ":" seperated assembly path list
90 void assembliesInDirectory(const std::vector<std::string>& directories, std::string& tpaList);
93 * @brief function pointer for file reader
95 typedef std::function<void (const std::string&, const char*)> FileReader;
98 * @brief scan files in the given directory and run file reader function for that
99 * @param[in] directory
100 * @param[in] file reader function
101 * @param[in] scan depth
103 void scanFilesInDir(const std::string& directory, FileReader reader, unsigned int depth);
106 * @brief start logging thread to bypass stderr and stdout to dlog
107 * @return return 0 when success, otherwise return negative value.
109 int runLoggingThread();
110 #endif /* __UTILS_H__ */