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_
29 * Joins two paths into one
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
35 * Data stored in joined before the function call will be replaced with joined
38 void WrtUtilJoinPaths(std::string &joined, const std::string &parent, const std::string &child);
41 * Creates directories specified by path
43 * @param[in] path Path to create
44 * @param[in] mode access flags, default to 0755
45 * @return true on success, false on failure
47 * Function creates directory specified by path argument and all directories
48 * leading up to it, if they don't exist. Note that if yout wish to create
49 * several nested directories, you must make sure that the mode flag allows you
50 * to write and search the direcotries you create.
52 bool WrtUtilMakeDir(const std::string &newpath, mode_t mode=0755);
55 * This function removes the directory or file pointed to by path
57 * @param[in] path Path to the file/directory to be deleted
59 * @return true on success, false otherwise
61 bool WrtUtilRemove(const std::string &path);
64 * Checks if path exists and is a regular file
66 * @param[in] path the string representing path to check
68 * @return true if regular file is accessible under path, false otherwise
70 bool WrtUtilFileExists(const std::string &path);
73 * Checks if path exists and is a directory
75 * @param[in] path the string representing path to check
77 * @return true if directory is accessible under path, false otherwise
79 bool WrtUtilDirExists(const std::string &path);
81 #endif //_WRT_UTILITY_H_