12#ifndef ZYPP_CORE_FS_PATHINFO_H
13#define ZYPP_CORE_FS_PATHINFO_H
41 inline bool IamRoot() { return ::geteuid() == 0; }
161 mode_t
perm()
const {
return (
_mode & (S_IRWXU|S_IRWXG|S_IRWXO|S_ISUID|S_ISGID|S_ISVTX)); }
206 bool insert(
const dev_t & dev_r,
const ino_t & ino_r ) {
207 return _devino[dev_r].insert( ino_r ).second;
242 PathInfo(
const std::string & path, Mode initial = STAT );
244 PathInfo(
const char * path, Mode initial = STAT );
330 mode_t
perm()
const {
return isExist() ? (
statbuf_C.st_mode & (S_IRWXU|S_IRWXG|S_IRWXO|S_ISUID|S_ISGID|S_ISVTX)) : 0; }
351 mode_t userMay()
const;
370 unsigned int devMajor()
const;
371 unsigned int devMinor()
const;
523 {
return str <<
'[' << obj.
type <<
"] " << obj.
name; }
721 std::string
checksum(
const Pathname & file,
const std::string &algorithm );
815 using filesystem::PathInfo;
std::ostream & operator<<(std::ostream &str, const zypp::sat::detail::CDataiterator *obj)
bool operator()(const zypp::Arch &lhs, const zypp::Arch &rhs) const
Default order for std::container based Arch::compare.
Store and operate with byte count.
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.
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.
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
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.
bool operator==(const Pathname &l, const Pathname &r)
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'.
int symlink(const Pathname &oldpath, const Pathname &newpath)
Like 'symlink'.
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.
int rmdir(const Pathname &path)
Like 'rmdir'.
int mkdir(const Pathname &path, unsigned mode)
Like 'mkdir'.
FileType
File type information.
int assert_file(const Pathname &path, unsigned mode)
Create an empty file if it does not yet exist.
int copy_dir(const Pathname &srcpath, const Pathname &destpath)
Like 'cp -a srcpath destpath'.
mode_t applyUmaskTo(mode_t mode_r)
Modify mode_r according to the current umask ( mode_r & ~getUmask() ).
int recursive_rmdir(const Pathname &path)
Like 'rm -r DIR'.
ByteCount df(const Pathname &path_r)
Report free disk space on a mounted file system.
std::list< DirEntry > DirContent
Returned by readdir.
int hardlinkCopy(const Pathname &oldpath, const Pathname &newpath)
Create newpath as hardlink or copy of oldpath.
int assert_file_mode(const Pathname &path, unsigned mode)
Like assert_file but enforce mode even if the file already exists.
int copy(const Pathname &file, const Pathname &dest)
Like 'cp file dest'.
int clean_dir(const Pathname &path)
Like 'rm -r DIR/ *'.
bool is_checksum(const Pathname &file, const CheckSum &checksum)
check files checksum
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 unlink(const Pathname &path)
Like 'unlink'.
int readdir(std::list< std::string > &retlist_r, const Pathname &path_r, bool dots_r)
Return content of directory via retlist.
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 assert_dir(const Pathname &path, unsigned mode)
Like 'mkdir -p'.
int readlink(const Pathname &symlink_r, Pathname &target_r)
Like 'readlink'.
int copy_file2dir(const Pathname &file, const Pathname &dest)
Like 'cp file dest'.
mode_t getUmask()
Get the current umask (file mode creation mask)
int copy_dir_content(const Pathname &srcpath, const Pathname &destpath)
Like 'cp -a srcpath/.
int dirForEachExt(const Pathname &dir_r, const function< bool(const Pathname &, const DirEntry &)> &fnc_r)
Simiar to.
int is_empty_dir(const Pathname &path_r)
Check if the specified directory is empty.
std::string md5sum(const Pathname &file)
Compute a files md5sum.
int hardlink(const Pathname &oldpath, const Pathname &newpath)
Like 'link'.
int exchange(const Pathname &lpath, const Pathname &rpath)
Exchanges two files or directories.
std::string sha1sum(const Pathname &file)
Compute a files sha1sum.
ZIP_TYPE zipType(const Pathname &file)
ZIP_TYPE
Test whether a file is compressed (gzip/bzip2).
int rename(const Pathname &oldpath, const Pathname &newpath)
Like 'rename'.
int chmodApplyUmask(const Pathname &path, mode_t mode)
Similar to 'chmod', but mode is modified by the process's umask in the usual way.
int touch(const Pathname &path)
Change file's modification and access times.
Easy-to use interface to the ZYPP dependency resolver.
const Arch Arch_armv7hnl Arch_armv7nhl ZYPP_API
Listentry returned by readdir.
DirEntry(std::string name_r=std::string(), FileType type_r=FT_NOT_AVAIL)