[AArch64] Handle literal pools for functions > 1 MiB in size.
[official-gcc.git] / libstdc++-v3 / include / experimental / fs_dir.h
blob0c5253fb62d0d89c5d96a700b44910ffb591bcac
1 // Filesystem directory utilities -*- C++ -*-
3 // Copyright (C) 2014-2015 Free Software Foundation, Inc.
4 //
5 // This file is part of the GNU ISO C++ Library. This library is free
6 // software; you can redistribute it and/or modify it under the
7 // terms of the GNU General Public License as published by the
8 // Free Software Foundation; either version 3, or (at your option)
9 // any later version.
11 // This library 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 // Under Section 7 of GPL version 3, you are granted additional
17 // permissions described in the GCC Runtime Library Exception, version
18 // 3.1, as published by the Free Software Foundation.
20 // You should have received a copy of the GNU General Public License and
21 // a copy of the GCC Runtime Library Exception along with this program;
22 // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
23 // <http://www.gnu.org/licenses/>.
25 /** @file experimental/fs_dir.h
26 * This is an internal header file, included by other library headers.
27 * Do not attempt to use it directly. @headername{experimental/filesystem}
30 #ifndef _GLIBCXX_EXPERIMENTAL_FS_DIR_H
31 #define _GLIBCXX_EXPERIMENTAL_FS_DIR_H 1
33 #if __cplusplus < 201103L
34 # include <bits/c++0x_warning.h>
35 #else
36 # include <typeinfo>
37 # include <ext/concurrence.h>
38 # include <bits/unique_ptr.h>
39 # include <bits/shared_ptr.h>
41 namespace std _GLIBCXX_VISIBILITY(default)
43 namespace experimental
45 namespace filesystem
47 inline namespace v1
49 _GLIBCXX_BEGIN_NAMESPACE_VERSION
51 /**
52 * @ingroup filesystem
53 * @{
56 class file_status
58 public:
59 // constructors
60 explicit
61 file_status(file_type __ft = file_type::none,
62 perms __prms = perms::unknown) noexcept
63 : _M_type(__ft), _M_perms(__prms) { }
65 file_status(const file_status&) noexcept = default;
66 file_status(file_status&&) noexcept = default;
67 ~file_status() = default;
69 file_status& operator=(const file_status&) noexcept = default;
70 file_status& operator=(file_status&&) noexcept = default;
72 // observers
73 file_type type() const noexcept { return _M_type; }
74 perms permissions() const noexcept { return _M_perms; }
76 // modifiers
77 void type(file_type __ft) noexcept { _M_type = __ft; }
78 void permissions(perms __prms) noexcept { _M_perms = __prms; }
80 private:
81 file_type _M_type;
82 perms _M_perms;
85 _GLIBCXX_BEGIN_NAMESPACE_CXX11
87 class directory_entry
89 public:
90 // constructors and destructor
91 directory_entry() noexcept = default;
92 directory_entry(const directory_entry&) = default;
93 directory_entry(directory_entry&&) noexcept = default;
94 explicit directory_entry(const filesystem::path& __p) : _M_path(__p) { }
95 ~directory_entry() = default;
97 // modifiers
98 directory_entry& operator=(const directory_entry&) = default;
99 directory_entry& operator=(directory_entry&&) noexcept = default;
101 void assign(const filesystem::path& __p) { _M_path = __p; }
103 void
104 replace_filename(const filesystem::path& __p)
105 { _M_path = _M_path.parent_path() / __p; }
107 // observers
108 const filesystem::path& path() const noexcept { return _M_path; }
109 operator const filesystem::path&() const noexcept { return _M_path; }
111 file_status
112 status() const
113 { return filesystem::status(_M_path); }
115 file_status
116 status(error_code& __ec) const noexcept
117 { return filesystem::status(_M_path, __ec); }
119 file_status
120 symlink_status() const
121 { return filesystem::symlink_status(_M_path); }
123 file_status
124 symlink_status(error_code& __ec) const noexcept
125 { return filesystem::symlink_status(_M_path, __ec); }
127 bool
128 operator< (const directory_entry& __rhs) const noexcept
129 { return _M_path < __rhs._M_path; }
131 bool
132 operator==(const directory_entry& __rhs) const noexcept
133 { return _M_path == __rhs._M_path; }
135 bool
136 operator!=(const directory_entry& __rhs) const noexcept
137 { return _M_path != __rhs._M_path; }
139 bool
140 operator<=(const directory_entry& __rhs) const noexcept
141 { return _M_path <= __rhs._M_path; }
143 bool
144 operator> (const directory_entry& __rhs) const noexcept
145 { return _M_path > __rhs._M_path; }
147 bool
148 operator>=(const directory_entry& __rhs) const noexcept
149 { return _M_path >= __rhs._M_path; }
151 private:
152 filesystem::path _M_path;
155 struct _Dir;
156 class recursive_directory_iterator;
158 class directory_iterator
160 public:
161 typedef directory_entry value_type;
162 typedef ptrdiff_t difference_type;
163 typedef const directory_entry* pointer;
164 typedef const directory_entry& reference;
165 typedef input_iterator_tag iterator_category;
167 directory_iterator() noexcept = default;
169 explicit
170 directory_iterator(const path& __p)
171 : directory_iterator(__p, directory_options::none, nullptr) { }
173 directory_iterator(const path& __p, directory_options __options)
174 : directory_iterator(__p, __options, nullptr) { }
176 directory_iterator(const path& __p, error_code& __ec) noexcept
177 : directory_iterator(__p, directory_options::none, __ec) { }
179 directory_iterator(const path& __p,
180 directory_options __options, error_code& __ec) noexcept
181 : directory_iterator(__p, __options, &__ec) { }
183 directory_iterator(const directory_iterator& __rhs) = default;
185 directory_iterator(directory_iterator&& __rhs) noexcept = default;
187 ~directory_iterator() = default;
189 directory_iterator& operator=(const directory_iterator& __rhs) = default;
190 directory_iterator& operator=(directory_iterator&& __rhs) noexcept = default;
192 const directory_entry& operator*() const;
193 const directory_entry* operator->() const { return &**this; }
194 directory_iterator& operator++();
195 directory_iterator& increment(error_code& __ec) noexcept;
197 directory_iterator operator++(int)
199 auto __tmp = *this;
200 ++*this;
201 return __tmp;
204 private:
205 directory_iterator(const path&, directory_options, error_code*);
207 friend bool
208 operator==(const directory_iterator& __lhs,
209 const directory_iterator& __rhs);
211 friend class recursive_directory_iterator;
213 std::shared_ptr<_Dir> _M_dir;
216 inline directory_iterator
217 begin(directory_iterator __iter) { return __iter; }
219 inline directory_iterator
220 end(directory_iterator) { return directory_iterator(); }
222 inline bool
223 operator==(const directory_iterator& __lhs, const directory_iterator& __rhs)
225 return !__rhs._M_dir.owner_before(__lhs._M_dir)
226 && !__lhs._M_dir.owner_before(__rhs._M_dir);
229 inline bool
230 operator!=(const directory_iterator& __lhs, const directory_iterator& __rhs)
231 { return !(__lhs == __rhs); }
233 class recursive_directory_iterator
235 public:
236 typedef directory_entry value_type;
237 typedef ptrdiff_t difference_type;
238 typedef const directory_entry* pointer;
239 typedef const directory_entry& reference;
240 typedef input_iterator_tag iterator_category;
242 recursive_directory_iterator() noexcept = default;
244 explicit
245 recursive_directory_iterator(const path& __p)
246 : recursive_directory_iterator(__p, directory_options::none, nullptr) { }
248 recursive_directory_iterator(const path& __p, directory_options __options)
249 : recursive_directory_iterator(__p, __options, nullptr) { }
251 recursive_directory_iterator(const path& __p,
252 directory_options __options,
253 error_code& __ec) noexcept
254 : recursive_directory_iterator(__p, __options, &__ec) { }
256 recursive_directory_iterator(const path& __p, error_code& __ec) noexcept
257 : recursive_directory_iterator(__p, directory_options::none, &__ec) { }
259 recursive_directory_iterator(
260 const recursive_directory_iterator&) = default;
262 recursive_directory_iterator(
263 recursive_directory_iterator&&) noexcept = default;
265 ~recursive_directory_iterator();
267 // observers
268 directory_options options() const { return _M_options; }
269 int depth() const;
270 bool recursion_pending() const { return _M_pending; }
272 const directory_entry& operator*() const;
273 const directory_entry* operator->() const { return &**this; }
275 // modifiers
276 recursive_directory_iterator&
277 operator=(const recursive_directory_iterator& __rhs) noexcept;
278 recursive_directory_iterator&
279 operator=(recursive_directory_iterator&& __rhs) noexcept;
281 recursive_directory_iterator& operator++();
282 recursive_directory_iterator& increment(error_code& __ec) noexcept;
284 recursive_directory_iterator operator++(int)
286 auto __tmp = *this;
287 ++*this;
288 return __tmp;
291 void pop();
293 void disable_recursion_pending() { _M_pending = false; }
295 private:
296 recursive_directory_iterator(const path&, directory_options, error_code*);
298 friend bool
299 operator==(const recursive_directory_iterator& __lhs,
300 const recursive_directory_iterator& __rhs);
302 struct _Dir_stack;
303 std::shared_ptr<_Dir_stack> _M_dirs;
304 directory_options _M_options;
305 bool _M_pending;
308 inline recursive_directory_iterator
309 begin(recursive_directory_iterator __iter) { return __iter; }
311 inline recursive_directory_iterator
312 end(recursive_directory_iterator) { return recursive_directory_iterator(); }
314 inline bool
315 operator==(const recursive_directory_iterator& __lhs,
316 const recursive_directory_iterator& __rhs)
318 return !__rhs._M_dirs.owner_before(__lhs._M_dirs)
319 && !__lhs._M_dirs.owner_before(__rhs._M_dirs);
322 inline bool
323 operator!=(const recursive_directory_iterator& __lhs,
324 const recursive_directory_iterator& __rhs)
325 { return !(__lhs == __rhs); }
327 _GLIBCXX_END_NAMESPACE_CXX11
329 // @} group filesystem
330 _GLIBCXX_END_NAMESPACE_VERSION
331 } // namespace v1
332 } // namespace filesystem
333 } // namespace experimental
334 } // namespace std
336 #endif // C++11
338 #endif // _GLIBCXX_EXPERIMENTAL_FS_DIR_H