Merge branch 'tizen' of https://github.sec.samsung.net/j-h-choi/dotnet-launcher into...
[platform/core/dotnet/launcher.git] / NativeLauncher / inc / utils.h
index 79e8489..bb72e00 100644 (file)
@@ -20,6 +20,7 @@
 #include <string>
 #include <vector>
 #include <functional>
+#include <boost/filesystem.hpp>
 
 #include <launcher_env.h>
 
 #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)
+};
+
+bool cmdOptionExists(char** begin, char** end, const std::string& option);
+
 /**
  * @brief get current executable path
  * return std::string path
@@ -56,6 +70,13 @@ std::string absolutePath(const std::string& path);
 std::string baseName(const std::string& path);
 
 /**
+ * @brief get root path
+ * @param[in] package id
+ * @param[out] root path
+ */
+int getRootPath(std::string pkgId, std::string& rootPath);
+
+/**
  * @brief split path with ":" delimiter and put that in the vector
  * @param[in] source path
  * @param[out] string vector
@@ -104,4 +125,50 @@ typedef std::function<void (const std::string&, const char*)> FileReader;
  */
 void scanFilesInDir(const std::string& directory, FileReader reader, unsigned int depth);
 
+/**
+ * @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__ */