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