paludis::FSEntry Class Reference
[Filesystem]

#include <fs_entry.hh>

Inheritance diagram for paludis::FSEntry:

paludis::relational_operators::HasRelationalOperators paludis::arithmetic_operators::HasArithmeticOperators paludis::PrivateImplementationPattern< C_ > paludis::equality_operators::HasEqualityOperators

List of all members.

Basic operations

 FSEntry (const std::string &path)
 FSEntry (const FSEntry &other)
 ~FSEntry ()
const FSEntryoperator= (const FSEntry &other)

Modification operations

const FSEntryoperator/= (const FSEntry &rhs)
const FSEntryoperator/= (const std::string &rhs)
FSEntry operator/ (const std::string &rhs) const PALUDIS_ATTRIBUTE((warn_unused_result))

Comparison operators

bool operator< (const FSEntry &) const
bool operator== (const FSEntry &) const

Filesystem queries

bool exists () const PALUDIS_ATTRIBUTE((warn_unused_result))
bool is_directory () const PALUDIS_ATTRIBUTE((warn_unused_result))
bool is_directory_or_symlink_to_directory () const PALUDIS_ATTRIBUTE((warn_unused_result))
bool is_regular_file () const PALUDIS_ATTRIBUTE((warn_unused_result))
bool is_regular_file_or_symlink_to_regular_file () const PALUDIS_ATTRIBUTE((warn_unused_result))
bool is_symbolic_link () const PALUDIS_ATTRIBUTE((warn_unused_result))
bool is_device () const PALUDIS_ATTRIBUTE((warn_unused_result))
bool is_fifo () const PALUDIS_ATTRIBUTE((warn_unused_result))
bool has_permission (const FSUserGroup &user_group, const FSPermission &fs_perm) const PALUDIS_ATTRIBUTE((warn_unused_result))
mode_t permissions () const PALUDIS_ATTRIBUTE((warn_unused_result))
FSEntry realpath () const PALUDIS_ATTRIBUTE((warn_unused_result))
FSEntry realpath_if_exists () const PALUDIS_ATTRIBUTE((warn_unused_result))
std::string readlink () const PALUDIS_ATTRIBUTE((warn_unused_result))
time_t ctime () const PALUDIS_ATTRIBUTE((warn_unused_result))
time_t mtime () const PALUDIS_ATTRIBUTE((warn_unused_result))
off_t file_size () const PALUDIS_ATTRIBUTE((warn_unused_result))
uid_t owner () const PALUDIS_ATTRIBUTE((warn_unused_result))
gid_t group () const PALUDIS_ATTRIBUTE((warn_unused_result))
std::pair< dev_t, ino_t > lowlevel_id () const PALUDIS_ATTRIBUTE((warn_unused_result))
static FSEntry cwd () PALUDIS_ATTRIBUTE((warn_unused_result))

Filesystem operations

bool mkdir (const mode_t mode=0755)
bool symlink (const std::string &target)
bool unlink ()
bool rmdir ()
bool utime (const struct::utimbuf *buf=0)
void chown (const uid_t owner, const gid_t group=static_cast< gid_t >(-1))
void lchown (const uid_t owner, const gid_t group=static_cast< gid_t >(-1))
void chmod (const mode_t mode)
void rename (const FSEntry &new_name)

Public Member Functions

std::string basename () const PALUDIS_ATTRIBUTE((warn_unused_result))
FSEntry strip_leading (const FSEntry &prefix) const
FSEntry dirname () const PALUDIS_ATTRIBUTE((warn_unused_result))

Friends

class DirIterator
std::ostream & operator<< (std::ostream &s, const FSEntry &f)


Detailed Description

Represents an entry (which may or may not exist) in the filesystem.

Member Function Documentation

const FSEntry& paludis::FSEntry::operator/= ( const FSEntry rhs  ) 

Append another FSEntry.

const FSEntry& paludis::FSEntry::operator/= ( const std::string &  rhs  )  [inline]

Append another path.

FSEntry paludis::FSEntry::operator/ ( const std::string &  rhs  )  const

Join with another path.

std::string paludis::FSEntry::basename (  )  const

Return the last part of our path (eg '/foo/bar' => 'bar').

FSEntry paludis::FSEntry::strip_leading ( const FSEntry prefix  )  const

Return the path without a given prefix (eg '/foo/bar/baz'->strip_leading('/foo') => '/bar/baz').

FSEntry paludis::FSEntry::dirname (  )  const

Return the first part of our path (eg '/foo/bar' => '/foo').

bool paludis::FSEntry::exists (  )  const

Does a filesystem entry exist at our location?

bool paludis::FSEntry::is_directory (  )  const

Does a filesystem entry exist at our location, and if it does, is it a directory?

