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();
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);

QUERY

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;

EXTENSION

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);

ADDITION

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);

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