zypp::filesystem Namespace Reference

Types and functions for filesystem operations. More...


Classes

class  StatMode
 Wrapper class for mode_t values as derived from stat. More...
class  DevInoCache
 Simple cache remembering device/inode to detect hardlinks. More...
class  PathInfo
 Wrapper class for stat/lstat. More...
struct  DirEntry
 Listentry returned by readdir. More...
class  Pathname
 Pathname. More...
class  TmpPath
 Automaticaly deletes files or directories when no longer needed. More...
class  TmpFile
 Provide a new empty temporary file and delete it when no longer needed. More...
class  TmpDir
 Provide a new empty temporary directory and recursively delete it when no longer needed. More...

Directory related functions.

typedef std::list< DirEntryDirContent
 Returned by readdir.
int mkdir (const Pathname &path, unsigned mode=0755)
 Like 'mkdir'.
int assert_dir (const Pathname &path, unsigned mode=0755)
 Like 'mkdir -p'.
int rmdir (const Pathname &path)
 Like 'rmdir'.
int recursive_rmdir (const Pathname &path)
 Like 'rm -r DIR'.
int clean_dir (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 readdir (std::list< std::string > &retlist, const Pathname &path, bool dots=true)
 Return content of directory via retlist.
int readdir (std::list< Pathname > &retlist, const Pathname &path, bool dots=true)
 Return content of directory via retlist.
int readdir (DirContent &retlist, const Pathname &path, bool dots=true, PathInfo::Mode statmode=PathInfo::STAT)
 Return content of directory via retlist.
int is_empty_dir (const Pathname &path)
 Check if the specified directory is empty.

Misc.

enum  ZIP_TYPE { ZT_NONE, ZT_GZ, ZT_BZ2 }
 Test whether a file is compressed (gzip/bzip2). More...
int erase (const Pathname &path)
 Erase whatever happens to be located at path (file or directory).
ZIP_TYPE zipType (const Pathname &file)

File related functions.

int unlink (const Pathname &path)
 Like 'unlink'.
int rename (const Pathname &oldpath, const Pathname &newpath)
 Like 'rename'.
int copy (const Pathname &file, const Pathname &dest)
 Like 'cp file dest'.
int symlink (const Pathname &oldpath, const Pathname &newpath)
 Like 'symlink'.
int hardlink (const Pathname &oldpath, const Pathname &newpath)
 Like 'link'.
int copy_file2dir (const Pathname &file, const Pathname &dest)
 Like 'cp file dest'.

Digest computaion.

Todo:
check cooperation with zypp::Digest


std::string md5sum (const Pathname &file)
 Compute a files md5sum.
std::string sha1sum (const Pathname &file)
 Compute a files sha1sum.

Changing permissions.

int chmod (const Pathname &path, mode_t mode)
 Like 'chmod'.

Enumerations

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

Functions

std::ostream & operator<< (std::ostream &str, FileType obj)
std::ostream & operator<< (std::ostream &str, const StatMode &obj)
std::ostream & operator<< (std::ostream &str, const PathInfo &obj)
int _Log_Result (const int res, const char *rclass="errno")
std::ostream & operator<< (std::ostream &str, const TmpPath &obj)
 Stream output as pathname.


Detailed Description

Types and functions for filesystem operations.

Todo:
move zypp::filesystem stuff into separate header

Add tmpfile and tmpdir handling.

think about using Exceptions in zypp::filesystem

provide a readdir iterator; at least provide an interface using an insert_iterator to be independent from std::container.


Typedef Documentation

typedef std::list<DirEntry> zypp::filesystem::DirContent
 

Returned by readdir.

Definition at line 491 of file PathInfo.h.


Enumeration Type Documentation

enum zypp::filesystem::FileType
 

File type information.

Todo:
Think about an Enumeration Class
Enumerator:
FT_NOT_AVAIL 
FT_NOT_EXIST 
FT_FILE 
FT_DIR 
FT_CHARDEV 
FT_BLOCKDEV 
FT_FIFO 
FT_LINK 
FT_SOCKET 

Definition at line 51 of file PathInfo.h.

enum zypp::filesystem::ZIP_TYPE
 

Test whether a file is compressed (gzip/bzip2).

Returns:
ZT_GZ, ZT_BZ2 if file is compressed, otherwise ZT_NONE.
Enumerator:
ZT_NONE 
ZT_GZ 
ZT_BZ2 

Definition at line 605 of file PathInfo.h.


Function Documentation

std::ostream& zypp::filesystem::operator<< std::ostream &  str,
FileType  obj
 

Definition at line 45 of file PathInfo.cc.

References EMUMOUT, FT_BLOCKDEV, FT_CHARDEV, FT_DIR, FT_FIFO, FT_FILE, FT_LINK, FT_NOT_AVAIL, FT_NOT_EXIST, and FT_SOCKET.

std::ostream& zypp::filesystem::operator<< std::ostream &  str,
const StatMode &  obj
 

Definition at line 93 of file PathInfo.cc.

References zypp::filesystem::StatMode::isBlk(), zypp::filesystem::StatMode::isChr(), zypp::filesystem::StatMode::isDir(), zypp::filesystem::StatMode::isFifo(), zypp::filesystem::StatMode::isFile(), zypp::filesystem::StatMode::isLink(), zypp::filesystem::StatMode::isSock(), and zypp::filesystem::StatMode::perm().

std::ostream& zypp::filesystem::operator<< std::ostream &  str,
const PathInfo &  obj
 

Definition at line 259 of file PathInfo.cc.

References zypp::filesystem::PathInfo::asString(), and zypp::filesystem::PathInfo::isExist().

int zypp::filesystem::_Log_Result const int  res,
const char *  rclass = "errno"
[inline]
 

Definition at line 291 of file PathInfo.cc.

References DBG.

Referenced by chmod(), clean_dir(), copy(), copy_dir(), copy_dir_content(), copy_file2dir(), hardlink(), is_empty_dir(), mkdir(), readdir(), recursive_rmdir(), rename(), rmdir(), symlink(), and unlink().

int zypp::filesystem::mkdir const Pathname &  path,
unsigned  mode = 0755
 

Like 'mkdir'.

Attempt to create a new directory named path. mode specifies the permissions to use. It is modified by the process's umask in the usual way.

Returns:
0 on success, errno on failure

Definition at line 304 of file PathInfo.cc.

References _Log_Result(), zypp::filesystem::Pathname::asString(), DBG, and zypp::str::octstring().

Referenced by assert_dir(), and zypp::source::susetags::SuseTagsImpl::initCacheDir().

int zypp::filesystem::assert_dir const Pathname &  path,
unsigned  mode = 0755
 

Like 'mkdir -p'.

No error if directory exists. Make parent directories as needed. mode specifies the permissions to use, if directories have to be created. It is modified by the process's umask in the usual way.

Returns:
0 on success, errno on failure

Definition at line 318 of file PathInfo.cc.

References zypp::filesystem::Pathname::asString(), zypp::filesystem::Pathname::empty(), mkdir(), and zypp::filesystem::Pathname::relative().

Referenced by zypp::source::SourceImpl::copyLocalMetadata(), zypp::source::yum::YUMSourceImpl::downloadMetadata(), zypp::source::susetags::SuseTagsImpl::downloadMetadata(), zypp::storage::XMLFilesBackend::initBackend(), zypp::source::susetags::SuseTagsImpl::initCacheDir(), zypp::SourceManager::store(), and zypp::SourceCache::storeSource().

int zypp::filesystem::rmdir const Pathname &  path  ) 
 

