Update wrt-commons_0.2.53
[framework/web/wrt-commons.git] / modules / utils / include / dpl / utils / wrt_utility.h
1 /*
2  * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
3  *
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
7  *
8  *        http://www.apache.org/licenses/LICENSE-2.0
9  *
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.
15  */
16 /**
17  * @file    wrt_utility.h
18  * @version    0.6
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
22  */
23
24 #ifndef _WRT_UTILITY_H_
25 #define _WRT_UTILITY_H_
26
27 #include <stdbool.h>
28
29 #ifdef __cplusplus
30 extern "C"
31 {
32 #endif
33
34 #ifndef MAX_WIDGET_PATH_LENGTH
35 #define MAX_WIDGET_PATH_LENGTH    1024
36 #endif
37
38 /**
39  * File options
40  */
41 enum
42 {
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
48 };
49
50 /**
51  * Combine the parentPath and fileName into a new absolute file name.
52  *
53  * @param[out]    absolutePath
54  * @param[in]    parentPath
55  * @param[in]    fileName
56  *
57  * @return    if success, return true; or return false.
58  */
59 bool _WrtUtilSetAbsolutePath(char* absolutePath,
60         const char* parentPath,
61         const char* fileName);
62
63 /**
64  * Change the string to bool value,no case sensitive, e.x., "true" or "1" to ture; "False" or "0" to false.
65  *
66  * @param[in]    value
67  * @param[out]    result
68  *
69  * @return    if success, return true; or return false.
70  */
71 // KW bool _WrtUtilConvertStrToBool(char* value, bool *result);
72
73 /**
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.
76  *
77  * @param[in]    fullPath
78  * @param[out]    dirName
79  * @param[out]    fileName
80  *
81  * @return
82  */
83 void _WrtUtilGetDirAndFileName(const char* fullPath,
84         char** dirName,
85         char** fileName);
86
87 #if 0
88 /**
89  * Change the provided string into lower case, caller should allocate the memory of source and dest.
90  *
91  * @param[in] source    the source string to be changed
92  * @param[out] dest    the dest string with lower case
93  *
94  * return        if success, return true, or return false.
95  */
96 bool _WrtUtilStringToLower(const char* source,
97         char* dest);
98 #endif
99
100 /**
101  * Compare two string, no case sensitive.
102  *
103  * @param[in] srcStr
104  * @param[in] destStr
105  *
106  * return        return true if the two strings are identical, or return false.
107  */
108 // KW bool _WrtUtilStringCmp(const char* srcStr, const char* destStr);
109
110 /**
111  * This function is used to make a directory.
112  * it's neccessary to free the returned dir path.
113  *
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.
118  *
119  * @return    TRUE on success or FALSE on failure.
120  */
121 bool _WrtMakeDir (const char *path,
122         long mode,
123         int flags);
124
125 /**
126  * This function is used to change to specified directory.
127  * If the directory does not exist, it will create it directly.
128  *
129  * @param[in]  path    Specified the directory path
130  *
131  * @return    TRUE on success or FALSE on failure.
132  */
133 bool _WrtUtilChangeDir(const char* path);
134
135 /**
136  * This function is used to remove a directory from the file system.
137  *
138  * @param[in]  path    Specified the directory path
139  *
140  * @return    TRUE on success or FALSE on failure.
141  */
142 bool _WrtUtilRemoveDir(const char* path);
143
144 // KW /**
145 // KW  * This function is used to make a temp directory in root directory.
146 // KW  *
147 // KW  * @param[in]  root    Specified the root directory
148 // KW  *
149 // KW  * @return    if fails, return NULL, else return the temp path.
150 // KW  * it's necessary to free the returned memory space.
151 // KW  */
152 // KW char* _WrtUtilMakeTempDir(const char* root);
153
154 /**
155  * This function is used to convert a string to lowercase.
156  *
157  * @param[in]  str            the string need to be converted.
158  * @param[in]  lowerStr    the converted string.
159  *
160  * @return    TRUE on success or FALSE on failure.
161  */
162 bool _WrtUtilStringToLower(const char* str,
163         char** lowerStr);
164
165 #ifdef __cplusplus
166 }
167 #endif
168
169 #endif //_WRT_UTILITY_H_
170