1
// boost/filesystem/operations.hpp ---------------------------------------------------//
3
// Copyright Beman Dawes 2002-2009
4
// Copyright Jan Langer 2002
5
// Copyright Dietmar Kuehl 2001
6
// Copyright Vladimir Prus 2002
8
// Distributed under the Boost Software License, Version 1.0.
9
// See http://www.boost.org/LICENSE_1_0.txt
11
// Library home page: http://www.boost.org/libs/filesystem
13
//--------------------------------------------------------------------------------------//
15
#ifndef BOOST_FILESYSTEM3_OPERATIONS_HPP
16
#define BOOST_FILESYSTEM3_OPERATIONS_HPP
18
#include <boost/config.hpp>
20
# if defined( BOOST_NO_STD_WSTRING )
21
# error Configuration not supported: Boost.Filesystem V3 and later requires std::wstring support
24
#include <boost/filesystem/v3/config.hpp>
25
#include <boost/filesystem/v3/path.hpp>
27
#include <boost/detail/scoped_enum_emulation.hpp>
28
#include <boost/system/error_code.hpp>
29
#include <boost/system/system_error.hpp>
30
#include <boost/shared_ptr.hpp>
31
#include <boost/utility/enable_if.hpp>
32
#include <boost/type_traits/is_same.hpp>
33
#include <boost/iterator.hpp>
34
#include <boost/cstdint.hpp>
35
#include <boost/assert.hpp>
38
#include <utility> // for pair
43
#ifdef BOOST_WINDOWS_API
47
#include <boost/config/abi_prefix.hpp> // must be the last #include
49
//--------------------------------------------------------------------------------------//
56
//--------------------------------------------------------------------------------------//
58
// support classes and enums //
60
//--------------------------------------------------------------------------------------//
65
# ifndef BOOST_FILESYSTEM_NO_DEPRECATED
66
status_unknown = status_error,
71
// the following will never be reported by some operating or file systems
77
type_unknown // file does exist, but isn't one of the above types or
78
// we don't have strong enough permission to find its type
81
class BOOST_FILESYSTEM_DECL file_status
84
explicit file_status(file_type v = status_error) : m_value(v) {}
86
void type(file_type v) { m_value = v; }
87
file_type type() const { return m_value; }
89
bool operator==(const file_status& rhs) const { return type() == rhs.type(); }
90
bool operator!=(const file_status& rhs) const { return !(*this == rhs); }
93
// the internal representation is unspecified so that additional state
94
// information such as permissions can be added in the future; this
95
// implementation just uses file_type as the internal representation
100
inline bool status_known(file_status f) { return f.type() != status_error; }
101
inline bool exists(file_status f) { return f.type() != status_error
102
&& f.type() != file_not_found; }
103
inline bool is_regular_file(file_status f){ return f.type() == regular_file; }
104
inline bool is_directory(file_status f) { return f.type() == directory_file; }
105
inline bool is_symlink(file_status f) { return f.type() == symlink_file; }
106
inline bool is_other(file_status f) { return exists(f) && !is_regular_file(f)
107
&& !is_directory(f) && !is_symlink(f); }
109
# ifndef BOOST_FILESYSTEM_NO_DEPRECATED
110
inline bool is_regular(file_status f) { return f.type() == regular_file; }
115
// all values are byte counts
116
boost::uintmax_t capacity;
117
boost::uintmax_t free; // <= capacity
118
boost::uintmax_t available; // <= free
121
BOOST_SCOPED_ENUM_START(copy_option)
122
{fail_if_exists, overwrite_if_exists};
123
BOOST_SCOPED_ENUM_END
125
//--------------------------------------------------------------------------------------//
126
// implementation details //
127
//--------------------------------------------------------------------------------------//
131
BOOST_FILESYSTEM_DECL
132
file_status status(const path&p, system::error_code* ec=0);
133
BOOST_FILESYSTEM_DECL
134
file_status symlink_status(const path& p, system::error_code* ec=0);
135
BOOST_FILESYSTEM_DECL
136
bool is_empty(const path& p, system::error_code* ec=0);
137
BOOST_FILESYSTEM_DECL
138
path initial_path(system::error_code* ec=0);
139
BOOST_FILESYSTEM_DECL
140
void copy(const path& from, const path& to, system::error_code* ec=0);
141
BOOST_FILESYSTEM_DECL
142
void copy_directory(const path& from, const path& to, system::error_code* ec=0);
143
BOOST_FILESYSTEM_DECL
144
void copy_file(const path& from, const path& to,
145
BOOST_SCOPED_ENUM(copy_option) option, // See ticket #2925
146
system::error_code* ec=0);
147
BOOST_FILESYSTEM_DECL
148
void copy_symlink(const path& from, const path& to, system::error_code* ec=0);
149
BOOST_FILESYSTEM_DECL
150
bool create_directories(const path& p, system::error_code* ec=0);
151
BOOST_FILESYSTEM_DECL
152
bool create_directory(const path& p, system::error_code* ec=0);
153
BOOST_FILESYSTEM_DECL
154
void create_directory_symlink(const path& to, const path& from,
155
system::error_code* ec=0);
156
BOOST_FILESYSTEM_DECL
157
void create_hard_link(const path& to, const path& from, system::error_code* ec=0);
158
BOOST_FILESYSTEM_DECL
159
void create_symlink(const path& to, const path& from, system::error_code* ec=0);
160
BOOST_FILESYSTEM_DECL
161
path current_path(system::error_code* ec=0);
162
BOOST_FILESYSTEM_DECL
163
void current_path(const path& p, system::error_code* ec=0);
164
BOOST_FILESYSTEM_DECL
165
bool equivalent(const path& p1, const path& p2, system::error_code* ec=0);
166
BOOST_FILESYSTEM_DECL
167
boost::uintmax_t file_size(const path& p, system::error_code* ec=0);
168
BOOST_FILESYSTEM_DECL
169
boost::uintmax_t hard_link_count(const path& p, system::error_code* ec=0);
170
BOOST_FILESYSTEM_DECL
171
std::time_t last_write_time(const path& p, system::error_code* ec=0);
172
BOOST_FILESYSTEM_DECL
173
void last_write_time(const path& p, const std::time_t new_time,
174
system::error_code* ec=0);
175
BOOST_FILESYSTEM_DECL
176
path read_symlink(const path& p, system::error_code* ec=0);
177
BOOST_FILESYSTEM_DECL
178
// For standardization, if the committee doesn't like "remove", consider "eliminate"
179
bool remove(const path& p, system::error_code* ec=0);
180
BOOST_FILESYSTEM_DECL
181
boost::uintmax_t remove_all(const path& p, system::error_code* ec=0);
182
BOOST_FILESYSTEM_DECL
183
void rename(const path& old_p, const path& new_p, system::error_code* ec=0);
184
BOOST_FILESYSTEM_DECL
185
void resize_file(const path& p, uintmax_t size, system::error_code* ec=0);
186
BOOST_FILESYSTEM_DECL
187
space_info space(const path& p, system::error_code* ec=0);
188
BOOST_FILESYSTEM_DECL
189
path system_complete(const path& p, system::error_code* ec=0);
190
BOOST_FILESYSTEM_DECL
191
path unique_path(const path& p, system::error_code* ec=0);
192
} // namespace detail
194
//--------------------------------------------------------------------------------------//
196
// status query functions //
198
//--------------------------------------------------------------------------------------//
201
file_status status(const path& p) {return detail::status(p);}
203
file_status status(const path& p, system::error_code& ec)
204
{return detail::status(p, &ec);}
206
file_status symlink_status(const path& p) {return detail::symlink_status(p);}
208
file_status symlink_status(const path& p, system::error_code& ec)
209
{return detail::symlink_status(p, &ec);}
211
bool exists(const path& p) {return exists(detail::status(p));}
213
bool exists(const path& p, system::error_code& ec)
214
{return exists(detail::status(p, &ec));}
216
bool is_directory(const path& p) {return is_directory(detail::status(p));}
218
bool is_directory(const path& p, system::error_code& ec)
219
{return is_directory(detail::status(p, &ec));}
221
bool is_regular_file(const path& p) {return is_regular_file(detail::status(p));}
223
bool is_regular_file(const path& p, system::error_code& ec)
224
{return is_regular_file(detail::status(p, &ec));}
226
bool is_other(const path& p) {return is_other(detail::status(p));}
228
bool is_other(const path& p, system::error_code& ec)
229
{return is_other(detail::status(p, &ec));}
231
bool is_symlink(const path& p) {return is_symlink(detail::symlink_status(p));}
233
bool is_symlink(const path& p, system::error_code& ec)
234
{return is_symlink(detail::symlink_status(p, &ec));}
235
# ifndef BOOST_FILESYSTEM_NO_DEPRECATED
237
bool is_regular(const path& p) {return is_regular(detail::status(p));}
239
bool is_regular(const path& p, system::error_code& ec)
240
{return is_regular(detail::status(p, &ec));}
244
bool is_empty(const path& p) {return detail::is_empty(p);}
246
bool is_empty(const path& p, system::error_code& ec)
247
{return detail::is_empty(p, &ec);}
249
//--------------------------------------------------------------------------------------//
251
// operational functions //
252
// in alphabetical order, unless otherwise noted //
254
//--------------------------------------------------------------------------------------//
256
// forward declarations
257
path current_path(); // fwd declaration
258
# ifndef BOOST_FILESYSTEM_NO_DEPRECATED
262
BOOST_FILESYSTEM_DECL
263
path absolute(const path& p, const path& base=current_path());
264
// If base.is_absolute(), throws nothing. Thus no need for ec argument
266
# ifndef BOOST_FILESYSTEM_NO_DEPRECATED
268
path complete(const path& p)
270
return absolute(p, initial_path());
274
path complete(const path& p, const path& base)
276
return absolute(p, base);
281
void copy(const path& from, const path& to) {detail::copy(from, to);}
284
void copy(const path& from, const path& to, system::error_code& ec)
285
{detail::copy(from, to, &ec);}
287
void copy_directory(const path& from, const path& to)
288
{detail::copy_directory(from, to);}
290
void copy_directory(const path& from, const path& to, system::error_code& ec)
291
{detail::copy_directory(from, to, &ec);}
293
void copy_file(const path& from, const path& to, // See ticket #2925
294
BOOST_SCOPED_ENUM(copy_option) option)
295
{detail::copy_file(from, to, option);}
297
void copy_file(const path& from, const path& to)
298
{detail::copy_file(from, to, copy_option::fail_if_exists);}
300
void copy_file(const path& from, const path& to, // See ticket #2925
301
BOOST_SCOPED_ENUM(copy_option) option, system::error_code& ec)
302
{detail::copy_file(from, to, option, &ec);}
304
void copy_file(const path& from, const path& to, system::error_code& ec)
305
{detail::copy_file(from, to, copy_option::fail_if_exists, &ec);}
307
void copy_symlink(const path& from, const path& to) {detail::copy_symlink(from, to);}
310
void copy_symlink(const path& from, const path& to, system::error_code& ec)
311
{detail::copy_symlink(from, to, &ec);}
313
bool create_directories(const path& p) {return detail::create_directories(p);}
316
bool create_directories(const path& p, system::error_code& ec)
317
{return detail::create_directories(p, &ec);}
319
bool create_directory(const path& p) {return detail::create_directory(p);}
322
bool create_directory(const path& p, system::error_code& ec)
323
{return detail::create_directory(p, &ec);}
325
void create_directory_symlink(const path& to, const path& from)
326
{detail::create_directory_symlink(to, from);}
328
void create_directory_symlink(const path& to, const path& from, system::error_code& ec)
329
{detail::create_directory_symlink(to, from, &ec);}
331
void create_hard_link(const path& to, const path& from) {detail::create_hard_link(to, from);}
334
void create_hard_link(const path& to, const path& from, system::error_code& ec)
335
{detail::create_hard_link(to, from, &ec);}
337
void create_symlink(const path& to, const path& from) {detail::create_symlink(to, from);}
340
void create_symlink(const path& to, const path& from, system::error_code& ec)
341
{detail::create_symlink(to, from, &ec);}
343
path current_path() {return detail::current_path();}
346
path current_path(system::error_code& ec) {return detail::current_path(&ec);}
349
void current_path(const path& p) {detail::current_path(p);}
352
void current_path(const path& p, system::error_code& ec) {detail::current_path(p, &ec);}
355
bool equivalent(const path& p1, const path& p2) {return detail::equivalent(p1, p2);}
358
bool equivalent(const path& p1, const path& p2, system::error_code& ec)
359
{return detail::equivalent(p1, p2, &ec);}
361
boost::uintmax_t file_size(const path& p) {return detail::file_size(p);}
364
boost::uintmax_t file_size(const path& p, system::error_code& ec)
365
{return detail::file_size(p, &ec);}
367
boost::uintmax_t hard_link_count(const path& p) {return detail::hard_link_count(p);}
370
boost::uintmax_t hard_link_count(const path& p, system::error_code& ec)
371
{return detail::hard_link_count(p, &ec);}
372
# ifndef BOOST_FILESYSTEM_NO_DEPRECATED
374
path initial_path() {return detail::initial_path();}
377
path initial_path(system::error_code& ec) {return detail::initial_path(&ec);}
379
template <class Path>
380
path initial_path() {return initial_path();}
381
template <class Path>
382
path initial_path(system::error_code& ec) {return detail::initial_path(&ec);}
386
std::time_t last_write_time(const path& p) {return detail::last_write_time(p);}
389
std::time_t last_write_time(const path& p, system::error_code& ec)
390
{return detail::last_write_time(p, &ec);}
392
void last_write_time(const path& p, const std::time_t new_time)
393
{detail::last_write_time(p, new_time);}
395
void last_write_time(const path& p, const std::time_t new_time, system::error_code& ec)
396
{detail::last_write_time(p, new_time, &ec);}
398
path read_symlink(const path& p) {return detail::read_symlink(p);}
401
path read_symlink(const path& p, system::error_code& ec)
402
{return detail::read_symlink(p, &ec);}
404
// For standardization, if the committee doesn't like "remove", consider "eliminate"
405
bool remove(const path& p) {return detail::remove(p);}
408
bool remove(const path& p, system::error_code& ec) {return detail::remove(p, &ec);}
411
boost::uintmax_t remove_all(const path& p) {return detail::remove_all(p);}
414
boost::uintmax_t remove_all(const path& p, system::error_code& ec)
415
{return detail::remove_all(p, &ec);}
417
void rename(const path& old_p, const path& new_p) {detail::rename(old_p, new_p);}
420
void rename(const path& old_p, const path& new_p, system::error_code& ec)
421
{detail::rename(old_p, new_p, &ec);}
422
inline // name suggested by Scott McMurray
423
void resize_file(const path& p, uintmax_t size) {detail::resize_file(p, size);}
426
void resize_file(const path& p, uintmax_t size, system::error_code& ec)
427
{detail::resize_file(p, size, &ec);}
429
space_info space(const path& p) {return detail::space(p);}
432
space_info space(const path& p, system::error_code& ec) {return detail::space(p, &ec);}
434
# ifndef BOOST_FILESYSTEM_NO_DEPRECATED
435
inline bool symbolic_link_exists(const path& p)
436
{ return is_symlink(symlink_status(p)); }
440
path system_complete(const path& p) {return detail::system_complete(p);}
443
path system_complete(const path& p, system::error_code& ec)
444
{return detail::system_complete(p, &ec);}
446
path unique_path(const path& p="%%%%-%%%%-%%%%-%%%%")
447
{ return detail::unique_path(p); }
449
path unique_path(const path& p, system::error_code& ec)
450
{ return detail::unique_path(p, &ec); }
452
//--------------------------------------------------------------------------------------//
454
// directory_entry //
456
//--------------------------------------------------------------------------------------//
458
// GCC has a problem with a member function named path within a namespace or
459
// sub-namespace that also has a class named path. The workaround is to always
460
// fully qualify the name path when it refers to the class name.
462
class BOOST_FILESYSTEM_DECL directory_entry
466
// compiler generated copy constructor, copy assignment, and destructor apply
469
explicit directory_entry(const boost::filesystem::path& p,
470
file_status st = file_status(), file_status symlink_st=file_status())
471
: m_path(p), m_status(st), m_symlink_status(symlink_st)
474
void assign(const boost::filesystem::path& p,
475
file_status st = file_status(), file_status symlink_st = file_status())
476
{ m_path = p; m_status = st; m_symlink_status = symlink_st; }
478
void replace_filename(const boost::filesystem::path& p,
479
file_status st = file_status(), file_status symlink_st = file_status())
481
m_path.remove_filename();
484
m_symlink_status = symlink_st;
487
# ifndef BOOST_FILESYSTEM_NO_DEPRECATED
488
void replace_leaf(const boost::filesystem::path& p,
489
file_status st, file_status symlink_st)
490
{ replace_filename(p, st, symlink_st); }
493
const boost::filesystem::path& path() const {return m_path;}
494
file_status status() const {return m_get_status();}
495
file_status status(system::error_code& ec) const {return m_get_status(&ec);}
496
file_status symlink_status() const {return m_get_symlink_status();}
497
file_status symlink_status(system::error_code& ec) const {return m_get_symlink_status(&ec);}
499
bool operator==(const directory_entry& rhs) {return m_path == rhs.m_path;}
500
bool operator!=(const directory_entry& rhs) {return m_path != rhs.m_path;}
501
bool operator< (const directory_entry& rhs) {return m_path < rhs.m_path;}
502
bool operator<=(const directory_entry& rhs) {return m_path <= rhs.m_path;}
503
bool operator> (const directory_entry& rhs) {return m_path > rhs.m_path;}
504
bool operator>=(const directory_entry& rhs) {return m_path >= rhs.m_path;}
507
boost::filesystem::path m_path;
508
mutable file_status m_status; // stat()-like
509
mutable file_status m_symlink_status; // lstat()-like
511
file_status m_get_status(system::error_code* ec=0) const;
512
file_status m_get_symlink_status(system::error_code* ec=0) const;
513
}; // directory_entry
515
//--------------------------------------------------------------------------------------//
517
// directory_iterator helpers //
519
//--------------------------------------------------------------------------------------//
521
class directory_iterator;
525
BOOST_FILESYSTEM_DECL
526
system::error_code dir_itr_close(// never throws()
528
# if defined(BOOST_POSIX_API)
535
directory_entry dir_entry;
538
# ifdef BOOST_POSIX_API
539
void* buffer; // see dir_itr_increment implementation
542
dir_itr_imp() : handle(0)
543
# ifdef BOOST_POSIX_API
548
~dir_itr_imp() // never throws
551
# if defined(BOOST_POSIX_API)
558
// see path::iterator: comment below
559
BOOST_FILESYSTEM_DECL void directory_iterator_construct(directory_iterator& it,
560
const path& p, system::error_code* ec);
561
BOOST_FILESYSTEM_DECL void directory_iterator_increment(directory_iterator& it,
562
system::error_code* ec);
564
} // namespace detail
566
//--------------------------------------------------------------------------------------//
568
// directory_iterator //
570
//--------------------------------------------------------------------------------------//
572
class directory_iterator
573
: public boost::iterator_facade< directory_iterator,
575
boost::single_pass_traversal_tag >
579
directory_iterator(){} // creates the "end" iterator
581
// iterator_facade derived classes don't seem to like implementations in
582
// separate translation unit dll's, so forward to detail functions
583
explicit directory_iterator(const path& p)
584
: m_imp(new detail::dir_itr_imp)
585
{ detail::directory_iterator_construct(*this, p, 0); }
587
directory_iterator(const path& p, system::error_code& ec)
588
: m_imp(new detail::dir_itr_imp)
589
{ detail::directory_iterator_construct(*this, p, &ec); }
591
~directory_iterator() {} // never throws
593
directory_iterator& increment(system::error_code& ec)
595
detail::directory_iterator_increment(*this, &ec);
600
friend struct detail::dir_itr_imp;
601
friend BOOST_FILESYSTEM_DECL void detail::directory_iterator_construct(directory_iterator& it,
602
const path& p, system::error_code* ec);
603
friend BOOST_FILESYSTEM_DECL void detail::directory_iterator_increment(directory_iterator& it,
604
system::error_code* ec);
606
// shared_ptr provides shallow-copy semantics required for InputIterators.
607
// m_imp.get()==0 indicates the end iterator.
608
boost::shared_ptr< detail::dir_itr_imp > m_imp;
610
friend class boost::iterator_core_access;
612
boost::iterator_facade<
615
boost::single_pass_traversal_tag >::reference dereference() const
617
BOOST_ASSERT(m_imp.get() && "attempt to dereference end iterator");
618
return m_imp->dir_entry;
621
void increment() { detail::directory_iterator_increment(*this, 0); }
623
bool equal(const directory_iterator& rhs) const
624
{ return m_imp == rhs.m_imp; }
627
//--------------------------------------------------------------------------------------//
629
// recursive_directory_iterator helpers //
631
//--------------------------------------------------------------------------------------//
635
struct recur_dir_itr_imp
637
typedef directory_iterator element_type;
638
std::stack< element_type, std::vector< element_type > > m_stack;
640
bool m_no_push_request;
642
recur_dir_itr_imp() : m_level(0), m_no_push_request(false) {}
644
void increment(system::error_code* ec); // ec == 0 means throw on error
650
// Implementation is inline to avoid dynamic linking difficulties with m_stack:
651
// Microsoft warning C4251, m_stack needs to have dll-interface to be used by
652
// clients of struct 'boost::filesystem::detail::recur_dir_itr_imp'
655
void recur_dir_itr_imp::increment(system::error_code* ec)
656
// ec == 0 means throw on error
658
if (m_no_push_request)
659
{ m_no_push_request = false; }
660
else if (is_directory(m_stack.top()->status()))
663
m_stack.push(directory_iterator(m_stack.top()->path()));
666
m_stack.push(directory_iterator(m_stack.top()->path(), *ec));
669
if (m_stack.top() != directory_iterator())
677
while (!m_stack.empty() && ++m_stack.top() == directory_iterator())
685
void recur_dir_itr_imp::pop()
687
BOOST_ASSERT(m_level > 0 && "pop() on recursive_directory_iterator with level < 1");
694
while (!m_stack.empty() && ++m_stack.top() == directory_iterator());
696
} // namespace detail
698
//--------------------------------------------------------------------------------------//
700
// recursive_directory_iterator //
702
//--------------------------------------------------------------------------------------//
704
class recursive_directory_iterator
705
: public boost::iterator_facade<
706
recursive_directory_iterator,
708
boost::single_pass_traversal_tag >
712
recursive_directory_iterator(){} // creates the "end" iterator
714
explicit recursive_directory_iterator(const path& dir_path)
715
: m_imp(new detail::recur_dir_itr_imp)
717
m_imp->m_stack.push(directory_iterator(dir_path));
718
if (m_imp->m_stack.top() == directory_iterator())
722
recursive_directory_iterator(const path& dir_path,
723
system::error_code & ec)
724
: m_imp(new detail::recur_dir_itr_imp)
726
m_imp->m_stack.push(directory_iterator(dir_path, ec));
727
if (m_imp->m_stack.top() == directory_iterator())
731
recursive_directory_iterator& increment(system::error_code* ec)
733
BOOST_ASSERT(m_imp.get() && "increment() on end recursive_directory_iterator");
734
m_imp->increment(ec);
740
BOOST_ASSERT(m_imp.get() && "level() on end recursive_directory_iterator");
741
return m_imp->m_level;
744
bool no_push_request() const
746
BOOST_ASSERT(m_imp.get() && "no_push_request() on end recursive_directory_iterator");
747
return m_imp->m_no_push_request;
752
BOOST_ASSERT(m_imp.get() && "pop() on end recursive_directory_iterator");
754
if (m_imp->m_stack.empty()) m_imp.reset(); // done, so make end iterator
759
BOOST_ASSERT(m_imp.get() && "no_push() on end recursive_directory_iterator");
760
m_imp->m_no_push_request = true;
763
file_status status() const
765
BOOST_ASSERT(m_imp.get()
766
&& "status() on end recursive_directory_iterator");
767
return m_imp->m_stack.top()->status();
770
file_status symlink_status() const
772
BOOST_ASSERT(m_imp.get()
773
&& "symlink_status() on end recursive_directory_iterator");
774
return m_imp->m_stack.top()->symlink_status();
779
// shared_ptr provides shallow-copy semantics required for InputIterators.
780
// m_imp.get()==0 indicates the end iterator.
781
boost::shared_ptr< detail::recur_dir_itr_imp > m_imp;
783
friend class boost::iterator_core_access;
785
boost::iterator_facade<
786
recursive_directory_iterator,
788
boost::single_pass_traversal_tag >::reference
791
BOOST_ASSERT(m_imp.get() && "dereference of end recursive_directory_iterator");
792
return *m_imp->m_stack.top();
797
BOOST_ASSERT(m_imp.get() && "increment of end recursive_directory_iterator");
799
if (m_imp->m_stack.empty()) m_imp.reset(); // done, so make end iterator
802
bool equal(const recursive_directory_iterator& rhs) const
803
{ return m_imp == rhs.m_imp; }
807
# if !defined(BOOST_FILESYSTEM_NO_DEPRECATED)
808
typedef recursive_directory_iterator wrecursive_directory_iterator;
811
//--------------------------------------------------------------------------------------//
813
// class filesystem_error //
815
//--------------------------------------------------------------------------------------//
817
class BOOST_SYMBOL_VISIBLE filesystem_error : public system::system_error
819
// see http://www.boost.org/more/error_handling.html for design rationale
821
// all functions are inline to avoid issues with crossing dll boundaries
824
// compiler generates copy constructor and copy assignment
827
const std::string & what_arg, system::error_code ec)
828
: system::system_error(ec, what_arg)
832
m_imp_ptr.reset(new m_imp);
834
catch (...) { m_imp_ptr.reset(); }
838
const std::string & what_arg, const path& path1_arg,
839
system::error_code ec)
840
: system::system_error(ec, what_arg)
844
m_imp_ptr.reset(new m_imp);
845
m_imp_ptr->m_path1 = path1_arg;
847
catch (...) { m_imp_ptr.reset(); }
851
const std::string & what_arg, const path& path1_arg,
852
const path& path2_arg, system::error_code ec)
853
: system::system_error(ec, what_arg)
857
m_imp_ptr.reset(new m_imp);
858
m_imp_ptr->m_path1 = path1_arg;
859
m_imp_ptr->m_path2 = path2_arg;
861
catch (...) { m_imp_ptr.reset(); }
864
~filesystem_error() throw() {}
866
const path& path1() const
868
static const path empty_path;
869
return m_imp_ptr.get() ? m_imp_ptr->m_path1 : empty_path ;
871
const path& path2() const
873
static const path empty_path;
874
return m_imp_ptr.get() ? m_imp_ptr->m_path2 : empty_path ;
877
const char* what() const throw()
879
if (!m_imp_ptr.get())
880
return system::system_error::what();
884
if (m_imp_ptr->m_what.empty())
886
m_imp_ptr->m_what = system::system_error::what();
887
if (!m_imp_ptr->m_path1.empty())
889
m_imp_ptr->m_what += ": \"";
890
m_imp_ptr->m_what += m_imp_ptr->m_path1.string();
891
m_imp_ptr->m_what += "\"";
893
if (!m_imp_ptr->m_path2.empty())
895
m_imp_ptr->m_what += ", \"";
896
m_imp_ptr->m_what += m_imp_ptr->m_path2.string();
897
m_imp_ptr->m_what += "\"";
900
return m_imp_ptr->m_what.c_str();
904
return system::system_error::what();
911
path m_path1; // may be empty()
912
path m_path2; // may be empty()
913
std::string m_what; // not built until needed
915
boost::shared_ptr<m_imp> m_imp_ptr;
918
// test helper -----------------------------------------------------------------------//
920
// Not part of the documented interface since false positives are possible;
921
// there is no law that says that an OS that has large stat.st_size
922
// actually supports large file sizes.
926
BOOST_FILESYSTEM_DECL bool possible_large_file_size_support();
929
} // namespace filesystem3
932
//----------------------------------------------------------------------------//
938
using filesystem3::absolute;
939
using filesystem3::block_file;
940
using filesystem3::character_file;
941
using filesystem3::copy_file;
942
using filesystem3::copy_option;
943
using filesystem3::copy_symlink;
944
using filesystem3::create_directories;
945
using filesystem3::create_directory;
946
using filesystem3::create_hard_link;
947
using filesystem3::create_symlink;
948
using filesystem3::current_path;
949
using filesystem3::directory_entry;
950
using filesystem3::directory_file;
951
using filesystem3::directory_iterator;
952
using filesystem3::equivalent;
953
using filesystem3::exists;
954
using filesystem3::fifo_file;
955
using filesystem3::file_not_found;
956
using filesystem3::file_size;
957
using filesystem3::file_status;
958
using filesystem3::file_type;
959
using filesystem3::filesystem_error;
960
using filesystem3::hard_link_count;
961
using filesystem3::is_directory;
962
using filesystem3::is_directory;
963
using filesystem3::is_empty;
964
using filesystem3::is_other;
965
using filesystem3::is_regular_file;
966
using filesystem3::is_symlink;
967
using filesystem3::last_write_time;
968
using filesystem3::read_symlink;
969
using filesystem3::recursive_directory_iterator;
970
using filesystem3::regular_file;
971
using filesystem3::remove;
972
using filesystem3::remove_all;
973
using filesystem3::rename;
974
using filesystem3::resize_file;
975
using filesystem3::socket_file;
976
using filesystem3::space;
977
using filesystem3::space_info;
978
using filesystem3::status;
979
using filesystem3::status_error;
980
using filesystem3::status_known;
981
using filesystem3::symlink_file;
982
using filesystem3::symlink_status;
983
using filesystem3::system_complete;
984
using filesystem3::type_unknown;
985
using filesystem3::unique_path;
986
# ifndef BOOST_FILESYSTEM_NO_DEPRECATED
987
using filesystem3::initial_path;
988
using filesystem3::is_regular;
989
using filesystem3::status_unknown;
990
using filesystem3::symbolic_link_exists;
991
//using filesystem3::wdirectory_iterator;
992
//using filesystem3::wdirectory_entry;
996
using filesystem3::detail::possible_large_file_size_support;
1001
#include <boost/config/abi_suffix.hpp> // pops abi_prefix.hpp pragmas
1002
#endif // BOOST_FILESYSTEM3_OPERATIONS_HPP