NAME
OTC_Pathname -
Class for accessing information about a pathname.
SYNOPSIS
#include <OTC/files/pathname.hh>
class OTC_Pathname : public OTC_SObject
{
public:
static os_typespec* get_os_typespec();
~OTC_Pathname();
OTC_Pathname();
OTC_Pathname(char const* thePath);
OTC_Pathname(OTC_String const& thePath);
OTC_Pathname(OTC_Pathname const& thePath);
inline OTC_Pathname& operator=(OTC_Pathname const& thePath);
inline OTC_Pathname& operator=(OTC_String const& thePath);
inline OTC_String const& path() const;
inline operator char const*() const;
OTC_Boolean isAccessable() const;
OTC_Boolean isWritable() const;
OTC_Boolean isReadable() const;
OTC_Boolean isExecutable() const;
inline OTC_Pathname& operator+=(char theChar);
inline OTC_Pathname& operator+=(char const* theString);
inline OTC_Pathname& operator+=(OTC_String const& theString);
inline OTC_Pathname& operator+=(OTC_Pathname const& thePath);
inline OTC_TString operator+(char theChar);
inline OTC_TString operator+(char const* theString);
inline OTC_TString operator+(OTC_String const& theString);
inline OTC_TString operator+(OTC_Pathname const& thePath);
protected:
OTC_RString rawString() const;
};
CLASS TYPE
Concrete
DESCRIPTION
The OTC_Pathname class is intended to hold the pathname
of a file and allow interogation of whether or not the file
exists and what access the user is allowed.
INITIALISATION
OTC_Pathname();
Creates an empty pathname.
OTC_Pathname(char const* thePath);
Creates a pathname using thePath.
OTC_Pathname(OTC_String const& thePath);
Creates a pathname using thePath.
OTC_Pathname(OTC_Pathname const& thePath);
Creates a pathname using thePath.
inline OTC_Pathname& operator=(OTC_Pathname const& thePath);
Initialises this path to thePath.
inline OTC_Pathname& operator=(OTC_String const& thePath);
Initialises this path to thePath.
QUERY
inline OTC_String const& path() const;
inline operator char const*() const;
OTC_Boolean isAccessable() const;
Returns OTCLIB_TRUE if the file exists
and all directories in the path are
searchable. In the case of OTCLIB_FALSE
being returned, if errno is ENOENT
then the file truly doesn't exist. If
errno has some other value then a
problem was encountered in accessing the
file.
OTC_Boolean isWritable() const;
Returns OTCLIB_TRUE if the file is
writable.
OTC_Boolean isReadable() const;
Returns OTCLIB_TRUE if the file is
readable.
OTC_Boolean isExecutable() const;
Returns OTCLIB_TRUE if the file is
executable.
EXTENSION
inline OTC_Pathname& operator+=(char theChar);
Extend the pathname with theChar.
inline OTC_Pathname& operator+=(char const* theString);
Extend the pathname with theString.
inline OTC_Pathname& operator+=(OTC_String const& theString);
Extend the pathname with theString.
inline OTC_Pathname& operator+=(OTC_Pathname const& thePath);
Extend the pathname with thePath.
ADDITION
inline OTC_TString operator+(char theChar);
Returns the path with theChar appended.
This object is not modified.
inline OTC_TString operator+(char const* theString);
Returns the path with theString appended.
This object is not modified.
inline OTC_TString operator+(OTC_String const& theString);
Returns the path with theString appended.
This object is not modified.
inline OTC_TString operator+(OTC_Pathname const& thePath);
Returns the path with thePath appended.
This object is not modified.
STREAMS
Both operator<<() and operator>>() are overloaded for operation
with streams. The extraction operator behaves the same as that for the
OTC_String class, namely it will extract up to the first whitespace
character in the input. Also, if ios::skipws is defined it will first
skip leading whitespace.
NOTES
Trailing and leading whitespace is not removed from the pathname
by this class. If you need to remove the whitespace then it must
be done before initialisation of the class. One way of doing
this would be to use OTC_String::trim().
The functions isAccessable(), isReadable(), isWritable() and
isExecutable() make use of access(1). Thus the results
generated are based on the real user ID and supplementary
group ID (including the real group ID) of the executing
program.
An OTC_BaseActions and OTC_HashActions class are defined for
OTC_Pathname.
SEE ALSO
access(2), dirname(1), basename(1)
LIBRARY
OTC
AUTHOR(S)
Graham Dumpleton
COPYRIGHT
Copyright 1992 OTC LIMITED
Copyright 1994 DUMPLETON SOFTWARE CONSULTING PTY LIMITED