2 Copyright (C) 2012-2023 Carl Hetherington <cth@carlh.net>
4 This file is part of libdcp.
6 libdcp is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2 of the License, or
9 (at your option) any later version.
11 libdcp is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with libdcp. If not, see <http://www.gnu.org/licenses/>.
19 In addition, as a special exception, the copyright holders give
20 permission to link the code of portions of this program with the
21 OpenSSL library under certain conditions as described in each
22 individual source file, and distribute linked combinations
25 You must obey the GNU General Public License in all respects
26 for all of the code used other than OpenSSL. If you modify
27 file(s) with this exception, you may extend this exception to your
28 version of the file(s), but you are not obligated to do so. If you
29 do not wish to do so, delete this exception statement from your
30 version. If you delete this exception statement from all source
31 files in the program, then also delete it here.
35 #ifndef LIBDCP_FILESYSTEM_H
36 #define LIBDCP_FILESYSTEM_H
39 #include <boost/filesystem.hpp>
47 boost::filesystem::path absolute(boost::filesystem::path const& path);
48 boost::filesystem::path canonical(boost::filesystem::path const& path);
49 boost::filesystem::path weakly_canonical(boost::filesystem::path const& path);
50 boost::filesystem::path change_extension(boost::filesystem::path const& from, std::string const& new_extension);
51 void copy(boost::filesystem::path const& from, boost::filesystem::path const& to);
52 void copy_file(boost::filesystem::path const& from, boost::filesystem::path const& to);
53 void copy_file(boost::filesystem::path const& from, boost::filesystem::path const& to, boost::system::error_code& ec);
54 void copy_file(boost::filesystem::path const& from, boost::filesystem::path const& to, boost::filesystem::copy_option ec);
55 bool create_directory(boost::filesystem::path const& path);
56 bool create_directory(boost::filesystem::path const& path, boost::system::error_code& ec);
57 bool create_directories(boost::filesystem::path const& path);
58 bool create_directories(boost::filesystem::path const& path, boost::system::error_code& ec);
59 void create_hard_link(boost::filesystem::path const& from, boost::filesystem::path const& to);
60 void create_hard_link(boost::filesystem::path const& from, boost::filesystem::path const& to, boost::system::error_code& ec);
61 void create_symlink(boost::filesystem::path const& from, boost::filesystem::path const& to, boost::system::error_code& ec);
62 void current_path(boost::filesystem::path const& path);
63 boost::filesystem::path current_path();
64 bool exists(boost::filesystem::path const& path);
65 bool exists(boost::filesystem::path const& path, boost::system::error_code& ec);
66 std::string extension(boost::filesystem::path const& path);
67 bool is_directory(boost::filesystem::path const& path);
68 bool is_empty(boost::filesystem::path const& path);
69 bool is_regular_file(boost::filesystem::path const& path);
70 uintmax_t file_size(boost::filesystem::path const& path);
71 uintmax_t file_size(boost::filesystem::path const& path, boost::system::error_code& ec);
72 uintmax_t hard_link_count(boost::filesystem::path const& path);
73 std::time_t last_write_time(boost::filesystem::path const& path);
74 std::time_t last_write_time(boost::filesystem::path const& path, boost::system::error_code& ec);
75 bool remove(boost::filesystem::path const& path);
76 bool remove(boost::filesystem::path const& path, boost::system::error_code& ec);
77 uintmax_t remove_all(boost::filesystem::path const& path);
78 uintmax_t remove_all(boost::filesystem::path const& path, boost::system::error_code& ec);
79 void rename(boost::filesystem::path const& old_path, boost::filesystem::path const& new_path);
80 void rename(boost::filesystem::path const& old_path, boost::filesystem::path const& new_path, boost::system::error_code& ec);
81 boost::filesystem::space_info space(boost::filesystem::path const& path);
88 directory_entry(boost::filesystem::path const& path);
90 boost::filesystem::path path() const;
91 operator boost::filesystem::path const&() const;
94 boost::filesystem::path _path;
98 class directory_iterator
101 directory_iterator() = default;
102 directory_iterator(boost::filesystem::path const& path);
103 directory_iterator(boost::filesystem::path const& path, boost::system::error_code& ec);
105 directory_iterator& operator++();
106 directory_entry operator*() const;
107 directory_entry* operator->() const;
108 bool operator!=(directory_iterator const& other) const;
111 boost::filesystem::directory_iterator _wrapped;
112 mutable directory_entry _entry;
116 directory_iterator const& begin(directory_iterator const& iter);
117 directory_iterator end(directory_iterator const&);
121 class recursive_directory_iterator
124 recursive_directory_iterator() = default;
125 recursive_directory_iterator(boost::filesystem::path const& path);
127 recursive_directory_iterator& operator++();
128 directory_entry operator*() const;
129 directory_entry* operator->() const;
130 bool operator!=(recursive_directory_iterator const& other) const;
133 boost::filesystem::recursive_directory_iterator _wrapped;
134 mutable directory_entry _entry;
138 recursive_directory_iterator const& begin(recursive_directory_iterator const& iter);
139 recursive_directory_iterator end(recursive_directory_iterator const&);
142 boost::filesystem::path fix_long_path(boost::filesystem::path long_path);
143 boost::filesystem::path unfix_long_path(boost::filesystem::path long_path);