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