Like 'rmdir'.

Delete a directory, which must be empty.

Returns:
0 on success, errno on failure

Definition at line 358 of file PathInfo.cc.

References _Log_Result(), and DBG.

Referenced by zypp::media::MediaCurl::MediaCurl().

int zypp::filesystem::recursive_rmdir const Pathname &  path  ) 
 

Like 'rm -r DIR'.

Delete a directory, recursively removing its contents.

Returns:
0 on success, ENOTDIR if path is not a directory, otherwise the commands return value.

Definition at line 372 of file PathInfo.cc.

References _Log_Result(), DBG, and zypp::filesystem::PathInfo::isExist().

Referenced by erase(), zypp::media::MediaHandler::removeAttachPoint(), zypp::SourceCache::removeSource(), zypp::SourceManager::store(), and zypp::filesystem::TmpPath::Impl::~Impl().

int zypp::filesystem::clean_dir const Pathname &  path  ) 
 

Like 'rm -r DIR/ *'.

Delete directory contents, but keep the directory itself.

Returns:
0 on success, ENOTDIR if path is not a directory, otherwise the commands return value.

Definition at line 404 of file PathInfo.cc.

References _Log_Result(), DBG, and zypp::filesystem::PathInfo::isExist().

Referenced by zypp::source::SourceImpl::copyLocalMetadata(), zypp::source::susetags::SuseTagsImpl::initCacheDir(), zypp::source::SourceImpl::refresh(), and zypp::filesystem::TmpPath::Impl::~Impl().

