Go to the documentation of this file.
12 #ifndef ZYPP_PATHINFO_H
13 #define ZYPP_PATHINFO_H
17 #include <sys/types.h>
156 mode_t
perm()
const {
return (
_mode & (S_IRWXU|S_IRWXG|S_IRWXO|S_ISUID|S_ISGID|S_ISVTX)); }
201 bool insert(
const dev_t & dev_r,
const ino_t & ino_r ) {
202 return _devino[dev_r].insert( ino_r ).second;
324 mode_t
perm()
const {
return isExist() ? (
statbuf_C.st_mode & (S_IRWXU|S_IRWXG|S_IRWXO|S_ISUID|S_ISGID|S_ISVTX)) : 0; }
513 int readdir( std::list<std::string> & retlist,
514 const Pathname & path,
bool dots =
true );
528 int readdir( std::list<Pathname> & retlist,
529 const Pathname & path,
bool dots =
true );
544 {
return str <<
'[' << obj.
type <<
"] " << obj.
name; }
736 std::string
checksum(
const Pathname & file,
const std::string &algorithm );
822 using filesystem::PathInfo;
827 #endif // ZYPP_PATHINFO_H
int delmod(const Pathname &path, mode_t mode)
Remove the mode bits from the file given by path.
int is_empty_dir(const Pathname &path_r)
Check if the specified directory is empty.
bool isX() const
Short for isXUsr().
int readdir(std::list< std::string > &retlist_r, const Pathname &path_r, bool dots_r)
Return content of directory via retlist.
int assert_dir(const Pathname &path, unsigned mode)
Like 'mkdir -p'.
DirEntry(const std::string &name_r=std::string(), FileType type_r=FT_NOT_AVAIL)
Mode mode() const
Return current stat Mode.
bool isR() const
Short for isRUsr().
const StrMatcher & matchNoDots()
Convenience returning StrMatcher( "[^.]*", Match::GLOB )
const Pathname & path() const
Return current Pathname.
bool isExist() const
Return whether valid stat info exists.
int clean_dir(const Pathname &path)
Like 'rm -r DIR/ *'.
int mkdir(const Pathname &path, unsigned mode)
Like 'mkdir'.
String matching (STRING|SUBSTRING|GLOB|REGEX).
int assert_file_mode(const Pathname &path, unsigned mode)
Like assert_file but enforce mode even if the file already exists.
unsigned long blocks() const
int copy_file2dir(const Pathname &file, const Pathname &dest)
Like 'cp file dest'.
ZIP_TYPE
Test whether a file is compressed (gzip/bzip2).
bool operator==(const DirEntry &rhs) const
int rename(const Pathname &oldpath, const Pathname &newpath)
Like 'rename'.
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...
int symlink(const Pathname &oldpath, const Pathname &newpath)
Like 'symlink'.
bool isPerm(mode_t m) const
unsigned int devMinor() const
bool operator()()
Restat current path using current mode.
std::map< dev_t, std::set< ino_t > > _devino
FileType fileType() const
int recursive_rmdir(const Pathname &path)
Like 'rm -r DIR'.
bool isUid() const
Set UID bit.
@ language
language support
int touch(const Pathname &path)
Change file's modification and access times.
bool lstat(const Pathname &path)
LSTAT path.
int hardlink(const Pathname &oldpath, const Pathname &newpath)
Like '::link'.
bool operator()(const Pathname &path)
Restat path using current mode.
int chmod(const Pathname &path, mode_t mode)
Like 'chmod'.
int unlink(const Pathname &path)
Like 'unlink'.
Listentry returned by readdir.
mode_t st_mode() const
Return the mode_t value.
Store and operate with byte count.
unsigned int devMajor() const
int exchange(const Pathname &lpath, const Pathname &rpath)
Exchanges two files or directories.
bool hasPerm(mode_t m) const
int rmdir(const Pathname &path)
Like 'rmdir'.
Wrapper class for ::stat/::lstat.
bool stat()
STAT current path.
int copy_dir(const Pathname &srcpath, const Pathname &destpath)
Like 'cp -a srcpath destpath'.
std::string sha1sum(const Pathname &file)
Compute a files sha1sum.
std::string md5sum(const Pathname &file)
Compute a files md5sum.
std::string checksum(const Pathname &file, const std::string &algorithm)
Compute a files checksum.
StatMode asStatMode() const
Return st_mode() as filesystem::StatMode.
Easy-to use interface to the ZYPP dependency resolver.
bool isPerm(mode_t m) const
Test for equal permission bits.
std::list< DirEntry > DirContent
Returned by readdir.
int error() const
Return error returned from last stat/lstat call.
bool isW() const
Short for isWUsr().
FileType
File type information.
Simple cache remembering device/inode to detect hardlinks.
void setPath(const Pathname &path)
Set a new Pathname.
bool is_checksum(const Pathname &file, const CheckSum &checksum)
check files checksum
Wrapper class for mode_t values as derived from ::stat.
void setMode(Mode mode)
Set a new Mode .
StatMode(const mode_t &mode_r=0)
Ctor taking mode_t value from ::stat.
const std::string & asString() const
Return current Pathname as String.
int copy(const Pathname &file, const Pathname &dest)
Like 'cp file dest'.
bool hasPerm(mode_t m) const
Test for set permission bits.
int addmod(const Pathname &path, mode_t mode)
Add the mode bits to the file given by path.
const char * c_str() const
Return current Pathname as C-string.
FileType fileType() const
ByteCount df(const Pathname &path_r)
Report free disk space on a mounted file system.
mode_t getUmask()
Get the current umask (file mode creation mask)
ZIP_TYPE zipType(const Pathname &file)
int erase(const Pathname &path)
Erase whatever happens to be located at path (file or directory).
std::ostream & operator<<(std::ostream &str, const Glob &obj)
int copy_dir_content(const Pathname &srcpath, const Pathname &destpath)
Like 'cp -a srcpath/.
unsigned long blksize() const
int assert_file(const Pathname &path, unsigned mode)
Create an empty file if it does not yet exist.
mode_t userMay() const
Returns current users permission ([0-7])
bool stat(const Pathname &path)
STAT path.
bool insert(const dev_t &dev_r, const ino_t &ino_r)
Remember dev/ino.
String related utilities and Regular expression matching.
bool isVtx() const
Sticky bit.
mode_t applyUmaskTo(mode_t mode_r)
Modify mode_r according to the current umask ( mode_r & ~getUmask() ).
int hardlinkCopy(const Pathname &oldpath, const Pathname &newpath)
Create newpath as hardlink or copy of oldpath.
const std::string & asString() const
String representation.
bool isGid() const
Set GID bit.
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.
bool lstat()
LSTAT current path.
friend std::ostream & operator<<(std::ostream &str, const StatMode &obj)
friend std::ostream & operator<<(std::ostream &str, const PathInfo &obj)
int readlink(const Pathname &symlink_r, Pathname &target_r)
Like 'readlink'.