1 // boost/filesystem/directory.hpp ------------------------------------------//
3 // < ----------------------------------------------------------------------- >
4 // < Copyright © 2002 Beman Dawes. >
5 // < Copyright © 2002 Jan Langer. >
6 // < Copyright © 2001 Dietmar Kühl, All Rights Reserved >
8 // < Permission to use, copy, modify, distribute and sell this >
9 // < software for any purpose is hereby granted without fee, provided >
10 // < that the above copyright notice appears in all copies and that >
11 // < both that copyright notice and this permission notice appear in >
12 // < supporting documentation. The authors make no representations about >
13 // < the suitability of this software for any purpose. It is provided >
14 // < "as is" without express or implied warranty. >
15 // < ----------------------------------------------------------------------- >
17 // See http://www.boost.org/libs/filesystem for documentation.
19 //----------------------------------------------------------------------------//
21 #ifndef BOOST_FILESYSTEM_DIRECTORY_HPP
22 #define BOOST_FILESYSTEM_DIRECTORY_HPP
24 #include <boost/config.hpp>
25 #include <boost/filesystem/path.hpp>
26 #include <boost/shared_ptr.hpp>
27 #include <boost/iterator.hpp>
31 //----------------------------------------------------------------------------//
38 // query functions ---------------------------------------------------------//
40 bool exists( const path & ph );
42 bool is_directory( const path & ph );
44 // VC++ 7.0 and earlier has a serious namespace bug that causes a clash
45 // between boost::filesystem::is_empty and the unrelated type trait
46 // boost::is_empty. The workaround for those who must use broken versions
47 // of VC++ is to use the function _is_empty. All others should use the
48 // correct is_empty name.
49 bool _is_empty( const path & ph ); // deprecated
51 # if !defined( BOOST_MSVC ) || BOOST_MSVC > 1300
52 inline bool is_empty( const path & ph ) { return _is_empty( ph ); }
55 // operations --------------------------------------------------------------//
57 void create_directory( const path & directory_ph );
59 bool remove( const path & ph );
60 unsigned long remove_all( const path & ph );
62 void rename( const path & from_path,
63 const path & to_path );
65 void copy_file( const path & from_file_ph,
66 const path & to_file_ph );
69 const path & initial_path();
71 path system_complete( const path & ph );
72 path complete( const path & ph, const path & base = initial_path() );
74 // directory_iterator ------------------------------------------------------//
76 class directory_iterator
77 : public boost::iterator< std::input_iterator_tag,
78 path, std::ptrdiff_t, const path *, const path & >
81 typedef directory_iterator self;
83 directory_iterator(); // creates the "end" iterator
84 explicit directory_iterator( const path & p );
86 reference operator*() const { return m_deref(); }
87 pointer operator->() const { return &m_deref(); }
88 self & operator++() { m_inc(); return *this; }
90 friend bool operator==( const self & x, const self & y )
91 { return x.m_imp == y.m_imp; }
92 friend bool operator!=( const self & x, const self & y )
93 { return !(x.m_imp == y.m_imp); }
95 struct path_proxy // allows *i++ to work, as required by std
98 explicit path_proxy( const path & p ) : pv(p) {}
99 path operator*() const { return pv; }
102 path_proxy operator++(int)
104 path_proxy pp( m_deref() );
111 // shared_ptr provides shallow-copy semantics required for InputIterators
112 typedef boost::shared_ptr< dir_itr_imp > m_imp_ptr;
114 reference m_deref() const;
118 } // namespace filesystem
121 #endif // BOOST_FILESYSTEM_DIRECTORY_HPP