int zypp::filesystem::copy_dir const Pathname &  srcpath,
const Pathname &  destpath
 

Like 'cp -a srcpath destpath'.

Copy directory tree. srcpath/destpath must be directories. 'basename srcpath' must not exist in destpath.

Returns:
0 on success, ENOTDIR if srcpath/destpath is not a directory, EEXIST if 'basename srcpath' exists in destpath, otherwise the commands return value.

Definition at line 431 of file PathInfo.cc.

References _Log_Result(), DBG, and zypp::filesystem::PathInfo::isDir().

Referenced by zypp::source::susetags::SuseTagsImpl::downloadMetadata().

int zypp::filesystem::copy_dir_content const Pathname &  srcpath,
const Pathname &  destpath
 

Like 'cp -a srcpath/.

destpath'. Copy the content of srcpath recursively into destpath. Both srcpath and destpath has to exists.

Returns:
0 on success, ENOTDIR if srcpath/destpath is not a directory, EEXIST if srcpath and destpath are equal, otherwise the commands return value.

Definition at line 472 of file PathInfo.cc.

References _Log_Result(), DBG, and zypp::filesystem::PathInfo::isDir().

Referenced by zypp::source::SourceImpl::copyLocalMetadata().

int zypp::filesystem::readdir std::list< std::string > &  retlist,
const Pathname &  path,
bool  dots = true
 

Return content of directory via retlist.

If dots is false entries starting with '.' are not reported. "." and ".." are never reported.

Returns just the directory entries as string.

Returns:
0 on success, errno on failure.
Todo:
provide some readdirIterator.

Definition at line 513 of file PathInfo.cc.

References _Log_Result(), and DBG.

Referenced by zypp::target::modalias::foreach_file(), is_empty_dir(), zypp::source::susetags::SuseTagsImpl::providePackages(), zypp::source::susetags::SuseTagsImpl::publicKeys(), readdir(), zypp::SourceCache::removeSource(), and zypp::SourceCache::restoreSources().

int zypp::filesystem::readdir std::list< Pathname > &  retlist,
const Pathname &  path,
bool  dots = true
 

Return content of directory via retlist.

If dots is false entries starting with '.' are not reported. "." and ".." are never reported.

Returns the directory entries prefixed with path.

Returns:
0 on success, errno on failure.
Todo:
provide some readdirIterator.

Definition at line 550 of file PathInfo.cc.

References readdir().

int zypp::filesystem::readdir DirContent retlist,
const Pathname &  path,
bool  dots = true,
PathInfo::Mode  statmode = PathInfo::STAT
 

Return content of directory via retlist.

If dots is false entries starting with '.' are not reported. "." and ".." are never reported.

The type of individual directory entries is determined accoding to statmode (i.e. via stat or lstat).

Returns:
0 on success, errno on failure.

Definition at line 572 of file PathInfo.cc.

References readdir().

int zypp::filesystem::is_empty_dir const Pathname &  path  ) 
 

Check if the specified directory is empty.

Parameters:
path The path of the directory to check.
Returns:
0 if directory is empty, -1 if not, errno > 0 on failure.

Definition at line 595 of file PathInfo.cc.

References _Log_Result(), zypp::filesystem::Pathname::asString(), name, and readdir().

int zypp::filesystem::unlink const Pathname &  path  ) 
 

Like 'unlink'.

Delete a file (symbolic link, socket, fifo or device).

Returns:
0 on success, errno on failure

Definition at line 622 of file PathInfo.cc.

References _Log_Result(), and DBG.

Referenced by zypp::storage::XMLFilesBackend::deleteObject(), erase(), zypp::media::MediaHandler::releasePath(), zypp::ZYppGlobalLock::zyppLocked(), and zypp::ZYppGlobalLock::~ZYppGlobalLock().

int zypp::filesystem::rename const Pathname &  oldpath,
const Pathname &  newpath
 

Like 'rename'.

