2 * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
19 * @author Wei Dong(d.wei@samsung.com)
20 * @author Ma Quan(jason.ma@samsung.com)
21 * @brief Header file of widget manager common functions
24 #ifndef _WRT_UTILITY_H_
25 #define _WRT_UTILITY_H_
34 #ifndef MAX_WIDGET_PATH_LENGTH
35 #define MAX_WIDGET_PATH_LENGTH 1024
43 WRT_FILEUTILS_PRESERVE_STATUS = 1,
44 WRT_FILEUTILS_PRESERVE_SYMLINKS = 2,
45 WRT_FILEUTILS_RECUR = 4,
46 WRT_FILEUTILS_FORCE = 8,
47 WRT_FILEUTILS_INTERACTIVE = 16
51 * Combine the parentPath and fileName into a new absolute file name.
53 * @param[out] absolutePath
54 * @param[in] parentPath
57 * @return if success, return true; or return false.
59 bool _WrtUtilSetAbsolutePath(char* absolutePath,
60 const char* parentPath,
61 const char* fileName);
64 * Change the string to bool value,no case sensitive, e.x., "true" or "1" to ture; "False" or "0" to false.
69 * @return if success, return true; or return false.
71 // KW bool _WrtUtilConvertStrToBool(char* value, bool *result);
74 * Get the dir path and file name from the full path. e.x., "/opt/lib/filename" as fullPath, "/opt/lib/" as dirName, "filename" as fileName.
75 * it's necessary to free *dirName or *fileName if either of them is not NULL.
79 * @param[out] fileName
83 void _WrtUtilGetDirAndFileName(const char* fullPath,
89 * Change the provided string into lower case, caller should allocate the memory of source and dest.
91 * @param[in] source the source string to be changed
92 * @param[out] dest the dest string with lower case
94 * return if success, return true, or return false.
96 bool _WrtUtilStringToLower(const char* source,
101 * Compare two string, no case sensitive.
106 * return return true if the two strings are identical, or return false.
108 // KW bool _WrtUtilStringCmp(const char* srcStr, const char* destStr);
111 * This function is used to make a directory.
112 * it's neccessary to free the returned dir path.
114 * @param[in] path Specified the directory path
115 * @param[in] mode Operation mode the you want to set
116 * @param[in] flags WRT_FILEUTILS_RECUR if you want to make parent's directory recusively,
117 * WRT_FILEUTILS_NONE if not.
119 * @return TRUE on success or FALSE on failure.
121 bool _WrtMakeDir (const char *path,
126 * This function is used to change to specified directory.
127 * If the directory does not exist, it will create it directly.
129 * @param[in] path Specified the directory path
131 * @return TRUE on success or FALSE on failure.
133 bool _WrtUtilChangeDir(const char* path);
136 * This function is used to remove a directory from the file system.
138 * @param[in] path Specified the directory path
140 * @return TRUE on success or FALSE on failure.
142 bool _WrtUtilRemoveDir(const char* path);
145 // KW * This function is used to make a temp directory in root directory.
147 // KW * @param[in] root Specified the root directory
149 // KW * @return if fails, return NULL, else return the temp path.
150 // KW * it's necessary to free the returned memory space.
152 // KW char* _WrtUtilMakeTempDir(const char* root);
155 * This function is used to convert a string to lowercase.
157 * @param[in] str the string need to be converted.
158 * @param[in] lowerStr the converted string.
160 * @return TRUE on success or FALSE on failure.
162 bool _WrtUtilStringToLower(const char* str,
169 #endif //_WRT_UTILITY_H_