libzypp 17.37.10

PathInfo.h
Go to the documentation of this file.
1/*---------------------------------------------------------------------\
2| ____ _ __ __ ___ |
3| |__ / \ / / . \ . \ |
4| / / \ V /| _/ _/ |
5| / /__ | | | | | | |
6| /_____||_| |_| |_| |
7| |
8\---------------------------------------------------------------------*/
12#ifndef ZYPP_CORE_FS_PATHINFO_H
13#define ZYPP_CORE_FS_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#include <utility>
30
31#include <zypp-core/Pathname.h>
32#include <zypp-core/ByteCount.h>
33#include <zypp-core/CheckSum.h>
34
35 struct dirent;
36
38 namespace zypp
39{
40
41 inline bool IamRoot() { return ::geteuid() == 0; }
42 inline bool IamNotRoot() { return not IamRoot(); }
43
45
52 namespace filesystem
53 {
54
56
59 enum FileType
60 {
61 FT_NOT_AVAIL = 0x00, // no typeinfo available
62 FT_NOT_EXIST = 0x01, // file does not exist
63 FT_FILE = 0x02,
64 FT_DIR = 0x04,
65 FT_CHARDEV = 0x08,
66 FT_BLOCKDEV = 0x10,
67 FT_FIFO = 0x20,
68 FT_LINK = 0x40,
69 FT_SOCKET = 0x80
70 };
71
72
74 extern std::ostream & operator<<( std::ostream & str, FileType obj ) ZYPP_API;
75
77
79 //
80 // CLASS NAME : StatMode
85 class StatMode
86 {
87 friend std::ostream & operator<<( std::ostream & str, const StatMode & obj );
88
89 public:
91 StatMode( const mode_t & mode_r = 0 )
92 : _mode( mode_r )
93 {}
94
95 public:
96
99 FileType fileType() const;
100
101 bool isFile() const { return S_ISREG( _mode ); }
102 bool isDir () const { return S_ISDIR( _mode ); }
103 bool isLink() const { return S_ISLNK( _mode ); }
104 bool isChr() const { return S_ISCHR( _mode ); }
105 bool isBlk() const { return S_ISBLK( _mode ); }
106 bool isFifo() const { return S_ISFIFO( _mode ); }
107 bool isSock() const { return S_ISSOCK( _mode ); }
109
112 bool isRUsr() const { return (_mode & S_IRUSR); }
113 bool isWUsr() const { return (_mode & S_IWUSR); }
114 bool isXUsr() const { return (_mode & S_IXUSR); }
115
117 bool isR() const { return isRUsr(); }
119 bool isW() const { return isWUsr(); }
121 bool isX() const { return isXUsr(); }
123
126 bool isRGrp() const { return (_mode & S_IRGRP); }
127 bool isWGrp() const { return (_mode & S_IWGRP); }
128 bool isXGrp() const { return (_mode & S_IXGRP); }
130
133 bool isROth() const { return (_mode & S_IROTH); }
134 bool isWOth() const { return (_mode & S_IWOTH); }
135 bool isXOth() const { return (_mode & S_IXOTH); }
137
140
141 bool isUid() const { return (_mode & S_ISUID); }
143 bool isGid() const { return (_mode & S_ISGID); }
145 bool isVtx() const { return (_mode & S_ISVTX); }
147
150
151 bool isPerm ( mode_t m ) const { return (m == perm()); }
153 bool hasPerm( mode_t m ) const { return (m == (m & perm())); }
155
158 mode_t uperm() const { return (_mode & S_IRWXU); }
159 mode_t gperm() const { return (_mode & S_IRWXG); }
160 mode_t operm() const { return (_mode & S_IRWXO); }
161 mode_t perm() const { return (_mode & (S_IRWXU|S_IRWXG|S_IRWXO|S_ISUID|S_ISGID|S_ISVTX)); }
163
165 mode_t st_mode() const { return _mode; }
166
167 private:
168 mode_t _mode;
169 };
170
171
173 extern std::ostream & operator<<( std::ostream & str, const StatMode & obj ) ZYPP_API;
174
176
178 //
179 // CLASS NAME : DevInoCache
192 class DevInoCache
193 {
194 public:
196 DevInoCache() {}
197
199 void clear() { _devino.clear(); }
200
206 bool insert( const dev_t & dev_r, const ino_t & ino_r ) {
207 return _devino[dev_r].insert( ino_r ).second;
208 }
209
210 private:
211 std::map<dev_t,std::set<ino_t> > _devino;
212 };
213
214
216 //
217 // CLASS NAME : PathInfo
225 class ZYPP_API PathInfo
226 {
227 friend std::ostream & operator<<( std::ostream & str, const PathInfo & obj );
228
229 public:
231 enum Mode { STAT, LSTAT };
232
233 public:
238 PathInfo();
239 explicit
240 PathInfo( Pathname path, Mode initial = STAT );
241 explicit
242 PathInfo( const std::string & path, Mode initial = STAT );
243 explicit
244 PathInfo( const char * path, Mode initial = STAT );
246
248 ~PathInfo();
249
251 const Pathname & path() const { return path_t; }
253 const std::string & asString() const { return path_t.asString(); }
255 const char * c_str() const { return path_t.asString().c_str(); }
257 Mode mode() const { return mode_e; }
259 int error() const { return error_i; }
260
262 void setPath( const Pathname & path ) { if ( path != path_t ) error_i = -1; path_t = path; }
264 void setMode( Mode mode ) { if ( mode != mode_e ) error_i = -1; mode_e = mode; }
265
267 bool stat ( const Pathname & path ) { setPath( path ); setMode( STAT ); return operator()(); }
269 bool lstat ( const Pathname & path ) { setPath( path ); setMode( LSTAT ); return operator()(); }
271 bool operator()( const Pathname & path ) { setPath( path ); return operator()(); }
272
274 bool stat() { setMode( STAT ); return operator()(); }
276 bool lstat() { setMode( LSTAT ); return operator()(); }
278 bool operator()();
279
280 public:
281
286 bool isExist() const { return !error_i; }
287
293 FileType fileType() const;
294
295 bool isFile() const { return isExist() && S_ISREG( statbuf_C.st_mode ); }
296 bool isDir () const { return isExist() && S_ISDIR( statbuf_C.st_mode ); }
297 bool isLink() const { return isExist() && S_ISLNK( statbuf_C.st_mode ); }
298 bool isChr() const { return isExist() && S_ISCHR( statbuf_C.st_mode ); }
299 bool isBlk() const { return isExist() && S_ISBLK( statbuf_C.st_mode ); }
300 bool isFifo() const { return isExist() && S_ISFIFO( statbuf_C.st_mode ); }
301 bool isSock() const { return isExist() && S_ISSOCK( statbuf_C.st_mode ); }
302
303 // permission
304 bool isRUsr() const { return isExist() && (statbuf_C.st_mode & S_IRUSR); }
305 bool isWUsr() const { return isExist() && (statbuf_C.st_mode & S_IWUSR); }
306 bool isXUsr() const { return isExist() && (statbuf_C.st_mode & S_IXUSR); }
307
308 bool isR() const { return isRUsr(); }
309 bool isW() const { return isWUsr(); }
310 bool isX() const { return isXUsr(); }
311
312 bool isRGrp() const { return isExist() && (statbuf_C.st_mode & S_IRGRP); }
313 bool isWGrp() const { return isExist() && (statbuf_C.st_mode & S_IWGRP); }
314 bool isXGrp() const { return isExist() && (statbuf_C.st_mode & S_IXGRP); }
315
316 bool isROth() const { return isExist() && (statbuf_C.st_mode & S_IROTH); }
317 bool isWOth() const { return isExist() && (statbuf_C.st_mode & S_IWOTH); }
318 bool isXOth() const { return isExist() && (statbuf_C.st_mode & S_IXOTH); }
319
320 bool isUid() const { return isExist() && (statbuf_C.st_mode & S_ISUID); }
321 bool isGid() const { return isExist() && (statbuf_C.st_mode & S_ISGID); }
322 bool isVtx() const { return isExist() && (statbuf_C.st_mode & S_ISVTX); }
323
324 bool isPerm ( mode_t m ) const { return isExist() && (m == perm()); }
325 bool hasPerm( mode_t m ) const { return isExist() && (m == (m & perm())); }
326
327 mode_t uperm() const { return isExist() ? (statbuf_C.st_mode & S_IRWXU) : 0; }
328 mode_t gperm() const { return isExist() ? (statbuf_C.st_mode & S_IRWXG) : 0; }
329 mode_t operm() const { return isExist() ? (statbuf_C.st_mode & S_IRWXO) : 0; }
330 mode_t perm() const { return isExist() ? (statbuf_C.st_mode & (S_IRWXU|S_IRWXG|S_IRWXO|S_ISUID|S_ISGID|S_ISVTX)) : 0; }
331
332 mode_t st_mode() const { return isExist() ? statbuf_C.st_mode : 0; }
334
336 StatMode asStatMode() const { return st_mode(); }
337
338 nlink_t nlink() const { return isExist() ? statbuf_C.st_nlink : 0; }
339
342 uid_t owner() const { return isExist() ? statbuf_C.st_uid : 0; }
343 gid_t group() const { return isExist() ? statbuf_C.st_gid : 0; }
345
350
351 mode_t userMay() const;
352
353 bool userMayR() const { return( userMay() & 04 ); }
354 bool userMayW() const { return( userMay() & 02 ); }
355 bool userMayX() const { return( userMay() & 01 ); }
356
357 bool userMayRW() const { return( (userMay() & 06) == 06 ); }
358 bool userMayRX() const { return( (userMay() & 05) == 05 ); }
359 bool userMayWX() const { return( (userMay() & 03) == 03 ); }
360
361 bool userMayRWX() const { return( userMay() == 07 ); }
363
366 ino_t ino() const { return isExist() ? statbuf_C.st_ino : 0; }
367 dev_t dev() const { return isExist() ? statbuf_C.st_dev : 0; }
368 dev_t rdev() const { return isExist() ? statbuf_C.st_rdev : 0; }
369
370 unsigned int devMajor() const;
371 unsigned int devMinor() const;
373
376 off_t size() const { return isExist() ? statbuf_C.st_size : 0; }
377 unsigned long blksize() const { return isExist() ? statbuf_C.st_blksize : 0; }
378 unsigned long blocks() const { return isExist() ? statbuf_C.st_blocks : 0; }
380
383 time_t atime() const { return isExist() ? statbuf_C.st_atime : 0; } /* time of last access */
384 time_t mtime() const { return isExist() ? statbuf_C.st_mtime : 0; } /* time of last modification */
385 time_t ctime() const { return isExist() ? statbuf_C.st_ctime : 0; }
387
388 private:
389 Pathname path_t;
390 struct stat statbuf_C;
391 Mode mode_e;
392 int error_i;
393 };
394
395
397 extern std::ostream & operator<<( std::ostream & str, const PathInfo & obj ) ZYPP_API;
398
400
402
404
411 int mkdir( const Pathname & path, unsigned mode = 0755 ) ZYPP_API;
412
420 int assert_dir( const Pathname & path, unsigned mode = 0755 ) ZYPP_API;
421
427 int rmdir( const Pathname & path ) ZYPP_API;
428
435 int recursive_rmdir( const Pathname & path ) ZYPP_API;
436
443 int clean_dir( const Pathname & path ) ZYPP_API;
444
452 int copy_dir( const Pathname & srcpath, const Pathname & destpath ) ZYPP_API;
453
462 int copy_dir_content( const Pathname & srcpath, const Pathname & destpath) ZYPP_API;
463
476 int dirForEach( const Pathname & dir_r, const function<bool(const Pathname &, const char *const)>& fnc_r ) ZYPP_API;
477
489
490 int readdir( std::list<std::string> & retlist,
491 const Pathname & path, bool dots = true ) ZYPP_API;
492
504
505 int readdir( std::list<Pathname> & retlist,
506 const Pathname & path, bool dots = true ) ZYPP_API;
507
509 struct DirEntry {
510 std::string name;
511 FileType type;
512 DirEntry( std::string name_r = std::string(), FileType type_r = FT_NOT_AVAIL )
513 : name(std::move( name_r ))
514 , type( type_r )
515 {}
516
517 DirEntry( struct dirent* entry );
518
519 bool operator==( const DirEntry &rhs ) const;
520 };
521
522 inline std::ostream & operator<<( std::ostream & str, const DirEntry & obj )
523 { return str << '[' << obj.type << "] " << obj.name; }
524
526 using DirContent = std::list<DirEntry>;
527
528 std::ostream & operator<<( std::ostream & str, const DirContent & obj ) ZYPP_API;
529
540 int readdir( DirContent & retlist, const Pathname & path,
541 bool dots = true, PathInfo::Mode statmode = PathInfo::STAT ) ZYPP_API;
542
546 int dirForEachExt( const Pathname & dir_r, const function<bool(const Pathname &, const DirEntry &)> &fnc_r ) ZYPP_API;
547
553 int is_empty_dir(const Pathname & path) ZYPP_API;
554
556
558
560
567 int assert_file( const Pathname & path, unsigned mode = 0644 ) ZYPP_API;
568
572 int assert_file_mode( const Pathname & path, unsigned mode = 0644 ) ZYPP_API;
573
580 int touch (const Pathname & path) ZYPP_API;
581
587 int unlink( const Pathname & path ) ZYPP_API;
588
597 int rename( const Pathname & oldpath, const Pathname & newpath ) ZYPP_API;
598
625 int exchange( const Pathname & lpath, const Pathname & rpath );
626
633 int copy( const Pathname & file, const Pathname & dest ) ZYPP_API;
634
641 int symlink( const Pathname & oldpath, const Pathname & newpath ) ZYPP_API;
642
649 int hardlink( const Pathname & oldpath, const Pathname & newpath ) ZYPP_API;
650
656 int hardlinkCopy( const Pathname & oldpath, const Pathname & newpath ) ZYPP_API;
657
664 int readlink( const Pathname & symlink_r, Pathname & target_r );
665 /** \overload Return an empty Pathname on error. */
666 inline Pathname readlink( const Pathname & symlink_r )
667 {
668 Pathname target;
669 readlink( symlink_r, target );
670 return target;
671 }
672
685 Pathname expandlink( const Pathname & path_r ) ZYPP_API;
686
693 int copy_file2dir( const Pathname & file, const Pathname & dest );
695
697
701
706 std::string md5sum( const Pathname & file );
707
713 std::string sha1sum( const Pathname & file );
715
721 std::string checksum( const Pathname & file, const std::string &algorithm );
722
728 bool is_checksum( const Pathname & file, const CheckSum &checksum );
729
731
733
738 int chmod( const Pathname & path, mode_t mode );
739
746 int chmodApplyUmask( const Pathname & path, mode_t mode );
747
753 int addmod( const Pathname & path, mode_t mode );
754
760 int delmod( const Pathname & path, mode_t mode );
762
764
766
771 enum ZIP_TYPE { ZT_NONE, ZT_GZ, ZT_BZ2, ZT_ZCHNK };
772
773 ZIP_TYPE zipType( const Pathname & file );
774
782 int erase( const Pathname & path );
783
791 ByteCount df( const Pathname & path );
792
798 mode_t getUmask();
799
805 **/
806 inline mode_t applyUmaskTo( mode_t mode_r )
807 { return mode_r & ~getUmask(); }
809
811 } // namespace filesystem
813
815 using filesystem::PathInfo;
816
818} // namespace zypp
820#endif // ZYPP_PATHINFO_H
operator<<
std::ostream & operator<<(std::ostream &str, const zypp::sat::detail::CDataiterator *obj)
Definition LookupAttr.cc:808
zypp::Arch::operator()
bool operator()(const zypp::Arch &lhs, const zypp::Arch &rhs) const
Default order for std::container based Arch::compare.
Definition Arch.h:370
zypp::ByteCount
Store and operate with byte count.
Definition ByteCount.h:32
zypp::CheckSum
Definition CheckSum.h:34
zypp::filesystem::DevInoCache::clear
void clear()
Clear cache.
Definition PathInfo.h:199
zypp::filesystem::DevInoCache::insert
bool insert(const dev_t &dev_r, const ino_t &ino_r)
Remember dev/ino.
Definition PathInfo.h:206
zypp::filesystem::DevInoCache::_devino
std::map< dev_t, std::set< ino_t > > _devino
Definition PathInfo.h:211
zypp::filesystem::DevInoCache::DevInoCache
DevInoCache()
Ctor.
Definition PathInfo.h:196
zypp::filesystem::PathInfo
Wrapper class for stat/lstat.
Definition PathInfo.h:226
zypp::filesystem::PathInfo::path_t
Pathname path_t
Definition PathInfo.h:389
zypp::filesystem::PathInfo::nlink
nlink_t nlink() const
Definition PathInfo.h:338
zypp::filesystem::PathInfo::perm
mode_t perm() const
Definition PathInfo.h:330
zypp::filesystem::PathInfo::isUid
bool isUid() const
Definition PathInfo.h:320
zypp::filesystem::PathInfo::dev
dev_t dev() const
Definition PathInfo.h:367
zypp::filesystem::PathInfo::isBlk
bool isBlk() const
Definition PathInfo.h:299
zypp::filesystem::PathInfo::PathInfo
PathInfo()
Definition PathInfo.cc:131
zypp::filesystem::PathInfo::isRGrp
bool isRGrp() const
Definition PathInfo.h:312
zypp::filesystem::PathInfo::lstat
bool lstat(const Pathname &path)
LSTAT path.
Definition PathInfo.h:269
zypp::filesystem::PathInfo::userMayR
bool userMayR() const
Definition PathInfo.h:353
zypp::filesystem::PathInfo::userMayRW
bool userMayRW() const
Definition PathInfo.h:357
zypp::filesystem::PathInfo::isXGrp
bool isXGrp() const
Definition PathInfo.h:314
zypp::filesystem::PathInfo::isX
bool isX() const
Definition PathInfo.h:310
zypp::filesystem::PathInfo::uperm
mode_t uperm() const
Definition PathInfo.h:327
zypp::filesystem::PathInfo::userMayW
bool userMayW() const
Definition PathInfo.h:354
zypp::filesystem::PathInfo::asStatMode
StatMode asStatMode() const
Return st_mode() as filesystem::StatMode.
Definition PathInfo.h:336
zypp::filesystem::PathInfo::mtime
time_t mtime() const
Definition PathInfo.h:384
zypp::filesystem::PathInfo::blksize
unsigned long blksize() const
Definition PathInfo.h:377
zypp::filesystem::PathInfo::userMayX
bool userMayX() const
Definition PathInfo.h:355
zypp::filesystem::PathInfo::mode
Mode mode() const
Return current stat Mode.
Definition PathInfo.h:257
zypp::filesystem::PathInfo::stat
bool stat()
STAT current path.
Definition PathInfo.h:274
zypp::filesystem::PathInfo::ctime
time_t ctime() const
Definition PathInfo.h:385
zypp::filesystem::PathInfo::isPerm
bool isPerm(mode_t m) const
Definition PathInfo.h:324
zypp::filesystem::PathInfo::userMayRX
bool userMayRX() const
Definition PathInfo.h:358
zypp::filesystem::PathInfo::st_mode
mode_t st_mode() const
Definition PathInfo.h:332
zypp::filesystem::PathInfo::isGid
bool isGid() const
Definition PathInfo.h:321
zypp::filesystem::PathInfo::isW
bool isW() const
Definition PathInfo.h:309
zypp::filesystem::PathInfo::userMayRWX
bool userMayRWX() const
Definition PathInfo.h:361
zypp::filesystem::PathInfo::path
const Pathname & path() const
Return current Pathname.
Definition PathInfo.h:251
zypp::filesystem::PathInfo::setPath
void setPath(const Pathname &path)
Set a new Pathname.
Definition PathInfo.h:262
zypp::filesystem::PathInfo::isWOth
bool isWOth() const
Definition PathInfo.h:317
zypp::filesystem::PathInfo::isRUsr
bool isRUsr() const
Definition PathInfo.h:304
zypp::filesystem::PathInfo::isR
bool isR() const
Definition PathInfo.h:308
zypp::filesystem::PathInfo::isDir
bool isDir() const
Definition PathInfo.h:296
zypp::filesystem::PathInfo::isFile
bool isFile() const
Definition PathInfo.h:295
zypp::filesystem::PathInfo::Mode
Mode
stat() or lstat()
Definition PathInfo.h:231
zypp::filesystem::PathInfo::STAT
@ STAT
Definition PathInfo.h:231
zypp::filesystem::PathInfo::LSTAT
@ LSTAT
Definition PathInfo.h:231
zypp::filesystem::PathInfo::isWUsr
bool isWUsr() const
Definition PathInfo.h:305
zypp::filesystem::PathInfo::atime
time_t atime() const
Definition PathInfo.h:383
zypp::filesystem::PathInfo::gperm
mode_t gperm() const
Definition PathInfo.h:328
zypp::filesystem::PathInfo::rdev
dev_t rdev() const
Definition PathInfo.h:368
zypp::filesystem::PathInfo::setMode
void setMode(Mode mode)
Set a new Mode .
Definition PathInfo.h:264
zypp::filesystem::PathInfo::userMayWX
bool userMayWX() const
Definition PathInfo.h:359
zypp::filesystem::PathInfo::lstat
bool lstat()
LSTAT current path.
Definition PathInfo.h:276
zypp::filesystem::PathInfo::isLink
bool isLink() const
Definition PathInfo.h:297
zypp::filesystem::PathInfo::isSock
bool isSock() const
Definition PathInfo.h:301
zypp::filesystem::PathInfo::isFifo
bool isFifo() const
Definition PathInfo.h:300
zypp::filesystem::PathInfo::size
off_t size() const
Definition PathInfo.h:376
zypp::filesystem::PathInfo::statbuf_C
struct stat statbuf_C
Definition PathInfo.h:390
zypp::filesystem::PathInfo::mode_e
Mode mode_e
Definition PathInfo.h:391
zypp::filesystem::PathInfo::isVtx
bool isVtx() const
Definition PathInfo.h:322
zypp::filesystem::PathInfo::userMay
mode_t userMay() const
Returns current users permission ([0-7])
Definition PathInfo.cc:225
zypp::filesystem::PathInfo::blocks
unsigned long blocks() const
Definition PathInfo.h:378
zypp::filesystem::PathInfo::isROth
bool isROth() const
Definition PathInfo.h:316
zypp::filesystem::PathInfo::isExist
bool isExist() const
Return whether valid stat info exists.
Definition PathInfo.h:286
zypp::filesystem::PathInfo::owner
uid_t owner() const
Definition PathInfo.h:342
zypp::filesystem::PathInfo::operm
mode_t operm() const
Definition PathInfo.h:329
zypp::filesystem::PathInfo::c_str
const char * c_str() const
Return current Pathname as C-string.
Definition PathInfo.h:255
zypp::filesystem::PathInfo::group
gid_t group() const
Definition PathInfo.h:343
zypp::filesystem::PathInfo::asString
const std::string & asString() const
Return current Pathname as String.
Definition PathInfo.h:253
zypp::filesystem::PathInfo::error_i
int error_i
Definition PathInfo.h:392
zypp::filesystem::PathInfo::hasPerm
bool hasPerm(mode_t m) const
Definition PathInfo.h:325
zypp::filesystem::PathInfo::isChr
bool isChr() const
Definition PathInfo.h:298
zypp::filesystem::PathInfo::isWGrp
bool isWGrp() const
Definition PathInfo.h:313
zypp::filesystem::PathInfo::isXOth
bool isXOth() const
Definition PathInfo.h:318
zypp::filesystem::PathInfo::ino
ino_t ino() const
Definition PathInfo.h:366
zypp::filesystem::PathInfo::isXUsr
bool isXUsr() const
Definition PathInfo.h:306
zypp::filesystem::PathInfo::operator()
bool operator()(const Pathname &path)
Restat path using current mode.
Definition PathInfo.h:271
zypp::filesystem::PathInfo::error
int error() const
Return error returned from last stat/lstat call.
Definition PathInfo.h:259
zypp::filesystem::PathInfo::stat
bool stat(const Pathname &path)
STAT path.
Definition PathInfo.h:267
zypp::filesystem::Pathname
Pathname.
Definition Pathname.h:47
zypp::filesystem::Pathname::operator==
bool operator==(const Pathname &l, const Pathname &r)
Definition Pathname.h:185
zypp::filesystem::StatMode
Wrapper class for mode_t values as derived from stat.
Definition PathInfo.h:86
zypp::filesystem::StatMode::isR
bool isR() const
Short for isRUsr().
Definition PathInfo.h:117
zypp::filesystem::StatMode::isW
bool isW() const
Short for isWUsr().
Definition PathInfo.h:119
zypp::filesystem::StatMode::isXOth
bool isXOth() const
Definition PathInfo.h:135
zypp::filesystem::StatMode::isRGrp
bool isRGrp() const
Definition PathInfo.h:126
zypp::filesystem::StatMode::st_mode
mode_t st_mode() const
Return the mode_t value.
Definition PathInfo.h:165
zypp::filesystem::StatMode::isSock
bool isSock() const
Definition PathInfo.h:107
zypp::filesystem::StatMode::isWUsr
bool isWUsr() const
Definition PathInfo.h:113
zypp::filesystem::StatMode::_mode
mode_t _mode
Definition PathInfo.h:168
zypp::filesystem::StatMode::isWOth
bool isWOth() const
Definition PathInfo.h:134
zypp::filesystem::StatMode::gperm
mode_t gperm() const
Definition PathInfo.h:159
zypp::filesystem::StatMode::isROth
bool isROth() const
Definition PathInfo.h:133
zypp::filesystem::StatMode::isXGrp
bool isXGrp() const
Definition PathInfo.h:128
zypp::filesystem::StatMode::isVtx
bool isVtx() const
Sticky bit.
Definition PathInfo.h:145
zypp::filesystem::StatMode::perm
mode_t perm() const
Definition PathInfo.h:161
zypp::filesystem::StatMode::isFile
bool isFile() const
Definition PathInfo.h:101
zypp::filesystem::StatMode::hasPerm
bool hasPerm(mode_t m) const
Test for set permission bits.
Definition PathInfo.h:153
zypp::filesystem::StatMode::isUid
bool isUid() const
Set UID bit.
Definition PathInfo.h:141
zypp::filesystem::StatMode::isRUsr
bool isRUsr() const
Definition PathInfo.h:112
zypp::filesystem::StatMode::isWGrp
bool isWGrp() const
Definition PathInfo.h:127
zypp::filesystem::StatMode::isFifo
bool isFifo() const
Definition PathInfo.h:106
zypp::filesystem::StatMode::operm
mode_t operm() const
Definition PathInfo.h:160
zypp::filesystem::StatMode::isX
bool isX() const
Short for isXUsr().
Definition PathInfo.h:121
zypp::filesystem::StatMode::isDir
bool isDir() const
Definition PathInfo.h:102
zypp::filesystem::StatMode::isBlk
bool isBlk() const
Definition PathInfo.h:105
zypp::filesystem::StatMode::uperm
mode_t uperm() const
Definition PathInfo.h:158
zypp::filesystem::StatMode::fileType
FileType fileType() const
Definition PathInfo.cc:71
zypp::filesystem::StatMode::isPerm
bool isPerm(mode_t m) const
Test for equal permission bits.
Definition PathInfo.h:151
zypp::filesystem::StatMode::StatMode
StatMode(const mode_t &mode_r=0)
Ctor taking mode_t value from stat.
Definition PathInfo.h:91
zypp::filesystem::StatMode::isLink
bool isLink() const
Definition PathInfo.h:103
zypp::filesystem::StatMode::isGid
bool isGid() const
Set GID bit.
Definition PathInfo.h:143
zypp::filesystem::StatMode::operator<<
friend std::ostream & operator<<(std::ostream &str, const StatMode &obj)
Definition PathInfo.cc:96
zypp::filesystem::StatMode::isXUsr
bool isXUsr() const
Definition PathInfo.h:114
zypp::filesystem::StatMode::isChr
bool isChr() const
Definition PathInfo.h:104
std
Definition Arch.h:364
str
String related utilities and Regular expression matching.
zypp::filesystem::chmod
int chmod(const Pathname &path, mode_t mode)
Like 'chmod'.
Definition PathInfo.cc:1097
zypp::filesystem::symlink
int symlink(const Pathname &oldpath, const Pathname &newpath)
Like 'symlink'.
Definition PathInfo.cc:860
zypp::filesystem::operator<<
std::ostream & operator<<(std::ostream &str, const Glob &obj)
Definition Glob.cc:53
zypp::filesystem::checksum
std::string checksum(const Pathname &file, const std::string &algorithm)
Compute a files checksum.
Definition PathInfo.cc:1056
zypp::filesystem::delmod
int delmod(const Pathname &path, mode_t mode)
Remove the mode bits from the file given by path.
Definition PathInfo.cc:1118
zypp::filesystem::rmdir
int rmdir(const Pathname &path)
Like 'rmdir'.
Definition PathInfo.cc:371
zypp::filesystem::mkdir
int mkdir(const Pathname &path, unsigned mode)
Like 'mkdir'.
Definition PathInfo.cc:310
zypp::filesystem::FileType
FileType
File type information.
Definition PathInfo.h:60
zypp::filesystem::FT_LINK
@ FT_LINK
Definition PathInfo.h:68
zypp::filesystem::FT_DIR
@ FT_DIR
Definition PathInfo.h:64
zypp::filesystem::FT_SOCKET
@ FT_SOCKET
Definition PathInfo.h:69
zypp::filesystem::FT_NOT_EXIST
@ FT_NOT_EXIST
Definition PathInfo.h:62
zypp::filesystem::FT_FIFO
@ FT_FIFO
Definition PathInfo.h:67
zypp::filesystem::FT_NOT_AVAIL
@ FT_NOT_AVAIL
Definition PathInfo.h:61
zypp::filesystem::FT_CHARDEV
@ FT_CHARDEV
Definition PathInfo.h:65
zypp::filesystem::FT_BLOCKDEV
@ FT_BLOCKDEV
Definition PathInfo.h:66
zypp::filesystem::FT_FILE
@ FT_FILE
Definition PathInfo.h:63
zypp::filesystem::assert_file
int assert_file(const Pathname &path, unsigned mode)
Create an empty file if it does not yet exist.
Definition PathInfo.cc:1191
zypp::filesystem::copy_dir
int copy_dir(const Pathname &srcpath, const Pathname &destpath)
Like 'cp -a srcpath destpath'.
Definition PathInfo.cc:468
zypp::filesystem::applyUmaskTo
mode_t applyUmaskTo(mode_t mode_r)
Modify mode_r according to the current umask ( mode_r & ~getUmask() ).
Definition PathInfo.h:805
zypp::filesystem::recursive_rmdir
int recursive_rmdir(const Pathname &path)
Like 'rm -r DIR'.
Definition PathInfo.cc:417
zypp::filesystem::df
ByteCount df(const Pathname &path_r)
Report free disk space on a mounted file system.
Definition PathInfo.cc:1163
zypp::filesystem::DirContent
std::list< DirEntry > DirContent
Returned by readdir.
Definition PathInfo.h:526
zypp::filesystem::hardlinkCopy
int hardlinkCopy(const Pathname &oldpath, const Pathname &newpath)
Create newpath as hardlink or copy of oldpath.
Definition PathInfo.cc:888
zypp::filesystem::assert_file_mode
int assert_file_mode(const Pathname &path, unsigned mode)
Like assert_file but enforce mode even if the file already exists.
Definition PathInfo.cc:1210
zypp::filesystem::copy
int copy(const Pathname &file, const Pathname &dest)
Like 'cp file dest'.
Definition PathInfo.cc:825
zypp::filesystem::clean_dir
int clean_dir(const Pathname &path)
Like 'rm -r DIR/ *'.
Definition PathInfo.cc:447
zypp::filesystem::is_checksum
bool is_checksum(const Pathname &file, const CheckSum &checksum)
check files checksum
Definition PathInfo.cc:1068
zypp::filesystem::expandlink
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:950
zypp::filesystem::unlink
int unlink(const Pathname &path)
Like 'unlink'.
Definition PathInfo.cc:705
zypp::filesystem::readdir
int readdir(std::list< std::string > &retlist_r, const Pathname &path_r, bool dots_r)
Return content of directory via retlist.
Definition PathInfo.cc:610
zypp::filesystem::dirForEach
int dirForEach(const Pathname &dir_r, const StrMatcher &matcher_r, function< bool(const Pathname &, const char *const)> fnc_r)
Definition PathInfo.cc:32
zypp::filesystem::erase
int erase(const Pathname &path)
Erase whatever happens to be located at path (file or directory).
Definition PathInfo.cc:1078
zypp::filesystem::addmod
int addmod(const Pathname &path, mode_t mode)
Add the mode bits to the file given by path.
Definition PathInfo.cc:1109
zypp::filesystem::assert_dir
int assert_dir(const Pathname &path, unsigned mode)
Like 'mkdir -p'.
Definition PathInfo.cc:324
zypp::filesystem::readlink
int readlink(const Pathname &symlink_r, Pathname &target_r)
Like 'readlink'.
Definition PathInfo.cc:929
zypp::filesystem::copy_file2dir
int copy_file2dir(const Pathname &file, const Pathname &dest)
Like 'cp file dest'.
Definition PathInfo.cc:995
zypp::filesystem::getUmask
mode_t getUmask()
Get the current umask (file mode creation mask)
Definition PathInfo.cc:1179
zypp::filesystem::copy_dir_content
int copy_dir_content(const Pathname &srcpath, const Pathname &destpath)
Like 'cp -a srcpath/.
Definition PathInfo.cc:509
zypp::filesystem::dirForEachExt
int dirForEachExt(const Pathname &dir_r, const function< bool(const Pathname &, const DirEntry &)> &fnc_r)
Simiar to.
Definition PathInfo.cc:598
zypp::filesystem::is_empty_dir
int is_empty_dir(const Pathname &path_r)
Check if the specified directory is empty.
Definition PathInfo.cc:693
zypp::filesystem::md5sum
std::string md5sum(const Pathname &file)
Compute a files md5sum.
Definition PathInfo.cc:1029
zypp::filesystem::hardlink
int hardlink(const Pathname &oldpath, const Pathname &newpath)
Like 'link'.
Definition PathInfo.cc:874
zypp::filesystem::exchange
int exchange(const Pathname &lpath, const Pathname &rpath)
Exchanges two files or directories.
Definition PathInfo.cc:761
zypp::filesystem::sha1sum
std::string sha1sum(const Pathname &file)
Compute a files sha1sum.
Definition PathInfo.cc:1046
zypp::filesystem::zipType
ZIP_TYPE zipType(const Pathname &file)
Definition PathInfo.cc:1132
zypp::filesystem::ZIP_TYPE
ZIP_TYPE
Test whether a file is compressed (gzip/bzip2).
Definition PathInfo.h:770
zypp::filesystem::ZT_GZ
@ ZT_GZ
Definition PathInfo.h:770
zypp::filesystem::ZT_BZ2
@ ZT_BZ2
Definition PathInfo.h:770
zypp::filesystem::ZT_NONE
@ ZT_NONE
Definition PathInfo.h:770
zypp::filesystem::ZT_ZCHNK
@ ZT_ZCHNK
Definition PathInfo.h:770
zypp::filesystem::rename
int rename(const Pathname &oldpath, const Pathname &newpath)
Like 'rename'.
Definition PathInfo.cc:747
zypp::filesystem::chmodApplyUmask
int chmodApplyUmask(const Pathname &path, mode_t mode)
Similar to 'chmod', but mode is modified by the process's umask in the usual way.
Definition PathInfo.cc:1106
zypp::filesystem::touch
int touch(const Pathname &path)
Change file's modification and access times.
Definition PathInfo.cc:1242
zypp::target
Definition KeyRing.h:325
zypp
Easy-to use interface to the ZYPP dependency resolver.
Definition Application.cc:20
zypp::IamRoot
bool IamRoot()
Definition PathInfo.h:41
zypp::IamNotRoot
bool IamNotRoot()
Definition PathInfo.h:42
zypp::ZYPP_API
const Arch Arch_armv7hnl Arch_armv7nhl ZYPP_API
Definition Arch.h:247
zypp::filesystem::DirEntry
Listentry returned by readdir.
Definition PathInfo.h:509
zypp::filesystem::DirEntry::name
std::string name
Definition PathInfo.h:510
zypp::filesystem::DirEntry::DirEntry
DirEntry(std::string name_r=std::string(), FileType type_r=FT_NOT_AVAIL)
Definition PathInfo.h:512
zypp::filesystem::DirEntry::type
FileType type
Definition PathInfo.h:511
ByteCount.h
CheckSum.h
Pathname.h