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 void copy(boost::filesystem::path const& from, boost::filesystem::path const& to);
50 void copy_file(boost::filesystem::path const& from, boost::filesystem::path const& to);
51 bool create_directory(boost::filesystem::path const& path);
52 bool create_directories(boost::filesystem::path const& path);
53 void create_hard_link(boost::filesystem::path const& from, boost::filesystem::path const& to);
54 void current_path(boost::filesystem::path const& path);
55 boost::filesystem::path current_path();
56 bool exists(boost::filesystem::path const& path);
57 bool is_regular_file(boost::filesystem::path const& path);
58 uintmax_t file_size(boost::filesystem::path const& path);
59 uintmax_t remove_all(boost::filesystem::path const& path);
66 directory_entry(boost::filesystem::path const& path);
68 boost::filesystem::path path() const;
69 operator boost::filesystem::path const&() const;
72 boost::filesystem::path _path;
76 class directory_iterator
79 directory_iterator() = default;
80 directory_iterator(boost::filesystem::path const& path);
82 directory_iterator& operator++();
83 directory_entry operator*() const;
84 bool operator!=(directory_iterator const& other) const;
87 boost::filesystem::directory_iterator _wrapped;
91 directory_iterator const& begin(directory_iterator const& iter);
92 directory_iterator end(directory_iterator const&);
96 class recursive_directory_iterator
99 recursive_directory_iterator() = default;
100 recursive_directory_iterator(boost::filesystem::path const& path);
102 recursive_directory_iterator& operator++();
103 directory_entry operator*() const;
104 directory_entry* operator->() const;
105 bool operator!=(recursive_directory_iterator const& other) const;
108 boost::filesystem::recursive_directory_iterator _wrapped;
109 mutable directory_entry _entry;
113 recursive_directory_iterator const& begin(recursive_directory_iterator const& iter);
114 recursive_directory_iterator end(recursive_directory_iterator const&);
117 boost::filesystem::path fix_long_path(boost::filesystem::path long_path);
118 boost::filesystem::path unfix_long_path(boost::filesystem::path long_path);