56 |
|
|
57 |
namespace boost |
namespace boost |
58 |
{ |
{ |
59 |
namespace filesystem |
namespace filesystem |
60 |
{ |
{ |
61 |
class dir_it; |
class dir_it; |
62 |
|
|
63 |
#if defined(__GNUG__) |
#if defined(__GNUG__) |
64 |
template <class Property> |
template <class Property> |
65 |
typename Property::value_type get(dir_it const &); |
typename Property::value_type get(dir_it const &); |
66 |
template <class Property> |
template <class Property> |
67 |
void set(dir_it const &, typename Property::value_type); |
void set(dir_it const &, typename Property::value_type); |
68 |
#else |
#else |
69 |
template <class Property> class get; |
template <class Property> class get; |
70 |
template <class Property> class set; |
template <class Property> class set; |
71 |
#endif |
#endif |
72 |
|
|
73 |
class BOOST_DECL dir_it //: public std::iterator<std::input_iterator_tag, std::string> |
class BOOST_DECL dir_it //: public std::iterator<std::input_iterator_tag, std::string> |
74 |
{ |
{ |
75 |
#if defined(__GNUG__) |
#if defined(__GNUG__) |
76 |
template <class Property> |
template <class Property> |
77 |
friend typename Property::value_type get(dir_it const &); |
friend typename Property::value_type get(dir_it const &); |
78 |
template <class Property> |
template <class Property> |
79 |
friend void set(dir_it const &, typename Property::value_type); |
friend void set(dir_it const &, typename Property::value_type); |
80 |
#endif |
#endif |
81 |
|
|
82 |
struct representation; |
struct representation; |
83 |
|
|
84 |
public: |
public: |
85 |
typedef ptrdiff_t difference_type; |
typedef ptrdiff_t difference_type; |
86 |
typedef std::string value_type; |
typedef std::string value_type; |
87 |
typedef std::string *pointer; |
typedef std::string *pointer; |
88 |
typedef std::string &reference; |
typedef std::string &reference; |
89 |
|
|
90 |
class proxy |
class proxy |
91 |
{ |
{ |
92 |
friend class dir_it; |
friend class dir_it; |
93 |
proxy(std::string const &ent): entry(ent) {} |
proxy(std::string const &ent): entry(ent) {} |
94 |
public: |
public: |
95 |
std::string operator*() const { return entry; } |
std::string operator*() const { return entry; } |
96 |
private: |
private: |
97 |
std::string entry; |
std::string entry; |
98 |
}; |
}; |
99 |
|
|
100 |
dir_it(); |
dir_it(); |
101 |
dir_it(std::string const &); |
dir_it(std::string const &); |
102 |
dir_it(dir_it const &); |
dir_it(dir_it const &); |
103 |
~dir_it(); |
~dir_it(); |
104 |
dir_it &operator= (dir_it const &); |
dir_it &operator= (dir_it const &); |
105 |
|
|
106 |
std::string operator* () const; |
std::string operator* () const; |
107 |
dir_it &operator++ (); |
dir_it &operator++ (); |
108 |
proxy operator++ (int); |
proxy operator++ (int); |
109 |
|
|
110 |
bool operator== (dir_it const &) const; |
bool operator== (dir_it const &) const; |
111 |
bool operator!= (dir_it const &) const; |
bool operator!= (dir_it const &) const; |
112 |
|
|
113 |
#if defined(__GNUG__) |
#if defined(__GNUG__) |
114 |
private: |
private: |
115 |
#endif |
#endif |
116 |
representation *rep; |
representation *rep; |
117 |
}; |
}; |
118 |
|
|
119 |
struct size { typedef size_t value_type; }; |
struct size { typedef size_t value_type; }; |
120 |
struct mtime { typedef time_t const *value_type; }; |
struct mtime { typedef time_t const *value_type; }; |
121 |
|
|
122 |
struct is_directory { typedef bool value_type; }; |
struct is_directory { typedef bool value_type; }; |
123 |
struct is_regular { typedef bool value_type; }; |
struct is_regular { typedef bool value_type; }; |
124 |
struct is_hidden { typedef bool value_type; }; |
struct is_hidden { typedef bool value_type; }; |
125 |
|
|
126 |
struct user_read { typedef bool value_type; }; |
struct user_read { typedef bool value_type; }; |
127 |
struct user_write { typedef bool value_type; }; |
struct user_write { typedef bool value_type; }; |
128 |
struct user_execute { typedef bool value_type; }; |
struct user_execute { typedef bool value_type; }; |
129 |
|
|
130 |
#if defined(__GNUG__) |
#if defined(__GNUG__) |
131 |
template <> size::value_type get<size>(dir_it const &); |
template <> size::value_type get<size>(dir_it const &); |
132 |
template <> mtime::value_type get<mtime>(dir_it const &); |
template <> mtime::value_type get<mtime>(dir_it const &); |
133 |
template <> bool get<is_directory>(dir_it const &); |
template <> bool get<is_directory>(dir_it const &); |
134 |
template <> bool get<is_regular>(dir_it const &); |
template <> bool get<is_regular>(dir_it const &); |
135 |
template <> bool get<is_hidden>(dir_it const &); |
template <> bool get<is_hidden>(dir_it const &); |
136 |
template <> bool get<user_read>(dir_it const &); |
template <> bool get<user_read>(dir_it const &); |
137 |
template <> void set<user_read>(dir_it const &, bool); |
template <> void set<user_read>(dir_it const &, bool); |
138 |
template <> bool get<user_write>(dir_it const &); |
template <> bool get<user_write>(dir_it const &); |
139 |
template <> void set<user_write>(dir_it const &, bool); |
template <> void set<user_write>(dir_it const &, bool); |
140 |
template <> bool get<user_execute>(dir_it const &); |
template <> bool get<user_execute>(dir_it const &); |
141 |
template <> void set<user_execute>(dir_it const &, bool); |
template <> void set<user_execute>(dir_it const &, bool); |
142 |
#else |
#else |
143 |
template <> class BOOST_DECL get<size> |
template <> class BOOST_DECL get<size> |
144 |
{ |
{ |
145 |
typedef size::value_type value_type; |
typedef size::value_type value_type; |
146 |
public: |
public: |
147 |
get(dir_it const &it): m_it(it) {} |
get(dir_it const &it): m_it(it) {} |
148 |
operator value_type() const; |
operator value_type() const; |
149 |
private: |
private: |
150 |
dir_it const &m_it; |
dir_it const &m_it; |
151 |
}; |
}; |
152 |
|
|
153 |
template <> class BOOST_DECL get<mtime> |
template <> class BOOST_DECL get<mtime> |
154 |
{ |
{ |
155 |
typedef mtime::value_type value_type; |
typedef mtime::value_type value_type; |
156 |
public: |
public: |
157 |
get(dir_it const &it): m_it(it) {} |
get(dir_it const &it): m_it(it) {} |
158 |
operator value_type() const; |
operator value_type() const; |
159 |
private: |
private: |
160 |
dir_it const &m_it; |
dir_it const &m_it; |
161 |
}; |
}; |
162 |
|
|
163 |
template <> class BOOST_DECL get<is_directory> |
template <> class BOOST_DECL get<is_directory> |
164 |
{ |
{ |
165 |
typedef is_directory::value_type value_type; |
typedef is_directory::value_type value_type; |
166 |
public: |
public: |
167 |
get(dir_it const &it): m_it(it) {} |
get(dir_it const &it): m_it(it) {} |
168 |
operator value_type() const; |
operator value_type() const; |
169 |
private: |
private: |
170 |
dir_it const &m_it; |
dir_it const &m_it; |
171 |
}; |
}; |
172 |
|
|
173 |
template <> class BOOST_DECL get<is_regular> |
template <> class BOOST_DECL get<is_regular> |
174 |
{ |
{ |
175 |
typedef is_regular::value_type value_type; |
typedef is_regular::value_type value_type; |
176 |
public: |
public: |
177 |
get(dir_it const &it): m_it(it) {} |
get(dir_it const &it): m_it(it) {} |
178 |
operator value_type() const; |
operator value_type() const; |
179 |
private: |
private: |
180 |
dir_it const &m_it; |
dir_it const &m_it; |
181 |
}; |
}; |
182 |
|
|
183 |
template <> class BOOST_DECL get<is_hidden> |
template <> class BOOST_DECL get<is_hidden> |
184 |
{ |
{ |
185 |
typedef is_hidden::value_type value_type; |
typedef is_hidden::value_type value_type; |
186 |
public: |
public: |
187 |
get(dir_it const &it): m_it(it) {} |
get(dir_it const &it): m_it(it) {} |
188 |
operator value_type() const; |
operator value_type() const; |
189 |
private: |
private: |
190 |
dir_it const &m_it; |
dir_it const &m_it; |
191 |
}; |
}; |
192 |
template <> class BOOST_DECL set<is_hidden> |
template <> class BOOST_DECL set<is_hidden> |
193 |
{ |
{ |
194 |
public: |
public: |
195 |
set(dir_it const &, is_hidden::value_type); |
set(dir_it const &, is_hidden::value_type); |
196 |
}; |
}; |
197 |
|
|
198 |
template <> class BOOST_DECL get<user_read> |
template <> class BOOST_DECL get<user_read> |
199 |
{ |
{ |
200 |
typedef user_read::value_type value_type; |
typedef user_read::value_type value_type; |
201 |
public: |
public: |
202 |
get(dir_it const &it): m_it(it) {} |
get(dir_it const &it): m_it(it) {} |
203 |
operator value_type() const; |
operator value_type() const; |
204 |
private: |
private: |
205 |
dir_it const &m_it; |
dir_it const &m_it; |
206 |
}; |
}; |
207 |
|
|
208 |
template <> class BOOST_DECL get<user_write> |
template <> class BOOST_DECL get<user_write> |
209 |
{ |
{ |
210 |
typedef user_write::value_type value_type; |
typedef user_write::value_type value_type; |
211 |
public: |
public: |
212 |
get(dir_it const &it): m_it(it) {} |
get(dir_it const &it): m_it(it) {} |
213 |
operator value_type() const; |
operator value_type() const; |
214 |
private: |
private: |
215 |
dir_it const &m_it; |
dir_it const &m_it; |
216 |
}; |
}; |
217 |
template <> class BOOST_DECL set<user_write> |
template <> class BOOST_DECL set<user_write> |
218 |
{ |
{ |
219 |
public: |
public: |
220 |
set(dir_it const &, user_write::value_type); |
set(dir_it const &, user_write::value_type); |
221 |
}; |
}; |
222 |
|
|
223 |
template <> class BOOST_DECL get<user_execute> |
template <> class BOOST_DECL get<user_execute> |
224 |
{ |
{ |
225 |
typedef user_execute::value_type value_type; |
typedef user_execute::value_type value_type; |
226 |
public: |
public: |
227 |
get(dir_it const &it): m_it(it) {} |
get(dir_it const &it): m_it(it) {} |
228 |
operator value_type() const; |
operator value_type() const; |
229 |
private: |
private: |
230 |
dir_it const &m_it; |
dir_it const &m_it; |
231 |
}; |
}; |
232 |
|
|
233 |
#endif |
#endif |
234 |
|
|
235 |
#if defined(unix) || defined(__unix) || defined(__unix__) |
#if defined(unix) || defined(__unix) || defined(__unix__) |
236 |
|
|
237 |
struct is_link { typedef bool value_type; }; |
struct is_link { typedef bool value_type; }; |
238 |
template <> bool get<is_link>(dir_it const &); |
template <> bool get<is_link>(dir_it const &); |
239 |
|
|
240 |
struct is_char_device { typedef bool value_type; }; |
struct is_char_device { typedef bool value_type; }; |
241 |
template <> bool get<is_char_device>(dir_it const &); |
template <> bool get<is_char_device>(dir_it const &); |
242 |
|
|
243 |
struct is_block_device { typedef bool value_type; }; |
struct is_block_device { typedef bool value_type; }; |
244 |
template <> bool get<is_block_device>(dir_it const &); |
template <> bool get<is_block_device>(dir_it const &); |
245 |
|
|
246 |
struct is_fifo { typedef bool value_type; }; |
struct is_fifo { typedef bool value_type; }; |
247 |
template <> bool get<is_fifo>(dir_it const &); |
template <> bool get<is_fifo>(dir_it const &); |
248 |
|
|
249 |
struct is_socket { typedef bool value_type; }; |
struct is_socket { typedef bool value_type; }; |
250 |
template <> bool get<is_socket>(dir_it const &); |
template <> bool get<is_socket>(dir_it const &); |
251 |
|
|
252 |
struct atime { typedef time_t *value_type; }; |
struct atime { typedef time_t *value_type; }; |
253 |
template <> atime::value_type get<atime>(dir_it const &); |
template <> atime::value_type get<atime>(dir_it const &); |
254 |
struct ctime { typedef time_t *value_type; }; |
struct ctime { typedef time_t *value_type; }; |
255 |
template <> ctime::value_type get<ctime>(dir_it const &); |
template <> ctime::value_type get<ctime>(dir_it const &); |
256 |
|
|
257 |
struct group_read { typedef bool value_type; }; |
struct group_read { typedef bool value_type; }; |
258 |
template <> bool get<group_read>(dir_it const &); |
template <> bool get<group_read>(dir_it const &); |
259 |
template <> void set<group_read>(dir_it const &, bool); |
template <> void set<group_read>(dir_it const &, bool); |
260 |
struct group_write { typedef bool value_type; }; |
struct group_write { typedef bool value_type; }; |
261 |
template <> bool get<group_write>(dir_it const &); |
template <> bool get<group_write>(dir_it const &); |
262 |
template <> void set<group_write>(dir_it const &, bool); |
template <> void set<group_write>(dir_it const &, bool); |
263 |
struct group_execute { typedef bool value_type; }; |
struct group_execute { typedef bool value_type; }; |
264 |
template <> bool get<group_execute>(dir_it const &); |
template <> bool get<group_execute>(dir_it const &); |
265 |
template <> void set<group_execute>(dir_it const &, bool); |
template <> void set<group_execute>(dir_it const &, bool); |
266 |
struct other_read { typedef bool value_type; }; |
struct other_read { typedef bool value_type; }; |
267 |
template <> bool get<other_read>(dir_it const &); |
template <> bool get<other_read>(dir_it const &); |
268 |
template <> void set<other_read>(dir_it const &, bool); |
template <> void set<other_read>(dir_it const &, bool); |
269 |
struct other_write { typedef bool value_type; }; |
struct other_write { typedef bool value_type; }; |
270 |
template <> bool get<other_write>(dir_it const &); |
template <> bool get<other_write>(dir_it const &); |
271 |
template <> void set<other_write>(dir_it const &, bool); |
template <> void set<other_write>(dir_it const &, bool); |
272 |
struct other_execute { typedef bool value_type; }; |
struct other_execute { typedef bool value_type; }; |
273 |
template <> bool get<other_execute>(dir_it const &); |
template <> bool get<other_execute>(dir_it const &); |
274 |
template <> void set<other_execute>(dir_it const &, bool); |
template <> void set<other_execute>(dir_it const &, bool); |
275 |
|
|
276 |
struct set_uid { typedef bool value_type; }; |
struct set_uid { typedef bool value_type; }; |
277 |
template <> bool get<set_uid>(dir_it const &); |
template <> bool get<set_uid>(dir_it const &); |
278 |
template <> void set<set_uid>(dir_it const &, bool); |
template <> void set<set_uid>(dir_it const &, bool); |
279 |
struct set_gid { typedef bool value_type; }; |
struct set_gid { typedef bool value_type; }; |
280 |
template <> bool get<set_gid>(dir_it const &); |
template <> bool get<set_gid>(dir_it const &); |
281 |
template <> void set<set_gid>(dir_it const &, bool); |
template <> void set<set_gid>(dir_it const &, bool); |
282 |
struct sticky { typedef bool value_type; }; |
struct sticky { typedef bool value_type; }; |
283 |
template <> bool get<sticky>(dir_it const &); |
template <> bool get<sticky>(dir_it const &); |
284 |
template <> void set<sticky>(dir_it const &, bool); |
template <> void set<sticky>(dir_it const &, bool); |
285 |
|
|
286 |
struct mode { typedef mode_t value_type; }; |
struct mode { typedef mode_t value_type; }; |
287 |
template <> mode_t get<mode>(dir_it const &); |
template <> mode_t get<mode>(dir_it const &); |
288 |
template <> void set<mode>(dir_it const &, mode_t); |
template <> void set<mode>(dir_it const &, mode_t); |
289 |
|
|
290 |
struct links { typedef nlink_t value_type; }; |
struct links { typedef nlink_t value_type; }; |
291 |
template<> nlink_t get<links>(dir_it const &); |
template<> nlink_t get<links>(dir_it const &); |
292 |
struct blocks { typedef unsigned long value_type; }; |
struct blocks { typedef unsigned long value_type; }; |
293 |
template<> unsigned long get<blocks>(dir_it const &); |
template<> unsigned long get<blocks>(dir_it const &); |
294 |
struct blksize { typedef unsigned long value_type; }; |
struct blksize { typedef unsigned long value_type; }; |
295 |
template<> unsigned long get<blksize>(dir_it const &); |
template<> unsigned long get<blksize>(dir_it const &); |
296 |
|
|
297 |
class unknown_uid: public std::invalid_argument |
class unknown_uid: public std::invalid_argument |
298 |
{ |
{ |
299 |
public: |
public: |
300 |
unknown_uid(uid_t u): std::invalid_argument("unknown user ID"), m_uid(u) {} |
unknown_uid(uid_t u): std::invalid_argument("unknown user ID"), m_uid(u) {} |
301 |
uid_t uid() const { return m_uid; } |
uid_t uid() const { return m_uid; } |
302 |
private: |
private: |
303 |
uid_t m_uid; |
uid_t m_uid; |
304 |
}; |
}; |
305 |
struct uid { typedef uid_t value_type; }; |
struct uid { typedef uid_t value_type; }; |
306 |
template<> uid_t get<uid>(dir_it const &); |
template<> uid_t get<uid>(dir_it const &); |
307 |
template<> void set<uid>(dir_it const &, uid_t); |
template<> void set<uid>(dir_it const &, uid_t); |
308 |
class unknown_uname: public std::invalid_argument |
class unknown_uname: public std::invalid_argument |
309 |
{ |
{ |
310 |
public: |
public: |
311 |
unknown_uname(std::string u): std::invalid_argument("unknown user name"), m_uname(u) {} |
unknown_uname(std::string u): std::invalid_argument("unknown user name"), m_uname(u) {} |
312 |
// TODO: Why does this destructor have to be redefined so as to avoid the "looser throw specifier" error. |
// TODO: Why does this destructor have to be redefined so as to avoid the "looser throw specifier" error. |
313 |
~unknown_uname() throw() { } |
~unknown_uname() throw() { } |
314 |
std::string uname() const { return m_uname; } |
std::string uname() const { return m_uname; } |
315 |
private: |
private: |
316 |
std::string m_uname; |
std::string m_uname; |
317 |
}; |
}; |
318 |
struct uname { typedef std::string value_type; }; |
struct uname { typedef std::string value_type; }; |
319 |
template<> std::string get<uname>(dir_it const &); |
template<> std::string get<uname>(dir_it const &); |
320 |
template<> void set<uname>(dir_it const &, std::string ); |
template<> void set<uname>(dir_it const &, std::string ); |
321 |
|
|
322 |
class unknown_gid: public std::invalid_argument |
class unknown_gid: public std::invalid_argument |
323 |
{ |
{ |
324 |
public: |
public: |
325 |
unknown_gid(gid_t g): std::invalid_argument("unknown group ID"), m_gid(g) {} |
unknown_gid(gid_t g): std::invalid_argument("unknown group ID"), m_gid(g) {} |
326 |
gid_t gid() const { return m_gid; } |
gid_t gid() const { return m_gid; } |
327 |
private: |
private: |
328 |
gid_t m_gid; |
gid_t m_gid; |
329 |
}; |
}; |
330 |
struct gid { typedef gid_t value_type; }; |
struct gid { typedef gid_t value_type; }; |
331 |
template<> gid_t get<gid>(dir_it const &); |
template<> gid_t get<gid>(dir_it const &); |
332 |
template<> void set<gid>(dir_it const &, gid_t); |
template<> void set<gid>(dir_it const &, gid_t); |
333 |
class unknown_gname: public std::invalid_argument |
class unknown_gname: public std::invalid_argument |
334 |
{ |
{ |
335 |
public: |
public: |
336 |
unknown_gname(std::string g): std::invalid_argument("unknown group name"), m_gname(g) {} |
unknown_gname(std::string g): std::invalid_argument("unknown group name"), m_gname(g) {} |
337 |
// TODO: Why does this destructor have to be redefined so as to avoid the "looser throw specifier" error. |
// TODO: Why does this destructor have to be redefined so as to avoid the "looser throw specifier" error. |
338 |
~unknown_gname() throw() { } |
~unknown_gname() throw() { } |
339 |
std::string gname() const { return m_gname; } |
std::string gname() const { return m_gname; } |
340 |
private: |
private: |
341 |
std::string m_gname; |
std::string m_gname; |
342 |
}; |
}; |
343 |
struct gname { typedef std::string value_type; }; |
struct gname { typedef std::string value_type; }; |
344 |
template<> std::string get<gname>(dir_it const &); |
template<> std::string get<gname>(dir_it const &); |
345 |
template<> void set<gname>(dir_it const &, std::string ); |
template<> void set<gname>(dir_it const &, std::string ); |
346 |
|
|
347 |
#endif |
#endif |
348 |
|
|
349 |
} // namespace filesystem |
} // namespace filesystem |
350 |
} // namespace boost |
} // namespace boost |
351 |
|
|
352 |
namespace std |
namespace std |
353 |
{ |
{ |
354 |
template<> |
template <> |
355 |
struct iterator_traits<boost::filesystem::dir_it> |
struct iterator_traits<boost::filesystem::dir_it> { |
356 |
{ |
public: |
357 |
public: |
typedef ptrdiff_t difference_type; |
358 |
typedef ptrdiff_t difference_type; |
typedef std::string value_type; |
359 |
typedef std::string value_type; |
typedef std::string *pointer; |
360 |
typedef std::string *pointer; |
typedef std::string &reference; |
361 |
typedef std::string &reference; |
typedef input_iterator_tag iterator_category; |
362 |
typedef input_iterator_tag iterator_category; |
}; |
|
}; |
|
363 |
} // namespace std |
} // namespace std |
364 |
|
|
365 |
// -------------------------------------------------------------------------- |
// -------------------------------------------------------------------------- |