libzypp  15.28.6
PathInfo.h
Go to the documentation of this file.
1 /*---------------------------------------------------------------------\
2 | ____ _ __ __ ___ |
3 | |__ / \ / / . \ . \ |
4 | / / \ V /| _/ _/ |
5 | / /__ | | | | | | |
6 | /_____||_| |_| |_| |
7 | |
8 \---------------------------------------------------------------------*/
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 
35 namespace zypp
36 {
37 
38  class StrMatcher;
39 
41 
48  namespace filesystem
49  {
50 
52 
55  enum FileType
56  {
57  FT_NOT_AVAIL = 0x00, // no typeinfo available
58  FT_NOT_EXIST = 0x01, // file does not exist
59  FT_FILE = 0x02,
60  FT_DIR = 0x04,
61  FT_CHARDEV = 0x08,
62  FT_BLOCKDEV = 0x10,
63  FT_FIFO = 0x20,
64  FT_LINK = 0x40,
65  FT_SOCKET = 0x80
66  };
68 
70  extern std::ostream & operator<<( std::ostream & str, FileType obj );
71 
73 
75  //
76  // CLASS NAME : StatMode
80  class StatMode
81  {
82  friend std::ostream & operator<<( std::ostream & str, const StatMode & obj );
83 
84  public:
86  StatMode( const mode_t & mode_r = 0 )
87  : _mode( mode_r )
88  {}
89 
90  public:
91 
94  FileType fileType() const;
95 
96  bool isFile() const { return S_ISREG( _mode ); }
97  bool isDir () const { return S_ISDIR( _mode ); }
98  bool isLink() const { return S_ISLNK( _mode ); }
99  bool isChr() const { return S_ISCHR( _mode ); }
100  bool isBlk() const { return S_ISBLK( _mode ); }
101  bool isFifo() const { return S_ISFIFO( _mode ); }
102  bool isSock() const { return S_ISSOCK( _mode ); }
104 
107  bool isRUsr() const { return (_mode & S_IRUSR); }
108  bool isWUsr() const { return (_mode & S_IWUSR); }
109  bool isXUsr() const { return (_mode & S_IXUSR); }
110 
112  bool isR() const { return isRUsr(); }
114  bool isW() const { return isWUsr(); }
116  bool isX() const { return isXUsr(); }
118 
121  bool isRGrp() const { return (_mode & S_IRGRP); }
122  bool isWGrp() const { return (_mode & S_IWGRP); }
123  bool isXGrp() const { return (_mode & S_IXGRP); }
125 
128  bool isROth() const { return (_mode & S_IROTH); }
129  bool isWOth() const { return (_mode & S_IWOTH); }
130  bool isXOth() const { return (_mode & S_IXOTH); }
132 
136  bool isUid() const { return (_mode & S_ISUID); }
138  bool isGid() const { return (_mode & S_ISGID); }
140  bool isVtx() const { return (_mode & S_ISVTX); }
142 
146  bool isPerm ( mode_t m ) const { return (m == perm()); }
148  bool hasPerm( mode_t m ) const { return (m == (m & perm())); }
150 
153  mode_t uperm() const { return (_mode & S_IRWXU); }
154  mode_t gperm() const { return (_mode & S_IRWXG); }
155  mode_t operm() const { return (_mode & S_IRWXO); }
156  mode_t perm() const { return (_mode & (S_IRWXU|S_IRWXG|S_IRWXO|S_ISUID|S_ISGID|S_ISVTX)); }
158 
160  mode_t st_mode() const { return _mode; }
161 
162  private:
163  mode_t _mode;
164  };
166 
168  extern std::ostream & operator<<( std::ostream & str, const StatMode & obj );
169 
171 
173  //
174  // CLASS NAME : DevInoCache
188  {
189  public:
192 
194  void clear() { _devino.clear(); }
195 
201  bool insert( const dev_t & dev_r, const ino_t & ino_r ) {
202  return _devino[dev_r].insert( ino_r ).second;
203  }
204 
205  private:
206  std::map<dev_t,std::set<ino_t> > _devino;
207  };
209 
211  //
212  // CLASS NAME : PathInfo
220  class PathInfo
221  {
222  friend std::ostream & operator<<( std::ostream & str, const PathInfo & obj );
223 
224  public:
226  enum Mode { STAT, LSTAT };
227 
228  public:
233  PathInfo();
234  explicit
235  PathInfo( const Pathname & path, Mode initial = STAT );
236  explicit
237  PathInfo( const std::string & path, Mode initial = STAT );
238  explicit
239  PathInfo( const char * path, Mode initial = STAT );
241 
243  ~PathInfo();
244 
246  const Pathname & path() const { return path_t; }
248  const std::string & asString() const { return path_t.asString(); }
250  const char * c_str() const { return path_t.asString().c_str(); }
252  Mode mode() const { return mode_e; }
254  int error() const { return error_i; }
255 
257  void setPath( const Pathname & path ) { if ( path != path_t ) error_i = -1; path_t = path; }
259  void setMode( Mode mode ) { if ( mode != mode_e ) error_i = -1; mode_e = mode; }
260 
262  bool stat ( const Pathname & path ) { setPath( path ); setMode( STAT ); return operator()(); }
264  bool lstat ( const Pathname & path ) { setPath( path ); setMode( LSTAT ); return operator()(); }
266  bool operator()( const Pathname & path ) { setPath( path ); return operator()(); }
267 
269  bool stat() { setMode( STAT ); return operator()(); }
271  bool lstat() { setMode( LSTAT ); return operator()(); }
273  bool operator()();
274 
275  public:
276 
281  bool isExist() const { return !error_i; }
282 
287  FileType fileType() const;
288 
289  bool isFile() const { return isExist() && S_ISREG( statbuf_C.st_mode ); }
290  bool isDir () const { return isExist() && S_ISDIR( statbuf_C.st_mode ); }
291  bool isLink() const { return isExist() && S_ISLNK( statbuf_C.st_mode ); }
292  bool isChr() const { return isExist() && S_ISCHR( statbuf_C.st_mode ); }
293  bool isBlk() const { return isExist() && S_ISBLK( statbuf_C.st_mode ); }
294  bool isFifo() const { return isExist() && S_ISFIFO( statbuf_C.st_mode ); }
295  bool isSock() const { return isExist() && S_ISSOCK( statbuf_C.st_mode ); }
296 
297  // permission
298  bool isRUsr() const { return isExist() && (statbuf_C.st_mode & S_IRUSR); }
299  bool isWUsr() const { return isExist() && (statbuf_C.st_mode & S_IWUSR); }
300  bool isXUsr() const { return isExist() && (statbuf_C.st_mode & S_IXUSR); }
301 
302  bool isR() const { return isRUsr(); }
303  bool isW() const { return isWUsr(); }
304  bool isX() const { return isXUsr(); }
305 
306  bool isRGrp() const { return isExist() && (statbuf_C.st_mode & S_IRGRP); }
307  bool isWGrp() const { return isExist() && (statbuf_C.st_mode & S_IWGRP); }
308  bool isXGrp() const { return isExist() && (statbuf_C.st_mode & S_IXGRP); }
309 
310  bool isROth() const { return isExist() && (statbuf_C.st_mode & S_IROTH); }
311  bool isWOth() const { return isExist() && (statbuf_C.st_mode & S_IWOTH); }
312  bool isXOth() const { return isExist() && (statbuf_C.st_mode & S_IXOTH); }
313 
314  bool isUid() const { return isExist() && (statbuf_C.st_mode & S_ISUID); }
315  bool isGid() const { return isExist() && (statbuf_C.st_mode & S_ISGID); }
316  bool isVtx() const { return isExist() && (statbuf_C.st_mode & S_ISVTX); }
317 
318  bool isPerm ( mode_t m ) const { return isExist() && (m == perm()); }
319  bool hasPerm( mode_t m ) const { return isExist() && (m == (m & perm())); }
320 
321  mode_t uperm() const { return isExist() ? (statbuf_C.st_mode & S_IRWXU) : 0; }
322  mode_t gperm() const { return isExist() ? (statbuf_C.st_mode & S_IRWXG) : 0; }
323  mode_t operm() const { return isExist() ? (statbuf_C.st_mode & S_IRWXO) : 0; }
324  mode_t perm() const { return isExist() ? (statbuf_C.st_mode & (S_IRWXU|S_IRWXG|S_IRWXO|S_ISUID|S_ISGID|S_ISVTX)) : 0; }
325 
326  mode_t st_mode() const { return isExist() ? statbuf_C.st_mode : 0; }
328 
330  StatMode asStatMode() const { return st_mode(); }
331 
332  nlink_t nlink() const { return isExist() ? statbuf_C.st_nlink : 0; }
333 
336  uid_t owner() const { return isExist() ? statbuf_C.st_uid : 0; }
337  gid_t group() const { return isExist() ? statbuf_C.st_gid : 0; }
339 
343  mode_t userMay() const;
344 
345  bool userMayR() const { return( userMay() & 04 ); }
346  bool userMayW() const { return( userMay() & 02 ); }
347  bool userMayX() const { return( userMay() & 01 ); }
348 
349  bool userMayRW() const { return( (userMay() & 06) == 06 ); }
350  bool userMayRX() const { return( (userMay() & 05) == 05 ); }
351  bool userMayWX() const { return( (userMay() & 03) == 03 ); }
352 
353  bool userMayRWX() const { return( userMay() == 07 ); }
355 
358  ino_t ino() const { return isExist() ? statbuf_C.st_ino : 0; }
359  dev_t dev() const { return isExist() ? statbuf_C.st_dev : 0; }
360  dev_t rdev() const { return isExist() ? statbuf_C.st_rdev : 0; }
361 
362  unsigned int devMajor() const;
363  unsigned int devMinor() const;
365 
368  off_t size() const { return isExist() ? statbuf_C.st_size : 0; }
369  unsigned long blksize() const { return isExist() ? statbuf_C.st_blksize : 0; }
370  unsigned long blocks() const { return isExist() ? statbuf_C.st_blocks : 0; }
372 
375  time_t atime() const { return isExist() ? statbuf_C.st_atime : 0; } /* time of last access */
376  time_t mtime() const { return isExist() ? statbuf_C.st_mtime : 0; } /* time of last modification */
377  time_t ctime() const { return isExist() ? statbuf_C.st_ctime : 0; }
379 
380  private:
382  struct stat statbuf_C;
384  int error_i;
385  };
387 
389  extern std::ostream & operator<<( std::ostream & str, const PathInfo & obj );
390 
392 
394 
403  int mkdir( const Pathname & path, unsigned mode = 0755 );
404 
412  int assert_dir( const Pathname & path, unsigned mode = 0755 );
413 
419  int rmdir( const Pathname & path );
420 
427  int recursive_rmdir( const Pathname & path );
428 
435  int clean_dir( const Pathname & path );
436 
444  int copy_dir( const Pathname & srcpath, const Pathname & destpath );
445 
454  int copy_dir_content( const Pathname & srcpath, const Pathname & destpath);
455 
460  const StrMatcher & matchNoDots();
461 
474  int dirForEach( const Pathname & dir_r, function<bool(const Pathname &, const char *const)> fnc_r );
475 
499  int dirForEach( const Pathname & dir_r, const StrMatcher & matcher_r, function<bool(const Pathname &, const char *const)> fnc_r );
500 
513  int readdir( std::list<std::string> & retlist,
514  const Pathname & path, bool dots = true );
515 
528  int readdir( std::list<Pathname> & retlist,
529  const Pathname & path, bool dots = true );
530 
532  struct DirEntry {
533  std::string name;
535  DirEntry( const std::string & name_r = std::string(), FileType type_r = FT_NOT_AVAIL )
536  : name( name_r )
537  , type( type_r )
538  {}
539 
540  bool operator==( const DirEntry &rhs ) const;
541  };
542 
543  inline std::ostream & operator<<( std::ostream & str, const DirEntry & obj )
544  { return str << '[' << obj.type << "] " << obj.name; }
545 
547  typedef std::list<DirEntry> DirContent;
548 
549  std::ostream & operator<<( std::ostream & str, const DirContent & obj );
550 
561  int readdir( DirContent & retlist, const Pathname & path,
562  bool dots = true, PathInfo::Mode statmode = PathInfo::STAT );
563 
569  int is_empty_dir(const Pathname & path);
570 
572 
574 
583  int assert_file( const Pathname & path, unsigned mode = 0644 );
587  int assert_file_mode( const Pathname & path, unsigned mode = 0644 );
588 
595  int touch (const Pathname & path);
596 
602  int unlink( const Pathname & path );
603 
609  int rename( const Pathname & oldpath, const Pathname & newpath );
610 
637  int exchange( const Pathname & lpath, const Pathname & rpath );
638 
645  int copy( const Pathname & file, const Pathname & dest );
646 
653  int symlink( const Pathname & oldpath, const Pathname & newpath );
654 
661  int hardlink( const Pathname & oldpath, const Pathname & newpath );
662 
668  int hardlinkCopy( const Pathname & oldpath, const Pathname & newpath );
669 
676  int readlink( const Pathname & symlink_r, Pathname & target_r );
678  inline Pathname readlink( const Pathname & symlink_r )
679  {
680  Pathname target;
681  readlink( symlink_r, target );
682  return target;
683  }
684 
697  Pathname expandlink( const Pathname & path_r );
698 
705  int copy_file2dir( const Pathname & file, const Pathname & dest );
707 
709 
718  std::string md5sum( const Pathname & file );
719 
725  std::string sha1sum( const Pathname & file );
727 
733  std::string checksum( const Pathname & file, const std::string &algorithm );
734 
740  bool is_checksum( const Pathname & file, const CheckSum &checksum );
741 
743 
750  int chmod( const Pathname & path, mode_t mode );
751 
757  int addmod( const Pathname & path, mode_t mode );
758 
764  int delmod( const Pathname & path, mode_t mode );
766 
768 
776 
777  ZIP_TYPE zipType( const Pathname & file );
778 
786  int erase( const Pathname & path );
787 
795  ByteCount df( const Pathname & path );
796 
802  mode_t getUmask();
803 
810  inline mode_t applyUmaskTo( mode_t mode_r )
811  { return mode_r & ~getUmask(); }
813 
815  } // namespace filesystem
817 
819  using filesystem::PathInfo;
820 
822 } // namespace zypp
824 #endif // ZYPP_PATHINFO_H
FileType fileType() const
Definition: PathInfo.cc:213
bool isW() const
Short for isWUsr().
Definition: PathInfo.h:114
int assert_dir(const Pathname &path, unsigned mode)
Like 'mkdir -p'.
Definition: PathInfo.cc:320
const Pathname & path() const
Return current Pathname.
Definition: PathInfo.h:246
bool isWOth() const
Definition: PathInfo.h:311
bool isROth() const
Definition: PathInfo.h:310
bool isSock() const
Definition: PathInfo.h:102
int exchange(const Pathname &lpath, const Pathname &rpath)
Exchanges two files or directories.
Definition: PathInfo.cc:690
ZIP_TYPE
Test whether a file is compressed (gzip/bzip2).
Definition: PathInfo.h:775
Listentry returned by readdir.
Definition: PathInfo.h:532
int assert_file(const Pathname &path, unsigned mode)
Create an empty file if it does not yet exist.
Definition: PathInfo.cc:1112
std::string sha1sum(const Pathname &file)
Compute a files sha1sum.
Definition: PathInfo.cc:973
unsigned int devMinor() const
Definition: PathInfo.cc:252
std::string md5sum(const Pathname &file)
Compute a files md5sum.
Definition: PathInfo.cc:956
int error() const
Return error returned from last stat/lstat call.
Definition: PathInfo.h:254
bool isFile() const
Definition: PathInfo.h:96
int readlink(const Pathname &symlink_r, Pathname &target_r)
Like 'readlink'.
Definition: PathInfo.cc:856
time_t atime() const
Definition: PathInfo.h:375
bool lstat()
LSTAT current path.
Definition: PathInfo.h:271
bool isXUsr() const
Definition: PathInfo.h:109
bool isUid() const
Set UID bit.
Definition: PathInfo.h:136
bool isExist() const
Return whether valid stat info exists.
Definition: PathInfo.h:281
StatMode asStatMode() const
Return st_mode() as filesystem::StatMode.
Definition: PathInfo.h:330
String matching (STRING|SUBSTRING|GLOB|REGEX).
Definition: StrMatcher.h:297
Store and operate with byte count.
Definition: ByteCount.h:30
int mkdir(const Pathname &path, unsigned mode)
Like 'mkdir'.
Definition: PathInfo.cc:306
void clear()
Clear cache.
Definition: PathInfo.h:194
bool isWUsr() const
Definition: PathInfo.h:299
mode_t operm() const
Definition: PathInfo.h:155
off_t size() const
Definition: PathInfo.h:368
const std::string & asString() const
String representation.
Definition: Pathname.h:90
int hardlink(const Pathname &oldpath, const Pathname &newpath)
Like '::link'.
Definition: PathInfo.cc:803
mode_t operm() const
Definition: PathInfo.h:323
friend std::ostream & operator<<(std::ostream &str, const StatMode &obj)
Definition: PathInfo.cc:96
bool userMayRW() const
Definition: PathInfo.h:349
int chmod(const Pathname &path, mode_t mode)
Like 'chmod'.
Definition: PathInfo.cc:1024
mode_t uperm() const
Definition: PathInfo.h:321
int clean_dir(const Pathname &path)
Like 'rm -r DIR/ *'.
Definition: PathInfo.cc:443
bool isRGrp() const
Definition: PathInfo.h:306
bool isR() const
Short for isRUsr().
Definition: PathInfo.h:112
mode_t uperm() const
Definition: PathInfo.h:153
ino_t ino() const
Definition: PathInfo.h:358
dev_t rdev() const
Definition: PathInfo.h:360
bool userMayW() const
Definition: PathInfo.h:346
bool isXOth() const
Definition: PathInfo.h:312
uid_t owner() const
Definition: PathInfo.h:336
bool stat()
STAT current path.
Definition: PathInfo.h:269
bool isROth() const
Definition: PathInfo.h:128
const char * c_str() const
Return current Pathname as C-string.
Definition: PathInfo.h:250
int copy_file2dir(const Pathname &file, const Pathname &dest)
Like 'cp file dest'.
Definition: PathInfo.cc:922
DirEntry(const std::string &name_r=std::string(), FileType type_r=FT_NOT_AVAIL)
Definition: PathInfo.h:535
mode_t st_mode() const
Return the mode_t value.
Definition: PathInfo.h:160
bool isVtx() const
Sticky bit.
Definition: PathInfo.h:140
bool isXGrp() const
Definition: PathInfo.h:308
FileType fileType() const
Definition: PathInfo.cc:71
mode_t perm() const
Definition: PathInfo.h:324
Mode
stat() or lstat()
Definition: PathInfo.h:226
int is_empty_dir(const Pathname &path_r)
Check if the specified directory is empty.
Definition: PathInfo.cc:650
ZIP_TYPE zipType(const Pathname &file)
Definition: PathInfo.cc:1056
int addmod(const Pathname &path, mode_t mode)
Add the mode bits to the file given by path.
Definition: PathInfo.cc:1033
int assert_file_mode(const Pathname &path, unsigned mode)
Like assert_file but enforce mode even if the file already exists.
Definition: PathInfo.cc:1131
bool userMayRX() const
Definition: PathInfo.h:350
const StrMatcher & matchNoDots()
Convenience returning StrMatcher( "[^.]*", Match::GLOB )
Definition: PathInfo.cc:545
bool isXUsr() const
Definition: PathInfo.h:300
bool operator()()
Restat current path using current mode.
Definition: PathInfo.cc:189
bool isLink() const
Definition: PathInfo.h:98
time_t mtime() const
Definition: PathInfo.h:376
const std::string & asString() const
Return current Pathname as String.
Definition: PathInfo.h:248
int unlink(const Pathname &path)
Like 'unlink'.
Definition: PathInfo.cc:662
void setMode(Mode mode)
Set a new Mode .
Definition: PathInfo.h:259
int rename(const Pathname &oldpath, const Pathname &newpath)
Like 'rename'.
Definition: PathInfo.cc:676
Simple cache remembering device/inode to detect hardlinks.
Definition: PathInfo.h:187
int recursive_rmdir(const Pathname &path)
Like 'rm -r DIR'.
Definition: PathInfo.cc:413
bool operator()(const Pathname &path)
Restat path using current mode.
Definition: PathInfo.h:266
bool operator==(const DirEntry &rhs) const
Definition: PathInfo.cc:623
bool isRUsr() const
Definition: PathInfo.h:107
std::list< DirEntry > DirContent
Returned by readdir.
Definition: PathInfo.h:547
bool isSock() const
Definition: PathInfo.h:295
int hardlinkCopy(const Pathname &oldpath, const Pathname &newpath)
Create newpath as hardlink or copy of oldpath.
Definition: PathInfo.cc:817
bool insert(const dev_t &dev_r, const ino_t &ino_r)
Remember dev/ino.
Definition: PathInfo.h:201
nlink_t nlink() const
Definition: PathInfo.h:332
bool isDir() const
Definition: PathInfo.h:97
bool isLink() const
Definition: PathInfo.h:291
StatMode(const mode_t &mode_r=0)
Ctor taking mode_t value from ::stat.
Definition: PathInfo.h:86
time_t ctime() const
Definition: PathInfo.h:377
bool isFile() const
Definition: PathInfo.h:289
int symlink(const Pathname &oldpath, const Pathname &newpath)
Like 'symlink'.
Definition: PathInfo.cc:789
bool isX() const
Short for isXUsr().
Definition: PathInfo.h:116
bool isChr() const
Definition: PathInfo.h:99
mode_t gperm() const
Definition: PathInfo.h:322
bool isXGrp() const
Definition: PathInfo.h:123
std::map< dev_t, std::set< ino_t > > _devino
Definition: PathInfo.h:206
int touch(const Pathname &path)
Change file's modification and access times.
Definition: PathInfo.cc:1163
bool isRUsr() const
Definition: PathInfo.h:298
bool isFifo() const
Definition: PathInfo.h:294
int copy(const Pathname &file, const Pathname &dest)
Like 'cp file dest'.
Definition: PathInfo.cc:754
int readdir(std::list< std::string > &retlist_r, const Pathname &path_r, bool dots_r)
Return content of directory via retlist.
Definition: PathInfo.cc:598
bool userMayRWX() const
Definition: PathInfo.h:353
int rmdir(const Pathname &path)
Like 'rmdir'.
Definition: PathInfo.cc:367
mode_t getUmask()
Get the current umask (file mode creation mask)
Definition: PathInfo.cc:1100
bool isWOth() const
Definition: PathInfo.h:129
int copy_dir(const Pathname &srcpath, const Pathname &destpath)
Like 'cp -a srcpath destpath'.
Definition: PathInfo.cc:464
Wrapper class for mode_t values as derived from ::stat.
Definition: PathInfo.h:80
unsigned int devMajor() const
Definition: PathInfo.cc:242
mode_t perm() const
Definition: PathInfo.h:156
FileType
File type information.
Definition: PathInfo.h:55
bool userMayR() const
Definition: PathInfo.h:345
mode_t gperm() const
Definition: PathInfo.h:154
std::string checksum(const Pathname &file, const std::string &algorithm)
Compute a files checksum.
Definition: PathInfo.cc:983
int erase(const Pathname &path)
Erase whatever happens to be located at path (file or directory).
Definition: PathInfo.cc:1005
dev_t dev() const
Definition: PathInfo.h:359
bool isPerm(mode_t m) const
Definition: PathInfo.h:318
unsigned long blksize() const
Definition: PathInfo.h:369
int copy_dir_content(const Pathname &srcpath, const Pathname &destpath)
Like 'cp -a srcpath/.
Definition: PathInfo.cc:505
Wrapper class for ::stat/::lstat.
Definition: PathInfo.h:220
int dirForEach(const Pathname &dir_r, function< bool(const Pathname &, const char *const)> fnc_r)
Invoke callback function fnc_r for each entry in directory dir_r.
Definition: PathInfo.cc:551
bool isRGrp() const
Definition: PathInfo.h:121
bool isGid() const
Set GID bit.
Definition: PathInfo.h:138
bool userMayX() const
Definition: PathInfo.h:347
Pathname expandlink(const Pathname &path_r)
Recursively follows the symlink pointed to by path_r and returns the Pathname to the real file or dir...
Definition: PathInfo.cc:877
bool isFifo() const
Definition: PathInfo.h:101
mode_t applyUmaskTo(mode_t mode_r)
Modify mode_r according to the current umask ( mode_r & ~getUmask() ).
Definition: PathInfo.h:810
mode_t userMay() const
Returns current users permission ([0-7])
Definition: PathInfo.cc:225
int delmod(const Pathname &path, mode_t mode)
Remove the mode bits from the file given by path.
Definition: PathInfo.cc:1042
bool userMayWX() const
Definition: PathInfo.h:351
unsigned long blocks() const
Definition: PathInfo.h:370
std::ostream & operator<<(std::ostream &str, const Glob &obj)
Definition: Glob.cc:53
bool isPerm(mode_t m) const
Test for equal permission bits.
Definition: PathInfo.h:146
bool isWUsr() const
Definition: PathInfo.h:108
bool lstat(const Pathname &path)
LSTAT path.
Definition: PathInfo.h:264
bool hasPerm(mode_t m) const
Definition: PathInfo.h:319
friend std::ostream & operator<<(std::ostream &str, const PathInfo &obj)
Definition: PathInfo.cc:262
bool isWGrp() const
Definition: PathInfo.h:307
bool hasPerm(mode_t m) const
Test for set permission bits.
Definition: PathInfo.h:148
Mode mode() const
Return current stat Mode.
Definition: PathInfo.h:252
bool isXOth() const
Definition: PathInfo.h:130
bool stat(const Pathname &path)
STAT path.
Definition: PathInfo.h:262
gid_t group() const
Definition: PathInfo.h:337
bool is_checksum(const Pathname &file, const CheckSum &checksum)
check files checksum
Definition: PathInfo.cc:995
mode_t st_mode() const
Definition: PathInfo.h:326
void setPath(const Pathname &path)
Set a new Pathname.
Definition: PathInfo.h:257
ByteCount df(const Pathname &path_r)
Report free disk space on a mounted file system.
Definition: PathInfo.cc:1084
bool isWGrp() const
Definition: PathInfo.h:122