Add include/experimental/bits dir
[gcc.git] / libstdc++-v3 / include / experimental / bits / fs_ops.h
1 // Filesystem operational functions -*- C++ -*-
2
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.
10
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.
15
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.
19
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/>.
24
25 /** @file experimental/filesystem
26 * This is a TS C++ Library header.
27 */
28
29 #ifndef _GLIBCXX_EXPERIMENTAL_FS_OPS_H
30 #define _GLIBCXX_EXPERIMENTAL_FS_OPS_H 1
31
32 #if __cplusplus < 201103L
33 # include <bits/c++0x_warning.h>
34 #else
35
36 #include <cstdint>
37
38 namespace std _GLIBCXX_VISIBILITY(default)
39 {
40 namespace experimental
41 {
42 namespace filesystem
43 {
44 inline namespace v1
45 {
46 _GLIBCXX_BEGIN_NAMESPACE_VERSION
47
48 /**
49 * @ingroup filesystem
50 * @{
51 */
52
53 path absolute(const path& __p, const path& __base = current_path());
54
55 path canonical(const path& __p, const path& __base = current_path());
56 path canonical(const path& __p, error_code& __ec);
57 path canonical(const path& __p, const path& __base, error_code& __ec);
58
59 inline void
60 copy(const path& __from, const path& __to)
61 { copy(__from, __to, copy_options::none); }
62
63 inline void
64 copy(const path& __from, const path& __to, error_code& __ec) noexcept
65 { copy(__from, __to, copy_options::none, __ec); }
66
67 void copy(const path& __from, const path& __to, copy_options __options);
68 void copy(const path& __from, const path& __to, copy_options __options,
69 error_code& __ec) noexcept;
70
71 inline bool
72 copy_file(const path& __from, const path& __to)
73 { return copy_file(__from, __to, copy_options::none); }
74
75 inline bool
76 copy_file(const path& __from, const path& __to, error_code& __ec) noexcept
77 { return copy_file(__from, __to, copy_options::none, __ec); }
78
79 bool copy_file(const path& __from, const path& __to, copy_options __option);
80 bool copy_file(const path& __from, const path& __to, copy_options __option,
81 error_code& __ec) noexcept;
82
83 void copy_symlink(const path& __existing_symlink, const path& __new_symlink);
84 void copy_symlink(const path& __existing_symlink, const path& __new_symlink,
85 error_code& __ec) noexcept;
86
87 bool create_directories(const path& __p);
88 bool create_directories(const path& __p, error_code& __ec) noexcept;
89
90 bool create_directory(const path& __p);
91 bool create_directory(const path& __p, error_code& __ec) noexcept;
92
93 bool create_directory(const path& __p, const path& attributes);
94 bool create_directory(const path& __p, const path& attributes,
95 error_code& __ec) noexcept;
96
97 void create_directory_symlink(const path& __to, const path& __new_symlink);
98 void create_directory_symlink(const path& __to, const path& __new_symlink,
99 error_code& __ec) noexcept;
100
101 void create_hard_link(const path& __to, const path& __new_hard_link);
102 void create_hard_link(const path& __to, const path& __new_hard_link,
103 error_code& __ec) noexcept;
104
105 void create_symlink(const path& __to, const path& __new_symlink);
106 void create_symlink(const path& __to, const path& __new_symlink,
107 error_code& __ec) noexcept;
108
109 path current_path();
110 path current_path(error_code& __ec);
111 void current_path(const path& __p);
112 void current_path(const path& __p, error_code& __ec) noexcept;
113
114 inline bool
115 exists(file_status __s) noexcept
116 { return status_known(__s) && __s.type() != file_type::not_found; }
117
118 inline bool
119 exists(const path& __p)
120 { return exists(status(__p)); }
121
122 inline bool
123 exists(const path& __p, error_code& __ec) noexcept
124 { return exists(status(__p, __ec)); }
125
126 bool
127 equivalent(const path& __p1, const path& __p2);
128
129 bool
130 equivalent(const path& __p1, const path& __p2, error_code& __ec) noexcept;
131
132 uintmax_t file_size(const path& __p);
133 uintmax_t file_size(const path& __p, error_code& __ec) noexcept;
134
135 uintmax_t hard_link_count(const path& __p);
136 uintmax_t hard_link_count(const path& __p, error_code& __ec) noexcept;
137
138 inline bool
139 is_block_file(file_status __s) noexcept
140 { return __s.type() == file_type::block; }
141
142 inline bool
143 is_block_file(const path& __p)
144 { return is_block_file(status(__p)); }
145
146 inline bool
147 is_block_file(const path& __p, error_code& __ec) noexcept
148 { return is_block_file(status(__p, __ec)); }
149
150 inline bool
151 is_character_file(file_status __s) noexcept
152 { return __s.type() == file_type::character; }
153
154 inline bool
155 is_character_file(const path& __p)
156 { return is_character_file(status(__p)); }
157
158 inline bool
159 is_character_file(const path& __p, error_code& __ec) noexcept
160 { return is_character_file(status(__p, __ec)); }
161
162 inline bool
163 is_directory(file_status __s) noexcept
164 { return __s.type() == file_type::directory; }
165
166 inline bool
167 is_directory(const path& __p)
168 { return is_directory(status(__p)); }
169
170 inline bool
171 is_directory(const path& __p, error_code& __ec) noexcept
172 { return is_directory(status(__p, __ec)); }
173
174 bool is_empty(const path& __p);
175 bool is_empty(const path& __p, error_code& __ec) noexcept;
176
177 inline bool
178 is_fifo(file_status __s) noexcept
179 { return __s.type() == file_type::fifo; }
180
181 inline bool
182 is_fifo(const path& __p)
183 { return is_fifo(status(__p)); }
184
185 inline bool
186 is_fifo(const path& __p, error_code& __ec) noexcept
187 { return is_fifo(status(__p, __ec)); }
188
189 inline bool
190 is_other(file_status __s) noexcept
191 {
192 return exists(__s) && !is_regular_file(__s) && !is_directory(__s)
193 && !is_symlink(__s);
194 }
195
196 inline bool
197 is_other(const path& __p)
198 { return is_other(status(__p)); }
199
200 inline bool
201 is_other(const path& __p, error_code& __ec) noexcept
202 { return is_other(status(__p, __ec)); }
203
204 inline bool
205 is_regular_file(file_status __s) noexcept
206 { return __s.type() == file_type::regular; }
207
208 inline bool
209 is_regular_file(const path& __p)
210 { return is_regular_file(status(__p)); }
211
212 inline bool
213 is_regular_file(const path& __p, error_code& __ec) noexcept
214 { return is_regular_file(status(__p, __ec)); }
215
216 inline bool
217 is_socket(file_status __s) noexcept
218 { return __s.type() == file_type::socket; }
219
220 inline bool
221 is_socket(const path& __p)
222 { return is_socket(status(__p)); }
223
224 inline bool
225 is_socket(const path& __p, error_code& __ec) noexcept
226 { return is_socket(status(__p, __ec)); }
227
228 inline bool
229 is_symlink(file_status __s) noexcept
230 { return __s.type() == file_type::symlink; }
231
232 inline bool
233 is_symlink(const path& __p)
234 { return is_symlink(symlink_status(__p)); }
235
236 inline bool
237 is_symlink(const path& __p, error_code& __ec) noexcept
238 { return is_symlink(symlink_status(__p, __ec)); }
239
240 file_time_type last_write_time(const path& __p);
241 file_time_type last_write_time(const path& __p, error_code& __ec) noexcept;
242 void last_write_time(const path& __p, file_time_type __new_time);
243 void last_write_time(const path& __p, file_time_type __new_time,
244 error_code& __ec) noexcept;
245
246 void permissions(const path& __p, perms __prms);
247 void permissions(const path& __p, perms __prms, error_code& __ec) noexcept;
248
249 path read_symlink(const path& __p);
250 path read_symlink(const path& __p, error_code& __ec);
251
252 bool remove(const path& __p);
253 bool remove(const path& __p, error_code& __ec) noexcept;
254
255 uintmax_t remove_all(const path& __p);
256 uintmax_t remove_all(const path& __p, error_code& __ec) noexcept;
257
258 void rename(const path& __from, const path& __to);
259 void rename(const path& __from, const path& __to, error_code& __ec) noexcept;
260
261 void resize_file(const path& __p, uintmax_t __size);
262 void resize_file(const path& __p, uintmax_t __size, error_code& __ec) noexcept;
263
264 space_info space(const path& __p);
265 space_info space(const path& __p, error_code& __ec) noexcept;
266
267 file_status status(const path& __p);
268 file_status status(const path& __p, error_code& __ec) noexcept;
269
270 inline bool status_known(file_status __s) noexcept
271 { return __s.type() != file_type::none; }
272
273 file_status symlink_status(const path& __p);
274 file_status symlink_status(const path& __p, error_code& __ec) noexcept;
275
276 path system_complete(const path& __p);
277 path system_complete(const path& __p, error_code& __ec);
278
279 path temp_directory_path();
280 path temp_directory_path(error_code& __ec);
281
282 // @} group filesystem
283 _GLIBCXX_END_NAMESPACE_VERSION
284 } // namespace v1
285 } // namespace filesystem
286 } // namespace experimental
287 } // namespace std
288
289 #endif // C++11
290
291 #endif // _GLIBCXX_EXPERIMENTAL_FS_OPS_H