Initialize Tizen 2.3
[framework/web/wrt-commons.git] / modules_mobile / 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.8
19  * @author      Janusz Majnert <j.majnert@samsung.com>
20  * @brief       Common utility functions
21  */
22
23 #ifndef _WRT_UTILITY_H_
24 #define _WRT_UTILITY_H_
25
26 #include <sys/stat.h>
27
28 /**
29  * Joins two paths into one
30  *
31  * @param[out] joined  String for storing joined paths
32  * @param[in] parent   String containing the first part of path
33  * @param[in] child    String containing the second part of the path
34  *
35  * Data stored in joined before the function call will be replaced with joined
36  * paths.
37  */
38 void WrtUtilJoinPaths(std::string &joined,
39                       const std::string &parent,
40                       const std::string &child);
41
42 /**
43  * Creates directories specified by path
44  *
45  * @param[in]  path    Path to create
46  * @param[in]  mode    access flags, default to 0755
47  * @return    true on success, false on failure
48  *
49  * Function creates directory specified by path argument and all directories
50  * leading up to it, if they don't exist. Note that if yout wish to create
51  * several nested directories, you must make sure that the mode flag allows you
52  * to write and search the direcotries you create.
53  */
54 bool WrtUtilMakeDir(const std::string &newpath, mode_t mode = 0755);
55
56 /**
57  * This function removes the directory or file pointed to by path
58  *
59  * @param[in] path  Path to the file/directory to be deleted
60  *
61  * @return true on success, false otherwise
62  */
63 bool WrtUtilRemove(const std::string &path);
64
65 /**
66  * Checks if path exists and is a regular file
67  *
68  * @param[in] path   the string representing path to check
69  *
70  * @return true if regular file is accessible under path, false otherwise
71  */
72 bool WrtUtilFileExists(const std::string &path);
73
74 /**
75  * Checks if path exists and is a directory
76  *
77  * @param[in] path   the string representing path to check
78  *
79  * @return true if directory is accessible under path, false otherwise
80  */
81 bool WrtUtilDirExists(const std::string &path);
82
83 #endif //_WRT_UTILITY_H_
84