bool paludis::FSEntry::is_directory_or_symlink_to_directory (  )  const

Does a filesystem entry exist at our location, and if it does, is it a directory?

bool paludis::FSEntry::is_regular_file (  )  const

Does a filesystem entry exist at our location, and if it does, is it a regular file?

bool paludis::FSEntry::is_regular_file_or_symlink_to_regular_file (  )  const

Does a filesystem entry exist at our location, and if it does, is it a regular file?

bool paludis::FSEntry::is_symbolic_link (  )  const

Does a filesystem entry exist at our location, and if it does, is it a symbolic link?

bool paludis::FSEntry::is_device (  )  const

Whether we exist and are a device file.

bool paludis::FSEntry::is_fifo (  )  const

Whether we exist and are a fifo.

bool paludis::FSEntry::has_permission ( const FSUserGroup user_group,
const FSPermission fs_perm 
) const

Check if filesystem entry has `perm` for `user_group`.

Exceptions:
FSError if there was a problem accessing the filesystem entry

mode_t paludis::FSEntry::permissions (  )  const

Return the permissions for our item.

Exceptions:
FSError if there was a problem accessing the filesystem entry

FSEntry paludis::FSEntry::realpath (  )  const

Return the canonicalised version of our path.

FSEntry paludis::FSEntry::realpath_if_exists (  )  const

Return the canonicalised version of our path, if it exists, or ourself if it doesn't.

std::string paludis::FSEntry::readlink (  )  const

Return our destination, if we are a symlink.

Exceptions:
FSError if we are not a symlink, or if the system call fails.

time_t paludis::FSEntry::ctime (  )  const

Return the time the inode for the filesystem entry was last modified

Exceptions:
FSError if there was a problem accessing the filesystem entry

time_t paludis::FSEntry::mtime (  )  const

Return the time the filesystem entry was last modified

Exceptions:
FSError if there was a problem accessing the filesystem entry

off_t paludis::FSEntry::file_size (  )  const

Return the size of our file, in bytes.

Exceptions:
FSError if we don't have a size.

uid_t paludis::FSEntry::owner (  )  const

Fetch our owner.

Exceptions:
FSError If we don't exist or the stat call fails.

gid_t paludis::FSEntry::group (  )  const

Fetch our group.

Exceptions:
FSError If we don't exist or the stat call fails.

static FSEntry paludis::FSEntry::cwd (  )  [static]

Return the current working directory

std::pair<dev_t, ino_t> paludis::FSEntry::lowlevel_id (  )  const

Return an unique low-level id for this entry

bool paludis::FSEntry::mkdir ( const mode_t  mode = 0755  ) 

Try to make a directory.

Returns:
True, if we succeeded, and false if the directory already exists and is a directory.
Exceptions:
FSError If an error other than the directory already existing occurs.

bool paludis::FSEntry::symlink ( const std::string &  target  ) 

Try to make a symlink.

Returns:
True, if we succeeded, and false if the target already exists and is a symlink to the same target.
Exceptions:
FSError If an error other than the symlink already existing occurs, or if the symlink exists and points elsewhere.

bool paludis::FSEntry::unlink (  ) 

Try to unlink.

Returns:
True, if we succeeded, and false if we don't exist already.
Exceptions:
FSError If an error other than us already not existing occurs.

bool paludis::FSEntry::rmdir (  ) 

Try to rmdir.

Returns:
True, if we succeeded, and false if we don't exist already.
Exceptions:
FSError If an error other than us already not existing occurs.

bool paludis::FSEntry::utime ( const struct::utimbuf *  buf = 0  ) 

Try to set atime and mtime

Returns:
True, if we succeeded, and false if we don't exist already.
Exceptions:
FSError If an error other than us already not existing ocurrs.

void paludis::FSEntry::chown ( const uid_t  owner,
const gid_t  group = static_cast< gid_t >(-1) 
)

Change our ownership, following symlinks.

Exceptions:
FSError If the chown failed.

void paludis::FSEntry::lchown ( const uid_t  owner,
const gid_t  group = static_cast< gid_t >(-1) 
)

Change our ownership, not following symlinks.

Exceptions:
FSError If the lchown failed.

void paludis::FSEntry::chmod ( const mode_t  mode  ) 

Change our permissions.

Exceptions:
FSError If the chmod failed.

void paludis::FSEntry::rename ( const FSEntry new_name  ) 

Rename ourself (will not work across mount points).

Exceptions:
FSError If the rename failed.


Friends And Related Function Documentation

std::ostream& operator<< ( std::ostream &  s,
const FSEntry f 
) [friend]

An FSEntry can be written to an ostream.


The documentation for this class was generated from the following file:
Generated on Mon Sep 21 10:36:11 2009 for paludis by  doxygen 1.5.4