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