[Refactoring] Code cleanup and remove duplicate methods
[platform/core/dotnet/launcher.git] / NativeLauncher / inc / utils.h
index a6b1d2d..524264e 100644 (file)
@@ -17,6 +17,7 @@
 #ifndef __UTILS_H__
 #define __UTILS_H__
 
+#include <algorithm>
 #include <string>
 #include <vector>
 #include <functional>
 
 #include <launcher_env.h>
 
+#include <sys/prctl.h>
+
 #ifndef PATH_SEPARATOR
 #define PATH_SEPARATOR '/'
 #endif
 
+#ifndef PROFILE_BASENAME
+#define PROFILE_BASENAME ".__tizen_specific_profile_data"
+#endif
+
 namespace bf = boost::filesystem;
 namespace bs = boost::system;
 
@@ -40,6 +47,10 @@ enum FSFlag : int {
   FS_PRESERVE_OWNERSHIP_AND_PERMISSIONS = (1 << 3)
 };
 
+#ifndef PR_TASK_PERF_USER_TRACE
+#define PR_TASK_PERF_USER_TRACE 666
+#endif
+
 /**
  * @brief concat path with PATH_SEPARATOR
  * @param[in] destination path
@@ -110,11 +121,11 @@ std::string getMetadataValue(const std::string& pkgId, const std::string& key);
 std::string changeExtension(const std::string& path, const std::string& from, const std::string& to);
 
 /**
- * @brief check the package is 'readonly' or not
- * @param[in] package id
+ * @brief check the path is 'readonly' or not
+ * @param[in] path
  * @return bool package readonly value
  */
-bool isReadOnlyApp(const std::string& pkgId);
+bool isReadOnlyArea(const std::string& path);
 
 /**
  * @brief split path with ":" delimiter and put that in the vector
@@ -132,6 +143,13 @@ void splitPath(const std::string& path, std::vector<std::string>& out);
 bool isFile(const std::string& path);
 
 /**
+ * @brief check symlink file
+ * @param[in] source path
+ * @return bool
+ */
+bool isSymlinkFile(const std::string& path);
+
+/**
  * @brief check directory exists
  * @param[in] source path
  * @return bool
@@ -147,13 +165,6 @@ bool isDirectory(const std::string& path);
 bool isManagedAssembly(const std::string& filePath);
 
 /**
- * @brief check the file is native image or not.
- * @param[in] file path
- * @return return true when the file is native image.
- */
-bool isNativeImage(const std::string& filePath);
-
-/**
  * @brief Resolve assembly files from directories and append their paths to the given list.
  * @remark If a native image exists for an assembly in the same directory, it will be used.
  *         If multiple assemblies of the same name exist, the first one will be used.
@@ -289,4 +300,23 @@ int pkgmgrMDFilterForeach(pkgmgrinfo_appinfo_metadata_filter_h handle,
                                         pkgmgrinfo_app_list_cb app_cb,
                                         void *user_data);
 
+/**
+ * @brief Prints HW Clock log
+ * @param[in] format `printf`-like format string
+ * @param[in] ... `printf`-like variadic list of arguments corresponding to the format string
+ */
+void printHWClockLog(const char* format, ...);
+
+/**
+ * @brief Return NCDB startup hook
+ * @return NCDB startup hook
+ */
+const char* getNCDBStartupHook();
+
+/**
+ * @brief Check is NCDB startup hook provided in DOTNET_STARTUP_HOOKS env
+ * @return `true` if provided, otherwise `false`
+ */
+bool isNCDBStartupHookProvided();
+
 #endif /* __UTILS_H__ */