sadly, DirEntry type does not get filled for some remote
[platform/upstream/libzypp.git] / zypp / PathInfo.h
1 /*---------------------------------------------------------------------\
2 |                          ____ _   __ __ ___                          |
3 |                         |__  / \ / / . \ . \                         |
4 |                           / / \ V /|  _/  _/                         |
5 |                          / /__ | | | | | |                           |
6 |                         /_____||_| |_| |_|                           |
7 |                                                                      |
8 \---------------------------------------------------------------------*/
9 /** \file zypp/PathInfo.h
10  *
11 */
12 #ifndef ZYPP_PATHINFO_H
13 #define ZYPP_PATHINFO_H
14
15 extern "C"
16 {
17 #include <sys/types.h>
18 #include <sys/stat.h>
19 #include <fcntl.h>
20 #include <unistd.h>
21 #include <dirent.h>
22 }
23
24 #include <cerrno>
25 #include <iosfwd>
26 #include <list>
27 #include <set>
28 #include <map>
29
30 #include "zypp/Pathname.h"
31 #include "zypp/CheckSum.h"
32 #include "zypp/ByteCount.h"
33
34 ///////////////////////////////////////////////////////////////////
35 namespace zypp
36 { /////////////////////////////////////////////////////////////////
37
38   ///////////////////////////////////////////////////////////////////
39   /** Types and functions for filesystem operations.
40    * \todo move zypp::filesystem stuff into separate header
41    * \todo Add tmpfile and tmpdir handling.
42    * \todo think about using Exceptions in zypp::filesystem
43    * \todo provide a readdir iterator; at least provide an interface
44    * using an insert_iterator to be independent from std::container.
45   */
46   namespace filesystem
47   { /////////////////////////////////////////////////////////////////
48
49     ///////////////////////////////////////////////////////////////////
50     /** File type information.
51      * \todo Think about an \ref g_EnumerationClass
52     */
53     enum FileType
54       {
55         FT_NOT_AVAIL = 0x00, // no typeinfo available
56         FT_NOT_EXIST = 0x01, // file does not exist
57         FT_FILE      = 0x02,
58         FT_DIR       = 0x04,
59         FT_CHARDEV   = 0x08,
60         FT_BLOCKDEV  = 0x10,
61         FT_FIFO      = 0x20,
62         FT_LINK      = 0x40,
63         FT_SOCKET    = 0x80
64       };
65     ///////////////////////////////////////////////////////////////////
66
67     /** \relates FileType Stram output. */
68     extern std::ostream & operator<<( std::ostream & str, FileType obj );
69
70     ///////////////////////////////////////////////////////////////////
71
72     ///////////////////////////////////////////////////////////////////
73     //
74     //  CLASS NAME : StatMode
75     /**
76      * @short Wrapper class for mode_t values as derived from ::stat
77      **/
78     class StatMode
79     {
80       friend std::ostream & operator<<( std::ostream & str, const StatMode & obj );
81
82     public:
83       /** Ctor taking  mode_t value from ::stat. */
84       StatMode( const mode_t & mode_r = 0 )
85       : _mode( mode_r )
86       {}
87
88     public:
89
90       /** \name Query FileType. */
91       //@{
92       FileType fileType() const;
93
94       bool   isFile()  const { return S_ISREG( _mode ); }
95       bool   isDir ()  const { return S_ISDIR( _mode ); }
96       bool   isLink()  const { return S_ISLNK( _mode ); }
97       bool   isChr()   const { return S_ISCHR( _mode ); }
98       bool   isBlk()   const { return S_ISBLK( _mode ); }
99       bool   isFifo()  const { return S_ISFIFO( _mode ); }
100       bool   isSock()  const { return S_ISSOCK( _mode ); }
101       //@}
102
103       /** \name Query user permissions. */
104       //@{
105       bool   isRUsr()  const { return (_mode & S_IRUSR); }
106       bool   isWUsr()  const { return (_mode & S_IWUSR); }
107       bool   isXUsr()  const { return (_mode & S_IXUSR); }
108
109       /** Short for isRUsr().*/
110       bool   isR()     const { return isRUsr(); }
111       /** Short for isWUsr().*/
112       bool   isW()     const { return isWUsr(); }
113       /** Short for isXUsr().*/
114       bool   isX()     const { return isXUsr(); }
115       //@}
116
117       /** \name Query group permissions. */
118       //@{
119       bool   isRGrp()  const { return (_mode & S_IRGRP); }
120       bool   isWGrp()  const { return (_mode & S_IWGRP); }
121       bool   isXGrp()  const { return (_mode & S_IXGRP); }
122       //@}
123
124       /** \name Query others permissions. */
125       //@{
126       bool   isROth()  const { return (_mode & S_IROTH); }
127       bool   isWOth()  const { return (_mode & S_IWOTH); }
128       bool   isXOth()  const { return (_mode & S_IXOTH); }
129       //@}
130
131       /** \name Query special permissions. */
132       //@{
133       /** Set UID bit. */
134       bool   isUid()   const { return (_mode & S_ISUID); }
135       /** Set GID bit. */
136       bool   isGid()   const { return (_mode & S_ISGID); }
137       /** Sticky bit. */
138       bool   isVtx()   const { return (_mode & S_ISVTX); }
139       //@}
140
141       /** \name Query permission */
142       //@{
143       /** Test for equal permission bits. */
144       bool   isPerm ( mode_t m ) const { return (m == perm()); }
145       /** Test for set permission bits. */
146       bool   hasPerm( mode_t m ) const { return (m == (m & perm())); }
147       //@}
148
149       /** \name Extract permission bits only. */
150       //@{
151       mode_t uperm()   const { return (_mode & S_IRWXU); }
152       mode_t gperm()   const { return (_mode & S_IRWXG); }
153       mode_t operm()   const { return (_mode & S_IRWXO); }
154       mode_t perm()    const { return (_mode & (S_IRWXU|S_IRWXG|S_IRWXO|S_ISUID|S_ISGID|S_ISVTX)); }
155       //@}
156
157       /** Return the mode_t value. */
158       mode_t st_mode() const { return _mode; }
159
160     private:
161       mode_t _mode;
162     };
163     ///////////////////////////////////////////////////////////////////
164
165     /** \relates StatMode Stream output. */
166     extern std::ostream & operator<<( std::ostream & str, const StatMode & obj );
167
168     ///////////////////////////////////////////////////////////////////
169
170     ///////////////////////////////////////////////////////////////////
171     //
172     //  CLASS NAME : DevInoCache
173     /** Simple cache remembering device/inode to detect hardlinks.
174      * \code
175      *     DevInoCache trace;
176      *     for ( all files ) {
177      *       if ( trace.insert( file.device, file.inode ) ) {
178      *         // 1st occurance of file
179      *       }
180      *         // else: hardlink; already counted this device/inode
181      *       }
182      *     }
183      * \endcode
184      **/
185     class DevInoCache
186     {
187     public:
188       /** Ctor */
189       DevInoCache() {}
190
191       /** Clear cache. */
192       void clear() { _devino.clear(); }
193
194       /** Remember dev/ino.
195        * \Return <code>true</code> if it's inserted the first
196        * time, <code>false</code> if alredy present in cache
197        * (a hardlink to a previously remembered file).
198        **/
199       bool insert( const dev_t & dev_r, const ino_t & ino_r ) {
200         return _devino[dev_r].insert( ino_r ).second;
201       }
202
203     private:
204       std::map<dev_t,std::set<ino_t> > _devino;
205     };
206     ///////////////////////////////////////////////////////////////////
207
208     ///////////////////////////////////////////////////////////////////
209     //
210     //  CLASS NAME : PathInfo
211     /** Wrapper class for ::stat/::lstat.
212      *
213      * \note All attribute quieries test for isExist(), and return \c false or
214      * \c 0, if stat was not successful.
215      *
216      * \note For convenience PathInfo is available as zypp::PathInfo too.
217      **/
218     class PathInfo
219     {
220       friend std::ostream & operator<<( std::ostream & str, const PathInfo & obj );
221
222     public:
223       /** stat() or lstat() */
224       enum Mode { STAT, LSTAT };
225
226     public:
227       /** \name Construct from Pathname.
228        * Default mode is \c STAT.
229       */
230       //@{
231       PathInfo();
232       explicit
233       PathInfo( const Pathname & path, Mode initial = STAT );
234       explicit
235       PathInfo( const std::string & path, Mode initial = STAT );
236       explicit
237       PathInfo( const char * path, Mode initial = STAT );
238       //@}
239
240       /**Dtor */
241       ~PathInfo();
242
243       /** Return current Pathname. */
244       const Pathname &    path()     const { return path_t; }
245       /** Return current Pathname as String. */
246       const std::string & asString() const { return path_t.asString(); }
247       /** Return current Pathname as C-string. */
248       const char * c_str()           const { return path_t.asString().c_str(); }
249       /** Return current stat Mode. */
250       Mode                mode()     const { return mode_e; }
251       /** Return error returned from last stat/lstat call. */
252       int                 error()    const { return error_i; }
253
254       /** Set a new Pathname. */
255       void setPath( const Pathname & path ) { if ( path != path_t ) error_i = -1; path_t = path; }
256       /** Set a new Mode . */
257       void setMode( Mode mode )             { if ( mode != mode_e ) error_i = -1; mode_e = mode; }
258
259       /** STAT \a path. */
260       bool stat      ( const Pathname & path ) { setPath( path ); setMode( STAT );  return operator()(); }
261       /** LSTAT \a path. */
262       bool lstat     ( const Pathname & path ) { setPath( path ); setMode( LSTAT ); return operator()(); }
263       /** Restat \a path using current mode. */
264       bool operator()( const Pathname & path ) { setPath( path ); return operator()(); }
265
266       /** STAT current path. */
267       bool stat()   { setMode( STAT );  return operator()(); }
268       /** LSTAT current path. */
269       bool lstat()  { setMode( LSTAT ); return operator()(); }
270       /** Restat current path using current mode. */
271       bool operator()();
272
273     public:
274
275       /** Return whether valid stat info exists.
276        * That's usg. whether the file exist and you had permission to
277        * stat it.
278       */
279       bool   isExist() const { return !error_i; }
280
281       /** \name Query StatMode attibutes.
282        * Combines \ref zypp::PathInfo::isExist and \ref zypp::filesystem::StatMode query.
283       */
284       //@{
285       FileType fileType() const;
286
287       bool   isFile()  const { return isExist() && S_ISREG( statbuf_C.st_mode ); }
288       bool   isDir ()  const { return isExist() && S_ISDIR( statbuf_C.st_mode ); }
289       bool   isLink()  const { return isExist() && S_ISLNK( statbuf_C.st_mode ); }
290       bool   isChr()   const { return isExist() && S_ISCHR( statbuf_C.st_mode ); }
291       bool   isBlk()   const { return isExist() && S_ISBLK( statbuf_C.st_mode ); }
292       bool   isFifo()  const { return isExist() && S_ISFIFO( statbuf_C.st_mode ); }
293       bool   isSock()  const { return isExist() && S_ISSOCK( statbuf_C.st_mode ); }
294
295       // permission
296       bool   isRUsr()  const { return isExist() && (statbuf_C.st_mode & S_IRUSR); }
297       bool   isWUsr()  const { return isExist() && (statbuf_C.st_mode & S_IWUSR); }
298       bool   isXUsr()  const { return isExist() && (statbuf_C.st_mode & S_IXUSR); }
299
300       bool   isR()     const { return isRUsr(); }
301       bool   isW()     const { return isWUsr(); }
302       bool   isX()     const { return isXUsr(); }
303
304       bool   isRGrp()  const { return isExist() && (statbuf_C.st_mode & S_IRGRP); }
305       bool   isWGrp()  const { return isExist() && (statbuf_C.st_mode & S_IWGRP); }
306       bool   isXGrp()  const { return isExist() && (statbuf_C.st_mode & S_IXGRP); }
307
308       bool   isROth()  const { return isExist() && (statbuf_C.st_mode & S_IROTH); }
309       bool   isWOth()  const { return isExist() && (statbuf_C.st_mode & S_IWOTH); }
310       bool   isXOth()  const { return isExist() && (statbuf_C.st_mode & S_IXOTH); }
311
312       bool   isUid()   const { return isExist() && (statbuf_C.st_mode & S_ISUID); }
313       bool   isGid()   const { return isExist() && (statbuf_C.st_mode & S_ISGID); }
314       bool   isVtx()   const { return isExist() && (statbuf_C.st_mode & S_ISVTX); }
315
316       bool   isPerm ( mode_t m ) const { return isExist() && (m == perm()); }
317       bool   hasPerm( mode_t m ) const { return isExist() && (m == (m & perm())); }
318
319       mode_t uperm()   const { return isExist() ? (statbuf_C.st_mode & S_IRWXU) : 0; }
320       mode_t gperm()   const { return isExist() ? (statbuf_C.st_mode & S_IRWXG) : 0; }
321       mode_t operm()   const { return isExist() ? (statbuf_C.st_mode & S_IRWXO) : 0; }
322       mode_t perm()    const { return isExist() ? (statbuf_C.st_mode & (S_IRWXU|S_IRWXG|S_IRWXO|S_ISUID|S_ISGID|S_ISVTX)) : 0; }
323
324       mode_t st_mode() const { return isExist() ? statbuf_C.st_mode : 0; }
325       //@}
326
327       /** Return st_mode() as filesystem::StatMode. */
328       StatMode asStatMode() const { return st_mode(); }
329
330       nlink_t nlink()  const { return isExist() ? statbuf_C.st_nlink : 0; }
331
332       /** \name Owner and group */
333       //@{
334       uid_t  owner()   const { return isExist() ? statbuf_C.st_uid : 0; }
335       gid_t  group()   const { return isExist() ? statbuf_C.st_gid : 0; }
336       //@}
337
338       /** \name Permission according to current uid/gid. */
339       //@{
340       /** Returns current users permission (<tt>[0-7]</tt>)*/
341       mode_t userMay() const;
342
343       bool   userMayR() const { return( userMay() & 04 ); }
344       bool   userMayW() const { return( userMay() & 02 ); }
345       bool   userMayX() const { return( userMay() & 01 ); }
346
347       bool   userMayRW()  const { return( (userMay() & 06) == 06 ); }
348       bool   userMayRX()  const { return( (userMay() & 05) == 05 ); }
349       bool   userMayWX()  const { return( (userMay() & 03) == 03 ); }
350
351       bool   userMayRWX() const { return( userMay() == 07 ); }
352       //@}
353
354       /** \name Device and inode info. */
355       //@{
356       ino_t  ino()     const { return isExist() ? statbuf_C.st_ino  : 0; }
357       dev_t  dev()     const { return isExist() ? statbuf_C.st_dev  : 0; }
358       dev_t  rdev()    const { return isExist() ? statbuf_C.st_rdev : 0; }
359
360       unsigned int major() const;
361       unsigned int minor() const;
362       //@}
363
364       /** \name Size info. */
365       //@{
366       off_t         size()    const { return isExist() ? statbuf_C.st_size : 0; }
367       unsigned long blksize() const { return isExist() ? statbuf_C.st_blksize : 0; }
368       unsigned long blocks()  const { return isExist() ? statbuf_C.st_blocks  : 0; }
369       //@}
370
371       /** \name Time stamps. */
372       //@{
373       time_t atime()   const { return isExist() ? statbuf_C.st_atime : 0; } /* time of last access */
374       time_t mtime()   const { return isExist() ? statbuf_C.st_mtime : 0; } /* time of last modification */
375       time_t ctime()   const { return isExist() ? statbuf_C.st_ctime : 0; }
376       //@}
377
378     private:
379       Pathname    path_t;
380       struct stat statbuf_C;
381       Mode        mode_e;
382       int         error_i;
383     };
384     ///////////////////////////////////////////////////////////////////
385
386     /** \relates PathInfo Stream output. */
387     extern std::ostream & operator<<( std::ostream & str, const PathInfo & obj );
388
389     ///////////////////////////////////////////////////////////////////
390
391     ///////////////////////////////////////////////////////////////////
392     /** \name Directory related functions. */
393     //@{
394     /**
395      * Like '::mkdir'. Attempt to create a new directory named path. mode
396      * specifies the permissions to use. It is modified by the process's
397      * umask in the usual way.
398      *
399      * @return 0 on success, errno on failure
400      **/
401     int mkdir( const Pathname & path, unsigned mode = 0755 );
402
403     /**
404      * Like 'mkdir -p'. No error if directory exists. Make parent directories
405      * as needed. mode specifies the permissions to use, if directories have to
406      * be created. It is modified by the process's umask in the usual way.
407      *
408      * @return 0 on success, errno on failure
409      **/
410     int assert_dir( const Pathname & path, unsigned mode = 0755 );
411
412     /**
413      * Like '::rmdir'. Delete a directory, which must be empty.
414      *
415      * @return 0 on success, errno on failure
416      **/
417     int rmdir( const Pathname & path );
418
419     /**
420      * Like 'rm -r DIR'. Delete a directory, recursively removing its contents.
421      *
422      * @return 0 on success, ENOTDIR if path is not a directory, otherwise the
423      * commands return value.
424      **/
425     int recursive_rmdir( const Pathname & path );
426
427     /**
428      * Like 'rm -r DIR/ *'. Delete directory contents, but keep the directory itself.
429      *
430      * @return 0 on success, ENOTDIR if path is not a directory, otherwise the
431      * commands return value.
432      **/
433     int clean_dir( const Pathname & path );
434
435     /**
436      * Like 'cp -a srcpath destpath'. Copy directory tree. srcpath/destpath must be
437      * directories. 'basename srcpath' must not exist in destpath.
438      *
439      * @return 0 on success, ENOTDIR if srcpath/destpath is not a directory, EEXIST if
440      * 'basename srcpath' exists in destpath, otherwise the commands return value.
441      **/
442     int copy_dir( const Pathname & srcpath, const Pathname & destpath );
443
444     /**
445      * Like 'cp -a srcpath/. destpath'. Copy the content of srcpath recursively
446      * into destpath. Both \p srcpath and \p destpath has to exists.
447      *
448      * @return 0 on success, ENOTDIR if srcpath/destpath is not a directory,
449      * EEXIST if srcpath and destpath are equal, otherwise the commands
450      * return value.
451      */
452     int copy_dir_content( const Pathname & srcpath, const Pathname & destpath);
453
454     /**
455      * Return content of directory via retlist. If dots is false
456      * entries starting with '.' are not reported. "." and ".."
457      * are never reported.
458      *
459      * Returns just the directory entries as string.
460      *
461      * @return 0 on success, errno on failure.
462      *
463      * \todo provide some readdirIterator.
464      **/
465
466     int readdir( std::list<std::string> & retlist,
467                  const Pathname & path, bool dots = true );
468
469     /**
470      * Return content of directory via retlist. If dots is false
471      * entries starting with '.' are not reported. "." and ".."
472      * are never reported.
473      *
474      * Returns the directory entries prefixed with \a path.
475      *
476      * @return 0 on success, errno on failure.
477      *
478      * \todo provide some readdirIterator.
479      **/
480
481     int readdir( std::list<Pathname> & retlist,
482                  const Pathname & path, bool dots = true );
483
484     /** Listentry returned by readdir. */
485     struct DirEntry {
486       std::string name;
487       FileType    type;
488       DirEntry( const std::string & name_r = std::string(), FileType type_r = FT_NOT_AVAIL )
489       : name( name_r )
490       , type( type_r )
491       {}
492
493       bool operator==( const DirEntry &rhs ) const;
494     };
495
496     /** Returned by readdir. */
497     typedef std::list<DirEntry> DirContent;
498
499     /**
500      * Return content of directory via retlist. If dots is false
501      * entries starting with '.' are not reported. "." and ".."
502      * are never reported.
503      *
504      * The type of individual directory entries is determined accoding to
505      * statmode (i.e. via stat or lstat).
506      *
507      * @return 0 on success, errno on failure.
508      **/
509     int readdir( DirContent & retlist, const Pathname & path,
510                  bool dots = true, PathInfo::Mode statmode = PathInfo::STAT );
511
512
513     /**
514      * Check if the specified directory is empty.
515      * \param path The path of the directory to check.
516      * \return 0 if directory is empty, -1 if not, errno > 0 on failure.
517      */
518     int is_empty_dir(const Pathname & path);
519
520     //@}
521
522     ///////////////////////////////////////////////////////////////////
523     /** \name File related functions. */
524     //@{
525     /**
526      * Change file's modification and access times.
527      *
528      * \return 0 on success, errno on failure
529      * \see man utime
530      */
531     int touch (const Pathname & path);
532
533     /**
534      * Like '::unlink'. Delete a file (symbolic link, socket, fifo or device).
535      *
536      * @return 0 on success, errno on failure
537      **/
538     int unlink( const Pathname & path );
539
540     /**
541      * Like '::rename'. Renames a file, moving it between directories if required.
542      *
543      * @return 0 on success, errno on failure
544      **/
545     int rename( const Pathname & oldpath, const Pathname & newpath );
546
547     /**
548      * Like 'cp file dest'. Copy file to destination file.
549      *
550      * @return 0 on success, EINVAL if file is not a file, EISDIR if
551      * destiantion is a directory, otherwise the commands return value.
552      **/
553     int copy( const Pathname & file, const Pathname & dest );
554
555     /**
556      * Like '::symlink'. Creates a symbolic link named newpath which contains
557      * the string oldpath. If newpath exists it will not be overwritten.
558      *
559      * @return 0 on success, errno on failure.
560      **/
561     int symlink( const Pathname & oldpath, const Pathname & newpath );
562
563     /**
564      * Like '::link'. Creates a hard link named newpath to an existing file
565      * oldpath. If newpath exists it will not be overwritten.
566      *
567      * @return 0 on success, errno on failure.
568      **/
569     int hardlink( const Pathname & oldpath, const Pathname & newpath );
570
571     /**
572      * Like '::readlink'. Return the contents of the symbolic link
573      * \a symlink_r via \a target_r.
574      *
575      * @return 0 on success, errno on failure.
576      */
577     int readlink( const Pathname & symlink_r, Pathname & target_r );
578     /** \overload Return an empty Pathname on error. */
579     inline Pathname readlink( const Pathname & symlink_r )
580     {
581       Pathname target;
582       readlink( symlink_r, target );
583       return target;
584     }
585
586     /**
587      * Recursively follows the symlink pointed to by \a path_r and returns
588      * the Pathname to the real file or directory pointed to by the link.
589      * 
590      * There is a recursion limit of 256 iterations to protect against a cyclic
591      * link.
592      *
593      * @return Pathname of the file or directory pointed to by the given link
594      *   if it is a valid link. If \a path_r is not a link, an exact copy of
595      *   it is returned. If \a path_r is a broken or a cyclic link, an empty
596      *   Pathname is returned and the event logged.
597      */ 
598     Pathname expandlink( const Pathname & path_r );
599
600     /**
601      * Like 'cp file dest'. Copy file to dest dir.
602      *
603      * @return 0 on success, EINVAL if file is not a file, ENOTDIR if dest
604      * is no directory, otherwise the commands return value.
605      **/
606     int copy_file2dir( const Pathname & file, const Pathname & dest );
607     //@}
608
609     ///////////////////////////////////////////////////////////////////
610     /** \name Digest computaion.
611      * \todo check cooperation with zypp::Digest
612     */
613     //@{
614     /**
615      * Compute a files md5sum.
616      *
617      * @return the files md5sum on success, otherwise an empty string..
618      **/
619     std::string md5sum( const Pathname & file );
620
621     /**
622      * Compute a files sha1sum.
623      *
624      * @return the files sha1sum on success, otherwise an empty string..
625      **/
626     std::string sha1sum( const Pathname & file );
627     //@}
628
629     /**
630      * Compute a files checksum
631      *
632      * @return the files checksum on success, otherwise an empty string..
633      **/
634     std::string checksum( const Pathname & file, const std::string &algorithm );
635
636     /**
637      * check files checksum
638      *
639      * @return true if the checksum matchs
640      **/
641     bool is_checksum( const Pathname & file, const CheckSum &checksum );
642
643     ///////////////////////////////////////////////////////////////////
644     /** \name Changing permissions. */
645     //@{
646     /**
647      * Like '::chmod'. The mode of the file given by path is changed.
648      *
649      * @return 0 on success, errno on failure
650      **/
651     int chmod( const Pathname & path, mode_t mode );
652     //@}
653
654     ///////////////////////////////////////////////////////////////////
655     /** \name Misc. */
656     //@{
657     /**
658      * Test whether a file is compressed (gzip/bzip2).
659      *
660      * @return ZT_GZ, ZT_BZ2 if file is compressed, otherwise ZT_NONE.
661      **/
662     enum ZIP_TYPE { ZT_NONE, ZT_GZ, ZT_BZ2 };
663
664     ZIP_TYPE zipType( const Pathname & file );
665
666     /**
667      * Erase whatever happens to be located at path (file or directory).
668      *
669      * @return 0 on success.
670      *
671      * \todo check cooperation with zypp::TmpFile and zypp::TmpDir
672      **/
673     int erase( const Pathname & path );
674
675     /**
676      * Report free disk space on a mounted file system.
677      *
678      * path is the path name of any file within the mounted filesystem.
679      *
680      * @return Free disk space or -1 on error.
681      **/
682     ByteCount df( const Pathname & path );
683
684     /**
685      * Get the current umask (file mode creation mask)
686      *
687      * @return The current umask
688      **/
689     mode_t getUmask();
690
691      /**
692      * Modify \c mode_r according to the current umask
693      * <tt>( mode_r & ~getUmask() )</tt>.
694      * \see \ref getUmask.
695      * @return The resulting permissions.
696      **/
697     inline mode_t applyUmaskTo( mode_t mode_r )
698     { return mode_r & ~getUmask(); }
699     //@}
700
701     /////////////////////////////////////////////////////////////////
702   } // namespace filesystem
703   ///////////////////////////////////////////////////////////////////
704
705   /** Dragged into namespace zypp. */
706   using filesystem::PathInfo;
707
708   /////////////////////////////////////////////////////////////////
709 } // namespace zypp
710 ///////////////////////////////////////////////////////////////////
711 #endif // ZYPP_PATHINFO_H