Initialize Tizen 2.3
[framework/web/wrt-commons.git] / modules_mobile / utils / include / dpl / utils / file_utils.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    file_utils.h
18  * @author  Bartosz Janiak (b.janiak@samsung.com)
19  * @author  Zbigniew Kostrzewa (z.kostrzewa@samsung.com)
20  * @version 1.0
21  */
22
23 #ifndef FILEUTILS_H
24 #define FILEUTILS_H
25
26 #include <sys/types.h>
27 #include <string>
28
29 #include <dpl/string.h>
30 #include <dpl/exception.h>
31
32 namespace FileUtils {
33 DECLARE_EXCEPTION_TYPE(DPL::Exception, CreateDirectoryException)
34 DECLARE_EXCEPTION_TYPE(DPL::Exception, RemoveDirectoryException)
35
36 bool FileExists(const DPL::String& absolutePath);
37 bool DirectoryExists(const DPL::String& absolutePath);
38
39 /**
40  * Creates specified path recursively.
41  * @param path Path to create (e.g. /tmp/dir1/dir2).
42  * @param mode Mode for the non-existing parts of the path (e.g. 0755).
43  * @throw DPL::CommonException::::InternalError If sth bad happens.
44  */
45 void MakePath(const std::string& path, mode_t mode);
46
47 /**
48  * Removes specified directory recursively.
49  * @param path Full path to directory to remove.
50  * @throw FileUtils::DirectoryRemoveException If an error occured.
51  */
52 void RemoveDir(const std::string& path);
53 } // namespace FileUtils
54
55 #endif