]> git.proxmox.com Git - ceph.git/blame - ceph/src/boost/boost/filesystem/operations.hpp
import new upstream nautilus stable release 14.2.8
[ceph.git] / ceph / src / boost / boost / filesystem / operations.hpp
CommitLineData
7c673cae
FG
1// boost/filesystem/operations.hpp ---------------------------------------------------//
2
3// Copyright Beman Dawes 2002-2009
4// Copyright Jan Langer 2002
92f5a8d4 5// Copyright Dietmar Kuehl 2001
7c673cae 6// Copyright Vladimir Prus 2002
92f5a8d4 7
7c673cae
FG
8// Distributed under the Boost Software License, Version 1.0.
9// See http://www.boost.org/LICENSE_1_0.txt
10
11// Library home page: http://www.boost.org/libs/filesystem
12
13//--------------------------------------------------------------------------------------//
14
15#ifndef BOOST_FILESYSTEM3_OPERATIONS_HPP
16#define BOOST_FILESYSTEM3_OPERATIONS_HPP
17
18#include <boost/config.hpp>
19
20# if defined( BOOST_NO_STD_WSTRING )
21# error Configuration not supported: Boost.Filesystem V3 and later requires std::wstring support
22# endif
23
24#include <boost/filesystem/config.hpp>
25#include <boost/filesystem/path.hpp>
92f5a8d4
TL
26#include <boost/filesystem/file_status.hpp>
27
28#ifndef BOOST_FILESYSTEM_NO_DEPRECATED
29// These includes are left for backward compatibility and should be included directly by users, as needed
30#include <boost/filesystem/exception.hpp>
31#include <boost/filesystem/directory.hpp>
32#endif
7c673cae 33
92f5a8d4 34#include <boost/core/scoped_enum.hpp>
7c673cae 35#include <boost/system/error_code.hpp>
7c673cae 36#include <boost/cstdint.hpp>
7c673cae 37#include <string>
7c673cae 38#include <ctime>
7c673cae
FG
39
40#include <boost/config/abi_prefix.hpp> // must be the last #include
41
42//--------------------------------------------------------------------------------------//
43
92f5a8d4
TL
44namespace boost {
45namespace filesystem {
7c673cae 46
92f5a8d4
TL
47struct space_info
48{
49 // all values are byte counts
50 boost::uintmax_t capacity;
51 boost::uintmax_t free; // <= capacity
52 boost::uintmax_t available; // <= free
53};
7c673cae 54
92f5a8d4
TL
55BOOST_SCOPED_ENUM_DECLARE_BEGIN(copy_option)
56 {none=0, fail_if_exists = none, overwrite_if_exists}
57BOOST_SCOPED_ENUM_DECLARE_END(copy_option)
7c673cae
FG
58
59//--------------------------------------------------------------------------------------//
60// implementation details //
61//--------------------------------------------------------------------------------------//
62
92f5a8d4
TL
63namespace detail {
64
65// We cannot pass a BOOST_SCOPED_ENUM to a compled function because it will result
66// in an undefined reference if the library is compled with -std=c++0x but the use
67// is compiled in C++03 mode, or vice versa. See tickets 6124, 6779, 10038.
68enum copy_option {none=0, fail_if_exists = none, overwrite_if_exists};
69
70BOOST_FILESYSTEM_DECL
71file_status status(const path&p, system::error_code* ec=0);
72BOOST_FILESYSTEM_DECL
73file_status symlink_status(const path& p, system::error_code* ec=0);
74BOOST_FILESYSTEM_DECL
75bool is_empty(const path& p, system::error_code* ec=0);
76BOOST_FILESYSTEM_DECL
77path initial_path(system::error_code* ec=0);
78BOOST_FILESYSTEM_DECL
79path canonical(const path& p, const path& base, system::error_code* ec=0);
80BOOST_FILESYSTEM_DECL
81void copy(const path& from, const path& to, system::error_code* ec=0);
82BOOST_FILESYSTEM_DECL
83void copy_directory(const path& from, const path& to, system::error_code* ec=0);
84BOOST_FILESYSTEM_DECL
85void copy_file(const path& from, const path& to, // See ticket #2925
86 detail::copy_option option, system::error_code* ec=0);
87BOOST_FILESYSTEM_DECL
88void copy_symlink(const path& existing_symlink, const path& new_symlink, system::error_code* ec=0);
89BOOST_FILESYSTEM_DECL
90bool create_directories(const path& p, system::error_code* ec=0);
91BOOST_FILESYSTEM_DECL
92bool create_directory(const path& p, system::error_code* ec=0);
93BOOST_FILESYSTEM_DECL
94void create_directory_symlink(const path& to, const path& from,
95 system::error_code* ec=0);
96BOOST_FILESYSTEM_DECL
97void create_hard_link(const path& to, const path& from, system::error_code* ec=0);
98BOOST_FILESYSTEM_DECL
99void create_symlink(const path& to, const path& from, system::error_code* ec=0);
100BOOST_FILESYSTEM_DECL
101path current_path(system::error_code* ec=0);
102BOOST_FILESYSTEM_DECL
103void current_path(const path& p, system::error_code* ec=0);
104BOOST_FILESYSTEM_DECL
105bool equivalent(const path& p1, const path& p2, system::error_code* ec=0);
106BOOST_FILESYSTEM_DECL
107boost::uintmax_t file_size(const path& p, system::error_code* ec=0);
108BOOST_FILESYSTEM_DECL
109boost::uintmax_t hard_link_count(const path& p, system::error_code* ec=0);
110BOOST_FILESYSTEM_DECL
111std::time_t last_write_time(const path& p, system::error_code* ec=0);
112BOOST_FILESYSTEM_DECL
113void last_write_time(const path& p, const std::time_t new_time,
114 system::error_code* ec=0);
115BOOST_FILESYSTEM_DECL
116void permissions(const path& p, perms prms, system::error_code* ec=0);
117BOOST_FILESYSTEM_DECL
118path read_symlink(const path& p, system::error_code* ec=0);
119BOOST_FILESYSTEM_DECL
120path relative(const path& p, const path& base, system::error_code* ec = 0);
121BOOST_FILESYSTEM_DECL
122bool remove(const path& p, system::error_code* ec=0);
123BOOST_FILESYSTEM_DECL
124boost::uintmax_t remove_all(const path& p, system::error_code* ec=0);
125BOOST_FILESYSTEM_DECL
126void rename(const path& old_p, const path& new_p, system::error_code* ec=0);
127BOOST_FILESYSTEM_DECL
128void resize_file(const path& p, uintmax_t size, system::error_code* ec=0);
129BOOST_FILESYSTEM_DECL
130space_info space(const path& p, system::error_code* ec=0);
131BOOST_FILESYSTEM_DECL
132path system_complete(const path& p, system::error_code* ec=0);
133BOOST_FILESYSTEM_DECL
134path temp_directory_path(system::error_code* ec=0);
135BOOST_FILESYSTEM_DECL
136path unique_path(const path& p, system::error_code* ec=0);
137BOOST_FILESYSTEM_DECL
138path weakly_canonical(const path& p, system::error_code* ec = 0);
139
140} // namespace detail
7c673cae
FG
141
142//--------------------------------------------------------------------------------------//
143// //
144// status query functions //
145// //
146//--------------------------------------------------------------------------------------//
147
92f5a8d4
TL
148inline
149file_status status(const path& p) {return detail::status(p);}
150inline
151file_status status(const path& p, system::error_code& ec)
152 {return detail::status(p, &ec);}
153inline
154file_status symlink_status(const path& p) {return detail::symlink_status(p);}
155inline
156file_status symlink_status(const path& p, system::error_code& ec)
157 {return detail::symlink_status(p, &ec);}
158inline
159bool exists(const path& p) {return exists(detail::status(p));}
160inline
161bool exists(const path& p, system::error_code& ec)
162 {return exists(detail::status(p, &ec));}
163inline
164bool is_directory(const path& p) {return is_directory(detail::status(p));}
165inline
166bool is_directory(const path& p, system::error_code& ec)
167 {return is_directory(detail::status(p, &ec));}
168inline
169bool is_regular_file(const path& p) {return is_regular_file(detail::status(p));}
170inline
171bool is_regular_file(const path& p, system::error_code& ec)
172 {return is_regular_file(detail::status(p, &ec));}
173inline
174bool is_other(const path& p) {return is_other(detail::status(p));}
175inline
176bool is_other(const path& p, system::error_code& ec)
177 {return is_other(detail::status(p, &ec));}
178inline
179bool is_symlink(const path& p) {return is_symlink(detail::symlink_status(p));}
180inline
181bool is_symlink(const path& p, system::error_code& ec)
182 {return is_symlink(detail::symlink_status(p, &ec));}
183#ifndef BOOST_FILESYSTEM_NO_DEPRECATED
184inline
185bool is_regular(const path& p) {return is_regular(detail::status(p));}
186inline
187bool is_regular(const path& p, system::error_code& ec)
188 {return is_regular(detail::status(p, &ec));}
189#endif
7c673cae 190
92f5a8d4
TL
191inline
192bool is_empty(const path& p) {return detail::is_empty(p);}
193inline
194bool is_empty(const path& p, system::error_code& ec)
195 {return detail::is_empty(p, &ec);}
7c673cae
FG
196
197//--------------------------------------------------------------------------------------//
198// //
199// operational functions //
200// in alphabetical order, unless otherwise noted //
201// //
7c673cae
FG
202//--------------------------------------------------------------------------------------//
203
92f5a8d4
TL
204// forward declarations
205path current_path(); // fwd declaration
206path initial_path();
207
208BOOST_FILESYSTEM_DECL
209path absolute(const path& p, const path& base=current_path());
210// If base.is_absolute(), throws nothing. Thus no need for ec argument
211
212inline
213path canonical(const path& p, const path& base=current_path())
214 {return detail::canonical(p, base);}
215inline
216path canonical(const path& p, system::error_code& ec)
217 {return detail::canonical(p, current_path(), &ec);}
218inline
219path canonical(const path& p, const path& base, system::error_code& ec)
220 {return detail::canonical(p, base, &ec);}
221
222#ifndef BOOST_FILESYSTEM_NO_DEPRECATED
223inline
224path complete(const path& p)
225{
226 return absolute(p, initial_path());
227}
7c673cae 228
92f5a8d4
TL
229inline
230path complete(const path& p, const path& base)
7c673cae 231{
92f5a8d4
TL
232 return absolute(p, base);
233}
7c673cae
FG
234#endif
235
92f5a8d4
TL
236inline
237void copy(const path& from, const path& to) {detail::copy(from, to);}
238
239inline
240void copy(const path& from, const path& to, system::error_code& ec) BOOST_NOEXCEPT
241 {detail::copy(from, to, &ec);}
242inline
243void copy_directory(const path& from, const path& to)
244 {detail::copy_directory(from, to);}
245inline
246void copy_directory(const path& from, const path& to, system::error_code& ec) BOOST_NOEXCEPT
247 {detail::copy_directory(from, to, &ec);}
248inline
249void copy_file(const path& from, const path& to, // See ticket #2925
250 BOOST_SCOPED_ENUM_NATIVE(copy_option) option)
7c673cae 251{
92f5a8d4
TL
252 detail::copy_file(from, to, static_cast<detail::copy_option>(option));
253}
254inline
255void copy_file(const path& from, const path& to)
7c673cae 256{
92f5a8d4
TL
257 detail::copy_file(from, to, detail::fail_if_exists);
258}
259inline
260void copy_file(const path& from, const path& to, // See ticket #2925
261 BOOST_SCOPED_ENUM_NATIVE(copy_option) option, system::error_code& ec) BOOST_NOEXCEPT
7c673cae 262{
92f5a8d4
TL
263 detail::copy_file(from, to, static_cast<detail::copy_option>(option), &ec);
264}
265inline
266void copy_file(const path& from, const path& to, system::error_code& ec) BOOST_NOEXCEPT
267{
268 detail::copy_file(from, to, detail::fail_if_exists, &ec);
269}
270inline
271void copy_symlink(const path& existing_symlink,
272 const path& new_symlink) {detail::copy_symlink(existing_symlink, new_symlink);}
273
274inline
275void copy_symlink(const path& existing_symlink, const path& new_symlink,
276 system::error_code& ec) BOOST_NOEXCEPT
277 {detail::copy_symlink(existing_symlink, new_symlink, &ec);}
278inline
279bool create_directories(const path& p) {return detail::create_directories(p);}
280
281inline
282bool create_directories(const path& p, system::error_code& ec) BOOST_NOEXCEPT
283 {return detail::create_directories(p, &ec);}
284inline
285bool create_directory(const path& p) {return detail::create_directory(p);}
286
287inline
288bool create_directory(const path& p, system::error_code& ec) BOOST_NOEXCEPT
289 {return detail::create_directory(p, &ec);}
290inline
291void create_directory_symlink(const path& to, const path& from)
292 {detail::create_directory_symlink(to, from);}
293inline
294void create_directory_symlink(const path& to, const path& from, system::error_code& ec) BOOST_NOEXCEPT
295 {detail::create_directory_symlink(to, from, &ec);}
296inline
297void create_hard_link(const path& to, const path& new_hard_link) {detail::create_hard_link(to, new_hard_link);}
298
299inline
300void create_hard_link(const path& to, const path& new_hard_link, system::error_code& ec) BOOST_NOEXCEPT
301 {detail::create_hard_link(to, new_hard_link, &ec);}
302inline
303void create_symlink(const path& to, const path& new_symlink) {detail::create_symlink(to, new_symlink);}
304
305inline
306void create_symlink(const path& to, const path& new_symlink, system::error_code& ec) BOOST_NOEXCEPT
307 {detail::create_symlink(to, new_symlink, &ec);}
308inline
309path current_path() {return detail::current_path();}
310
311inline
312path current_path(system::error_code& ec) {return detail::current_path(&ec);}
313
314inline
315void current_path(const path& p) {detail::current_path(p);}
316
317inline
318void current_path(const path& p, system::error_code& ec) BOOST_NOEXCEPT {detail::current_path(p, &ec);}
319
320inline
321bool equivalent(const path& p1, const path& p2) {return detail::equivalent(p1, p2);}
322
323inline
324bool equivalent(const path& p1, const path& p2, system::error_code& ec) BOOST_NOEXCEPT
325 {return detail::equivalent(p1, p2, &ec);}
326inline
327boost::uintmax_t file_size(const path& p) {return detail::file_size(p);}
328
329inline
330boost::uintmax_t file_size(const path& p, system::error_code& ec) BOOST_NOEXCEPT
331 {return detail::file_size(p, &ec);}
332inline
333boost::uintmax_t hard_link_count(const path& p) {return detail::hard_link_count(p);}
334
335inline
336boost::uintmax_t hard_link_count(const path& p, system::error_code& ec) BOOST_NOEXCEPT
337 {return detail::hard_link_count(p, &ec);}
338inline
339path initial_path() {return detail::initial_path();}
340
341inline
342path initial_path(system::error_code& ec) {return detail::initial_path(&ec);}
343
344template <class Path>
345path initial_path() {return initial_path();}
346template <class Path>
347path initial_path(system::error_code& ec) {return detail::initial_path(&ec);}
348
349inline
350std::time_t last_write_time(const path& p) {return detail::last_write_time(p);}
351
352inline
353std::time_t last_write_time(const path& p, system::error_code& ec) BOOST_NOEXCEPT
354 {return detail::last_write_time(p, &ec);}
355inline
356void last_write_time(const path& p, const std::time_t new_time)
357 {detail::last_write_time(p, new_time);}
358inline
359void last_write_time(const path& p, const std::time_t new_time,
360 system::error_code& ec) BOOST_NOEXCEPT
361 {detail::last_write_time(p, new_time, &ec);}
362inline
363void permissions(const path& p, perms prms)
364 {detail::permissions(p, prms);}
365inline
366void permissions(const path& p, perms prms, system::error_code& ec) BOOST_NOEXCEPT
367 {detail::permissions(p, prms, &ec);}
368
369inline
370path read_symlink(const path& p) {return detail::read_symlink(p);}
371
372inline
373path read_symlink(const path& p, system::error_code& ec)
374 {return detail::read_symlink(p, &ec);}
375
376inline
377bool remove(const path& p) {return detail::remove(p);}
378
379inline
380bool remove(const path& p, system::error_code& ec) BOOST_NOEXCEPT
381 {return detail::remove(p, &ec);}
382
383inline
384boost::uintmax_t remove_all(const path& p) {return detail::remove_all(p);}
385
386inline
387boost::uintmax_t remove_all(const path& p, system::error_code& ec) BOOST_NOEXCEPT
388 {return detail::remove_all(p, &ec);}
389inline
390void rename(const path& old_p, const path& new_p) {detail::rename(old_p, new_p);}
391
392inline
393void rename(const path& old_p, const path& new_p, system::error_code& ec) BOOST_NOEXCEPT
394 {detail::rename(old_p, new_p, &ec);}
395inline // name suggested by Scott McMurray
396void resize_file(const path& p, uintmax_t size) {detail::resize_file(p, size);}
397
398inline
399void resize_file(const path& p, uintmax_t size, system::error_code& ec) BOOST_NOEXCEPT
400 {detail::resize_file(p, size, &ec);}
401inline
402path relative(const path& p, const path& base=current_path())
403 {return detail::relative(p, base);}
404inline
405path relative(const path& p, system::error_code& ec)
406 {return detail::relative(p, current_path(), &ec);}
407inline
408path relative(const path& p, const path& base, system::error_code& ec)
409 {return detail::relative(p, base, &ec);}
410inline
411space_info space(const path& p) {return detail::space(p);}
412
413inline
414space_info space(const path& p, system::error_code& ec) BOOST_NOEXCEPT
415 {return detail::space(p, &ec);}
416
417#ifndef BOOST_FILESYSTEM_NO_DEPRECATED
418inline bool symbolic_link_exists(const path& p)
419 { return is_symlink(filesystem::symlink_status(p)); }
420#endif
7c673cae 421
92f5a8d4
TL
422inline
423path system_complete(const path& p) {return detail::system_complete(p);}
424
425inline
426path system_complete(const path& p, system::error_code& ec)
427 {return detail::system_complete(p, &ec);}
428inline
429path temp_directory_path() {return detail::temp_directory_path();}
430
431inline
432path temp_directory_path(system::error_code& ec)
433 {return detail::temp_directory_path(&ec);}
434inline
435path unique_path(const path& p="%%%%-%%%%-%%%%-%%%%")
436 {return detail::unique_path(p);}
437inline
438path unique_path(const path& p, system::error_code& ec)
439 {return detail::unique_path(p, &ec);}
440inline
441path weakly_canonical(const path& p) {return detail::weakly_canonical(p);}
442
443inline
444path weakly_canonical(const path& p, system::error_code& ec)
445 {return detail::weakly_canonical(p, &ec);}
7c673cae
FG
446
447// test helper -----------------------------------------------------------------------//
448
449// Not part of the documented interface since false positives are possible;
450// there is no law that says that an OS that has large stat.st_size
451// actually supports large file sizes.
452
92f5a8d4
TL
453namespace detail {
454
455BOOST_FILESYSTEM_DECL bool possible_large_file_size_support();
456
457} // namespace detail
7c673cae 458
92f5a8d4 459} // namespace filesystem
7c673cae
FG
460} // namespace boost
461
462#include <boost/config/abi_suffix.hpp> // pops abi_prefix.hpp pragmas
463#endif // BOOST_FILESYSTEM3_OPERATIONS_HPP