~ubuntu-branches/ubuntu/warty/aqsis/warty

« back to all changes in this revision

Viewing changes to boost/boost/filesystem/operations.hpp

  • Committer: Bazaar Package Importer
  • Author(s): LaMont Jones
  • Date: 2004-08-24 07:25:04 UTC
  • Revision ID: james.westby@ubuntu.com-20040824072504-zf993vnevvisdsvb
Tags: upstream-0.9.1
Import upstream version 0.9.1

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
//  boost/filesystem/directory.hpp  ------------------------------------------//
 
2
 
 
3
// < ----------------------------------------------------------------------- > 
 
4
// <   Copyright � 2002 Beman Dawes.                                         >
 
5
// <   Copyright � 2002 Jan Langer.                                          >
 
6
// <   Copyright � 2001 Dietmar K�hl, All Rights Reserved                    >
 
7
// <                                                                         > 
 
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
// < ----------------------------------------------------------------------- > 
 
16
 
 
17
//  See http://www.boost.org/libs/filesystem for documentation.
 
18
 
 
19
//----------------------------------------------------------------------------// 
 
20
 
 
21
#ifndef BOOST_FILESYSTEM_DIRECTORY_HPP
 
22
#define BOOST_FILESYSTEM_DIRECTORY_HPP
 
23
 
 
24
#include <boost/config.hpp>
 
25
#include <boost/filesystem/path.hpp>
 
26
#include <boost/shared_ptr.hpp>
 
27
#include <boost/iterator.hpp>
 
28
 
 
29
#include <string>
 
30
 
 
31
//----------------------------------------------------------------------------//
 
32
 
 
33
namespace boost
 
34
{
 
35
  namespace filesystem
 
36
  {
 
37
 
 
38
//  query functions  ---------------------------------------------------------//
 
39
 
 
40
    bool exists( const path & ph );
 
41
 
 
42
    bool is_directory( const path & ph );
 
43
 
 
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
 
50
 
 
51
#   if !defined( BOOST_MSVC ) || BOOST_MSVC > 1300
 
52
    inline bool is_empty( const path & ph ) { return _is_empty( ph ); }
 
53
#   endif
 
54
 
 
55
//  operations  --------------------------------------------------------------//
 
56
 
 
57
    void create_directory( const path & directory_ph );
 
58
 
 
59
    bool remove( const path & ph );
 
60
    unsigned long remove_all( const path & ph );
 
61
 
 
62
    void rename( const path & from_path,
 
63
                 const path & to_path );
 
64
 
 
65
    void copy_file( const path & from_file_ph,
 
66
                    const path & to_file_ph );
 
67
 
 
68
    path          current_path();
 
69
    const path &  initial_path();
 
70
 
 
71
    path          system_complete( const path & ph );
 
72
    path          complete( const path & ph, const path & base = initial_path() );
 
73
 
 
74
//  directory_iterator  ------------------------------------------------------//
 
75
 
 
76
    class directory_iterator
 
77
      : public boost::iterator< std::input_iterator_tag,
 
78
          path, std::ptrdiff_t, const path *, const path & >
 
79
    {
 
80
    private:
 
81
      typedef directory_iterator self;
 
82
    public:
 
83
      directory_iterator();  // creates the "end" iterator
 
84
      explicit directory_iterator( const path & p );
 
85
 
 
86
      reference operator*() const { return m_deref(); }
 
87
      pointer   operator->() const { return &m_deref(); }
 
88
      self &    operator++() { m_inc(); return *this; }
 
89
 
 
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); }
 
94
 
 
95
      struct path_proxy // allows *i++ to work, as required by std
 
96
      {
 
97
        path pv;
 
98
        explicit path_proxy( const path & p ) : pv(p) {}
 
99
        path operator*() const { return pv; }
 
100
      };
 
101
 
 
102
      path_proxy operator++(int)
 
103
      {
 
104
        path_proxy pp( m_deref() );
 
105
        ++*this;
 
106
        return pp;
 
107
      }
 
108
 
 
109
    private:
 
110
      class dir_itr_imp;
 
111
      // shared_ptr provides shallow-copy semantics required for InputIterators
 
112
      typedef boost::shared_ptr< dir_itr_imp > m_imp_ptr;
 
113
      m_imp_ptr  m_imp;
 
114
      reference  m_deref() const;
 
115
      void       m_inc();
 
116
    };
 
117
 
 
118
  } // namespace filesystem
 
119
} // namespace boost
 
120
 
 
121
#endif // BOOST_FILESYSTEM_DIRECTORY_HPP