X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=NativeLauncher%2Finc%2Futils.h;h=089f78cb420316d8e88f50fb7135fd9e4eeb72a8;hb=22b013a59c4e0ad749017a3b13c0e10e73fdfd3e;hp=534be8b83b48fa2999abdccce8d373010b0fe199;hpb=639e23e19bc3cfb7833f7d8379262cc52c23bd95;p=platform%2Fcore%2Fdotnet%2Flauncher.git diff --git a/NativeLauncher/inc/utils.h b/NativeLauncher/inc/utils.h index 534be8b..089f78c 100644 --- a/NativeLauncher/inc/utils.h +++ b/NativeLauncher/inc/utils.h @@ -20,29 +20,144 @@ #include #include #include -#include +#include #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& 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& directories, std::string& tpaList); +/** + * @brief function pointer for file reader + */ typedef std::function 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__ */