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 Janusz Majnert <j.majnert@samsung.com>
20 * @brief Common utility functions
23 #ifndef _WRT_UTILITY_H_
24 #define _WRT_UTILITY_H_
27 #include <dpl/availability.h>
30 * Joins two paths into one
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
36 * Data stored in joined before the function call will be replaced with joined
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");
45 * Creates directories specified by path
47 * @param[in] path Path to create
48 * @param[in] mode access flags, default to 0755
49 * @return true on success, false on failure
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.
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");
60 * This function removes the directory or file pointed to by path
62 * @param[in] path Path to the file/directory to be deleted
64 * @return true on success, false otherwise
66 bool WrtUtilRemove(const std::string &path) DPL_DEPRECATED_WITH_MESSAGE("Use boost::filesystem::remove_all instead");
69 * Checks if path exists and is a regular file
71 * @param[in] path the string representing path to check
73 * @return true if regular file is accessible under path, false otherwise
75 bool WrtUtilFileExists(const std::string &path) DPL_DEPRECATED_WITH_MESSAGE("Use boost::filesystem::exists() instead");
78 * Checks if path exists and is a directory
80 * @param[in] path the string representing path to check
82 * @return true if directory is accessible under path, false otherwise
84 bool WrtUtilDirExists(const std::string &path) DPL_DEPRECATED_WITH_MESSAGE("Use boost::filesystem::exists() instead");
86 #endif //_WRT_UTILITY_H_