X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=NativeLauncher%2Finc%2Futils.h;h=1c930eeb78a660f9e0e719b154172fdaa06b32a8;hb=f9c1d06d8924b0a9a4897cf968e930f167603013;hp=b5c11b8c3555f1c99a1f1df75477b85b5ab9f95a;hpb=a53235f961a791766fc33f4db4594bf5f927cec9;p=platform%2Fcore%2Fdotnet%2Flauncher.git diff --git a/NativeLauncher/inc/utils.h b/NativeLauncher/inc/utils.h index b5c11b8..1c930ee 100644 --- a/NativeLauncher/inc/utils.h +++ b/NativeLauncher/inc/utils.h @@ -40,20 +40,6 @@ enum FSFlag : int { }; /** - * @brief an iterator to the begin element in the range that compares equal to option - * @param[in] begin element - * @param[in] end elment - * return return true when elements match - */ -bool cmdOptionExists(char** begin, char** end, const std::string& option); - -/** - * @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 @@ -62,49 +48,56 @@ std::string readSelfPath(); std::string concatPath(const std::string& path1, const std::string& path2); /** - * @brief get absolute Path + * @brief get canonicalized absolute Path * @param[in] source path * return std::string result path */ -std::string absolutePath(const std::string& path); +std::string getAbsolutePath(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); +std::string getBaseName(const std::string& path); /** * @brief replaces all matching substrings of the regular expression with a given replacement * @param[in] original string * @param[in] pattern to match * @param[in] replacement string - * return the modified string + * return std::string the modified string */ -std::string replaceAll(const std::string &str, const std::string &pattern, const std::string &replace); +std::string replaceAll(const std::string& str, const std::string& pattern, const std::string& replace); /** * @brief get root path * @param[in] package id - * @param[out] root path + * return std::string root path */ -int getRootPath(std::string pkgId, std::string& rootPath); +std::string getRootPath(const std::string& pkgId); /** * @brief get exec name * @param[in] package id - * @param[out] exec name + * return std::string exec name */ -int getExecName(std::string pkgId, std::string& execName); +std::string getExecName(const std::string& pkgId); + +/** + * @brief get app type + * @param[in] package id + * return std::string app type + */ +std::string getAppType(const std::string& pkgId); /** * @brief get metadata value * @param[in] package id * @param[in] metadata key - * @param[out] metadata value + * return std::string metadata value */ -int getMetadataValue(std::string pkgId, std::string metadataKey, std::string& metadataValue); +std::string getMetadataValue(const std::string& pkgId, const std::string& key); /** * @brief split path with ":" delimiter and put that in the vector @@ -114,18 +107,18 @@ int getMetadataValue(std::string pkgId, std::string metadataKey, std::string& me void splitPath(const std::string& path, std::vector& out); /** - * @brief check file is exist + * @brief check file exists * @param[in] source path * @return bool */ -bool isFileExist(const std::string& path); +bool isFile(const std::string& path); /** - * @brief get file size + * @brief check directory exists * @param[in] source path - * @return size of file + * @return bool */ -uintptr_t getFileSize(const std::string& path); +bool isDirectory(const std::string& path); /** * @brief check the file is managed assembly or not. @@ -143,24 +136,28 @@ bool isManagedAssembly(const std::string& filePath); bool isNativeImage(const std::string& filePath); /** - * @brief find assembly files in the directories - * @param[in] directories - * @param[out] ":" seperated assembly path list + * @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. + * @param[in] directories list of directories + * @param[out] list colon-separated string of assembly paths */ -void assembliesInDirectory(const std::vector& directories, std::string& tpaList); +void addAssembliesFromDirectories(const std::vector& directories, std::string& list); /** - * @brief function pointer for file reader + * @brief File search callback + * @param[in] path full path to a resolved file + * @param[in] filename file name */ -typedef std::function FileReader; +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 + * @brief Scan all files in the given directory. + * @param[in] directory path to a root directory + * @param[in] reader callback for iteration + * @param[in] depth recursive search depth */ -void scanFilesInDir(const std::string& directory, FileReader reader, unsigned int depth); +void scanFilesInDirectory(const std::string& directory, FileReader reader, unsigned int depth); /** * @brief copy smack and ownership. @@ -220,13 +217,14 @@ bool removeAll(const bf::path& path); * @brief change command name of the current process for access via ps command * @param[in] name */ -void setCmdName(const char* name); +void setCmdName(const std::string& name); /** - * @brief get file name from the path - * @param[in] file path - * @return return file name if exist otherwise null. + * @brief Get the file name from the specified path. + * @remark An empty string will be returned if the path string ends with a path separator character. + * @param[in] path path to a file + * @return a substring after the path separator character */ -char* getFileNameFromPath(char* path); +std::string getFileName(const std::string& path); #endif /* __UTILS_H__ */