Renames a file, moving it between directories if required.

Returns:
0 on success, errno on failure

Definition at line 636 of file PathInfo.cc.

References _Log_Result(), zypp::filesystem::Pathname::asString(), and DBG.

int zypp::filesystem::copy const Pathname &  file,
const Pathname &  dest
 

Like 'cp file dest'.

Copy file to destination file.

Returns:
0 on success, EINVAL if file is not a file, EISDIR if destiantion is a directory, otherwise the commands return value.

Definition at line 650 of file PathInfo.cc.

References _Log_Result(), DBG, and zypp::filesystem::PathInfo::isFile().

Referenced by zypp::url::UrlBase::cleanupPathName(), zypp::source::yum::YUMSourceImpl::downloadMetadata(), zypp::source::susetags::SuseTagsImpl::downloadMetadata(), zypp::media::MediaHandler::getFileCopy(), zypp::operator<<(), and zypp::target::rpm::RpmDb::run_rpm().

int zypp::filesystem::symlink const Pathname &  oldpath,
const Pathname &  newpath
 

Like 'symlink'.

Creates a symbolic link named newpath which contains the string oldpath. If newpath exists it will not be overwritten.

Returns:
0 on success, errno on failure.

Definition at line 684 of file PathInfo.cc.

References _Log_Result(), zypp::filesystem::Pathname::asString(), and DBG.

int zypp::filesystem::hardlink const Pathname &  oldpath,
const Pathname &  newpath
 

Like 'link'.

Creates a hard link named newpath to an existing file oldpath. If newpath exists it will not be overwritten.

Returns:
0 on success, errno on failure.

Definition at line 698 of file PathInfo.cc.

References _Log_Result(), zypp::filesystem::Pathname::asString(), and DBG.

int zypp::filesystem::copy_file2dir const Pathname &  file,
const Pathname &  dest
 

Like 'cp file dest'.

Copy file to dest dir.

Returns:
0 on success, EINVAL if file is not a file, ENOTDIR if dest is no directory, otherwise the commands return value.

Definition at line 712 of file PathInfo.cc.

References _Log_Result(), DBG, and zypp::filesystem::PathInfo::isFile().

std::string zypp::filesystem::md5sum const Pathname &  file  ) 
 

Compute a files md5sum.

Returns:
the files md5sum on success, otherwise an empty string..

Definition at line 746 of file PathInfo.cc.

References zypp::filesystem::Pathname::asString(), and zypp::Digest::digest().

std::string zypp::filesystem::sha1sum const Pathname &  file  ) 
 

Compute a files sha1sum.

Returns:
the files sha1sum on success, otherwise an empty string..

Definition at line 763 of file PathInfo.cc.

References zypp::filesystem::Pathname::asString(), and zypp::Digest::digest().

Referenced by zypp::source::yum::YUMSourceImpl::downloadNeeded(), and zypp::source::susetags::SuseTagsImpl::downloadNeeded().

int zypp::filesystem::erase const Pathname &  path  ) 
 

Erase whatever happens to be located at path (file or directory).

Returns:
0 on success.
Todo:
check cooperation with zypp::TmpFile and zypp::TmpDir

Definition at line 780 of file PathInfo.cc.

References zypp::filesystem::PathInfo::isDir(), zypp::filesystem::PathInfo::isExist(), recursive_rmdir(), and unlink().

int zypp::filesystem::chmod const Pathname &  path,
mode_t  mode
 

Like 'chmod'.

The mode of the file given by path is changed.

Returns:
0 on success, errno on failure

Definition at line 799 of file PathInfo.cc.

References _Log_Result(), zypp::filesystem::Pathname::asString(), DBG, and zypp::str::octstring().

Referenced by zypp::base::logger::FileWriter::FileWriter().

ZIP_TYPE zypp::filesystem::zipType const Pathname &  file  ) 
 

Definition at line 813 of file PathInfo.cc.

References zypp::filesystem::Pathname::asString(), zypp::base::sysconfig::read(), ZT_BZ2, ZT_GZ, and ZT_NONE.

std::ostream& zypp::filesystem::operator<< std::ostream &  str,
const TmpPath &  obj
[inline]
 

Stream output as pathname.

Definition at line 95 of file TmpPath.h.


Generated on Thu Jul 6 00:07:32 2006 for zypp by  doxygen 1.4.6