libzypp 17.38.3
PathInfo.h File Reference
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <unistd.h>
#include <dirent.h>
#include <cerrno>
#include <iosfwd>
#include <list>
#include <set>
#include <map>
#include <utility>
#include <zypp-core/Pathname.h>
#include <zypp-core/ByteCount.h>
#include <zypp-core/CheckSum.h>
Include dependency graph for PathInfo.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

class  zypp::filesystem::StatMode
 Wrapper class for mode_t values as derived from ::stat. More...
class  zypp::filesystem::DevInoCache
 Simple cache remembering device/inode to detect hardlinks. More...
class  zypp::filesystem::PathInfo
 Wrapper class for ::stat/::lstat. More...
struct  zypp::filesystem::DirEntry
 Listentry returned by readdir. More...

Namespaces

namespace  zypp
 Easy-to use interface to the ZYPP dependency resolver.
namespace  zypp::filesystem
 Types and functions for filesystem operations.

Enumerations

enum  zypp::filesystem::FileType {
  zypp::filesystem::FT_NOT_AVAIL = 0x00 , zypp::filesystem::FT_NOT_EXIST = 0x01 , zypp::filesystem::FT_FILE = 0x02 , zypp::filesystem::FT_DIR = 0x04 ,
  zypp::filesystem::FT_CHARDEV = 0x08 , zypp::filesystem::FT_BLOCKDEV = 0x10 , zypp::filesystem::FT_FIFO = 0x20 , zypp::filesystem::FT_LINK = 0x40 ,
  zypp::filesystem::FT_SOCKET = 0x80
}
 File type information. More...

Functions

bool zypp::IamRoot ()
bool zypp::IamNotRoot ()
File related functions.
int zypp::filesystem::assert_file (const Pathname &path, unsigned mode=0644) ZYPP_API
 Create an empty file if it does not yet exist.
int zypp::filesystem::assert_file_mode (const Pathname &path, unsigned mode=0644) ZYPP_API
 Like assert_file but enforce mode even if the file already exists.
int zypp::filesystem::touch (const Pathname &path) ZYPP_API
 Change file's modification and access times.
int zypp::filesystem::unlink (const Pathname &path) ZYPP_API
 Like '::unlink'.
int zypp::filesystem::rename (const Pathname &oldpath, const Pathname &newpath) ZYPP_API
 Like '::rename'.
int zypp::filesystem::exchange (const Pathname &lpath, const Pathname &rpath)
 Exchanges two files or directories.
int zypp::filesystem::copy (const Pathname &file, const Pathname &dest) ZYPP_API
 Like 'cp file dest'.
int zypp::filesystem::symlink (const Pathname &oldpath, const Pathname &newpath) ZYPP_API
 Like '::symlink'.
int zypp::filesystem::hardlink (const Pathname &oldpath, const Pathname &newpath) ZYPP_API
 Like '::link'.
int zypp::filesystem::hardlinkCopy (const Pathname &oldpath, const Pathname &newpath) ZYPP_API
 Create newpath as hardlink or copy of oldpath.
int zypp::filesystem::readlink (const Pathname &symlink_r, Pathname &target_r)
 Like '::readlink'.
Pathname zypp::filesystem::readlink (const Pathname &symlink_r)
Pathname zypp::filesystem::expandlink (const Pathname &path_r) ZYPP_API
 Recursively follows the symlink pointed to by path_r and returns the Pathname to the real file or directory pointed to by the link.
int zypp::filesystem::copy_file2dir (const Pathname &file, const Pathname &dest)
 Like 'cp file dest'.
Digest computaion.
Todo
check cooperation with zypp::Digest
std::string zypp::filesystem::md5sum (const Pathname &file)
 Compute a files md5sum.
std::string zypp::filesystem::sha1sum (const Pathname &file)
 Compute a files sha1sum.
std::string zypp::filesystem::checksum (const Pathname &file, const std::string &algorithm)
 Compute a files checksum.
