Add comments for added function in utils.h
[platform/core/dotnet/launcher.git] / NativeLauncher / inc / utils.h
index 534be8b..089f78c 100644 (file)
 #include <string>
 #include <vector>
 #include <functional>
-#include <map>
+#include <boost/filesystem.hpp>
 
 #ifndef PATH_SEPARATOR
 #define PATH_SEPARATOR '/'
 #endif
 
+namespace bf = boost::filesystem;
+namespace bs = boost::system;
+
+enum FSFlag : int {
+  FS_NONE              = 0,
+  FS_MERGE_SKIP        = (1 << 0),
+  FS_MERGE_OVERWRITE   = (1 << 1),
+  FS_COMMIT_COPY_FILE  = (1 << 2),
+  FS_PRESERVE_OWNERSHIP_AND_PERMISSIONS = (1 << 3)
+};
+
+/**
+ * @brief get current executable path
+ * return std::string path
+ */
 std::string readSelfPath();
 
+/**
+ * @brief concat path with PATH_SEPARATOR
+ * @param[in] destination path
+ * @param[in] source path
+ * return std::string result path
+ */
 std::string concatPath(const std::string& path1, const std::string& path2);
+
+/**
+ * @brief get absolute Path
+ * @param[in] source path
+ * return std::string result path
+ */
 std::string absolutePath(const std::string& path);
+
+/**
+ * @brief get the directory of file
+ * @param[in] source path
+ * return std::string result path
+ */
 std::string baseName(const std::string& path);
+
+/**
+ * @brief split path with ":" delimiter and put that in the vector
+ * @param[in] source path
+ * @param[out] string vector
+ */
 void splitPath(const std::string& path, std::vector<std::string>& out);
-void appendPath(std::string& path1, const std::string& path2);
 
+/**
+ * @brief check file is exist
+ * @param[in] source path
+ * @return bool
+ */
 bool isFileExist(const std::string& path);
 
-bool isManagedAssembly(const std::string& fileName);
-bool isNativeImage(const std::string& fileName);
+/**
+ * @brief check the file is managed assembly or not.
+ * @param[in] file path
+ * @return return true when the file is managed assembly.
+ *         otherwise return false including native image case.
+ */
+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 find assembly files in the directories
+ * @param[in] directories
+ * @param[out] ":" seperated assembly path list
+ */
 void assembliesInDirectory(const std::vector<std::string>& directories, std::string& tpaList);
 
+/**
+ * @brief function pointer for file reader
+ */
 typedef std::function<void (const std::string&, const char*)> FileReader;
+
+/**
+ * @brief scan files in the given directory and run file reader function for that
+ * @param[in] directory
+ * @param[in] file reader function
+ * @param[in] scan depth
+ */
 void scanFilesInDir(const std::string& directory, FileReader reader, unsigned int depth);
 
-int runLoggingThread();
+/**
+ * @brief create the new directory.
+ * @param[in] source path
+ * @return return true when the directory was created.
+ */
+bool createDir(const bf::path& path);
+
+/**
+ * @brief copy the directory.
+ * @param[in] path to the source directory
+ * @param[in] path to the target directory
+ * @param[in] filesystem flag
+ * @return return true when the directory was copied.
+ */
+bool copyDir(const bf::path& path1, const bf::path& path2, FSFlag flags = FS_NONE);
+
+/**
+ * @brief copy the file.
+ * @param[in] path to the source file
+ * @param[in] path to the target file
+ * @return return true when the file was copied.
+ */
+bool copyFile(const bf::path& path1, const bf::path& path2);
+
+/**
+ * @brief moves of renames the file or directory.
+ * @param[in] path to the source file
+ * @param[in] path to the target file
+ * @return return true when the file was moved.
+ */
+bool moveFile(const bf::path& path1, const bf::path& path2);
+
+/**
+ * @brief removes the file or empty directory.
+ * @param[in] source path
+ * @return return true when the file was deleted.
+ */
+bool removeFile(const bf::path& path);
+
+/**
+ * @brief removes the file or directory and all its contents.
+ * @param[in] source path
+ * @return return true when the file or directory was deleted.
+ */
+bool removeAll(const bf::path& path);
+
 #endif /* __UTILS_H__ */