bool zypp::filesystem::is_checksum (const Pathname &file, const CheckSum &checksum)
 check files checksum
Changing permissions.
int zypp::filesystem::chmod (const Pathname &path, mode_t mode)
 Like '::chmod'.
int zypp::filesystem::chmodApplyUmask (const Pathname &path, mode_t mode)
 Similar to '::chmod', but mode is modified by the process's umask in the usual way.
int zypp::filesystem::addmod (const Pathname &path, mode_t mode)
 Add the mode bits to the file given by path.
int zypp::filesystem::delmod (const Pathname &path, mode_t mode)
 Remove the mode bits from the file given by path.

Misc.

enum  zypp::filesystem::ZIP_TYPE { zypp::filesystem::ZT_NONE , zypp::filesystem::ZT_GZ , zypp::filesystem::ZT_BZ2 , zypp::filesystem::ZT_ZCHNK }
 Test whether a file is compressed (gzip/bzip2). More...
ZIP_TYPE zypp::filesystem::zipType (const Pathname &file)
int zypp::filesystem::erase (const Pathname &path)
 Erase whatever happens to be located at path (file or directory).
ByteCount zypp::filesystem::df (const Pathname &path)
 Report free disk space on a mounted file system.
mode_t zypp::filesystem::getUmask ()
 Get the current umask (file mode creation mask).
mode_t zypp::filesystem::applyUmaskTo (mode_t mode_r)
 Modify mode_r according to the current umask ( mode_r & ~getUmask() ).

Directory related functions.

using zypp::filesystem::DirContent = std::list<DirEntry>
 Returned by readdir.
bool zypp::filesystem::userMayWriteOrCreateDir (const Pathname &path_r)
 Returns whether path_r denotes an existing directory with write permission for the current user or an existing parent directory has write permission for the current user so the directory can be created by him.
int zypp::filesystem::mkdir (const Pathname &path, unsigned mode=0755) ZYPP_API
 Like '::mkdir'.
int zypp::filesystem::assert_dir (const Pathname &path, unsigned mode=0755) ZYPP_API
 Like 'mkdir -p'.
int zypp::filesystem::rmdir (const Pathname &path) ZYPP_API
 Like '::rmdir'.
int zypp::filesystem::recursive_rmdir (const Pathname &path) ZYPP_API
 Like 'rm -r DIR'.
int zypp::filesystem::clean_dir (const Pathname &path) ZYPP_API
 Like 'rm -r DIR/ *'.
int zypp::filesystem::copy_dir (const Pathname &srcpath, const Pathname &destpath) ZYPP_API
 Like 'cp -a srcpath destpath'.
int zypp::filesystem::copy_dir_content (const Pathname &srcpath, const Pathname &destpath) ZYPP_API
 Like 'cp -a srcpath/.
int zypp::filesystem::dirForEach (const Pathname &dir_r, const function< bool(const Pathname &, const char *const)> &fnc_r) ZYPP_API
 Invoke callback function fnc_r for each entry in directory dir_r.
int zypp::filesystem::readdir (std::list< std::string > &retlist, const Pathname &path, bool dots=true) ZYPP_API
 Return content of directory via retlist.
int zypp::filesystem::readdir (std::list< Pathname > &retlist, const Pathname &path, bool dots=true) ZYPP_API
 Return content of directory via retlist.
std::ostream & zypp::filesystem::operator<< (std::ostream &str, const DirEntry &obj)
std::ostream & zypp::filesystem::operator<< (std::ostream &str, const DirContent &obj)
int zypp::filesystem::readdir (DirContent &retlist, const Pathname &path, bool dots=true, PathInfo::Mode statmode=PathInfo::STAT) ZYPP_API
 Return content of directory via retlist.
int zypp::filesystem::dirForEachExt (const Pathname &dir_r, const function< bool(const Pathname &, const DirEntry &)> &fnc_r) ZYPP_API
 Simiar to.
int zypp::filesystem::is_empty_dir (const Pathname &path) ZYPP_API
 Check if the specified directory is empty.