Pyro higlevel API
Classes | Public Member Functions | List of all members
os::Directory Class Reference

Filesystem directory class. More...

Inheritance diagram for os::Directory:
os::FSNode os::DirIterator

Classes

class  Private
 

Public Member Functions

 Directory ()
 Default contructor. More...
 
 Directory (const String &cPath, int nOpenMode=O_RDONLY)
 Construct a directory from a path. More...
 
 Directory (const Directory &cDir, const String &cName, int nOpenMode=O_RDONLY)
 Construct a directory from a path. More...
 
 Directory (const FileReference &cRef, int nOpenMode=O_RDONLY)
 Construct a directory from a path. More...
 
 Directory (const FSNode &cNode)
 Construct a directory from a path. More...
 
 Directory (int nFD)
 Construct a directory object from a open filedescriptor. More...
 
 Directory (const Directory &cDir)
 Copy constructor. More...
 
virtual ~Directory ()
 
virtual status_t FDChanged (int nNewFD, const struct stat &sStat)
 
virtual status_t GetNextEntry (String *pcName)
 
virtual status_t GetNextEntry (FileReference *pcRef)
 
virtual status_t Rewind ()
 
virtual status_t Delete ()
 Delete the directory. More...
 
status_t CreateFile (const String &cName, os::File *pcFile, int nAccessMode=S_IRWXU)
 
status_t CreateDirectory (const String &cName, os::Directory *pcDir, int nAccessMode=S_IRWXU)
 
status_t CreateSymlink (const String &cName, const String &cDestination, os::SymLink *pcLink)
 
WindowCreateDirectoryDialog (const Messenger &cMsgTarget, Message *pcCreateMsg, String cDefaultName)
 Create a dialog which can be used to create a new directory. More...
 
status_t GetPath (String *pcPath) const
 Get the absolute path of the directory. More...
 
status_t SetPath (const String &cPath, int nOpenMode=O_RDONLY)
 Open a directory using a path. More...
 
status_t SetPath (const Path &cPath, int nOpenMode=O_RDONLY)
 Open a directory using a path. More...
 
- Public Member Functions inherited from os::FSNode
 FSNode ()
 Default contructor. More...
 
 FSNode (const String &cPath, int nOpenMode=O_RDONLY)
 Construct a FSNode from a file path. More...
 
 FSNode (const Directory &cDir, const String &cName, int nOpenMode=O_RDONLY)
 Construct a FSNode from directory and a name inside that directory. More...
 
 FSNode (const FileReference &cRef, int nOpenMode=O_RDONLY)
 Construct a FSNode from a file reference. More...
 
 FSNode (int nFD)
 Construct a FSNode from a file descriptor. More...
 
 FSNode (const FSNode &cNode)
 Copy contructor. More...
 
virtual ~FSNode ()
 Destructor. More...
 
virtual status_t SetTo (const String &cPath, int nOpenMode=O_RDONLY)
 Open a node using a path. More...
 
virtual status_t SetTo (const Directory &cDir, const String &cPath, int nOpenMode=O_RDONLY)
 Open a node using a dir/path pair. More...
 
virtual status_t SetTo (const FileReference &cRef, int nOpenMode=O_RDONLY)
 Open the node referred to by the given os::FileReference. More...
 
virtual status_t SetTo (int nFD)
 Make the FSNode represent an already open file. More...
 
virtual status_t SetTo (const FSNode &cNode)
 Copy another FSNode. More...
 
virtual void Unset ()
 Reset the FSNode. More...
 
virtual bool IsValid () const
 Check if the node has been properly initialized. More...
 
virtual status_t GetStat (struct stat *psStat, bool bUpdateCache=true) const
 
virtual ino_t GetInode () const
 
virtual dev_t GetDev () const
 
virtual int GetMode (bool bUpdateCache=false) const
 
virtual off_t GetSize (bool bUpdateCache=true) const
 
virtual time_t GetCTime (bool bUpdateCache=true) const
 
virtual time_t GetMTime (bool bUpdateCache=true) const
 
virtual time_t GetATime (bool bUpdateCache=true) const
 
bool IsDir () const
 
bool IsLink () const
 
bool IsFile () const
 
bool IsCharDev () const
 
bool IsBlockDev () const
 
bool IsFIFO () const
 
virtual status_t GetNextAttrName (String *pcName)
 Read the node's attribute directory. More...
 
virtual status_t RewindAttrdir ()
 Reset the attribute directory iterator. More...
 
virtual ssize_t WriteAttr (const String &cAttrName, int nFlags, int nType, const void *pBuffer, off_t nPos, size_t nLen)
 Add/update an attribute. More...
 
virtual ssize_t ReadAttr (const String &cAttrName, int nType, void *pBuffer, off_t nPos, size_t nLen)
 Read the data held by an attribute. More...
 
virtual status_t RemoveAttr (const String &cName)
 Remove an attribute from an FS node. More...
 
virtual status_t StatAttr (const String &cName, struct::attr_info *psBuffer)
 Get extended info about an attribute. More...
 
virtual int GetFileDescriptor () const
 
- Public Member Functions inherited from os::DirIterator
virtual ~DirIterator ()
 

Detailed Description

Description:
This class let you iterate over the content of a directory.

Unlik other FSNode derivated classes it is possible to ask a os::Directory to retrieve it's own path.

See Also
FSNode
Author
Kurt Skauen (kurt@.nosp@m.athe.nosp@m.os.cx)

Constructor & Destructor Documentation

Directory::Directory ( )
Description:
Initiate the instance to a know but invalid state. The instance must be successfully initialized with one of the SetTo() members before it can be used.
Author
Kurt Skauen (kurt@.nosp@m.athe.nosp@m.os.cx)
Directory::Directory ( const String cPath,
int  nOpenMode = O_RDONLY 
)
Directory::Directory ( const Directory cDir,
const String cPath,
int  nOpenMode = O_RDONLY 
)
Description:
See: ( const Directory& cDir, const String& cPath, int nOpenMode )
Author
Kurt Skauen (kurt@.nosp@m.athe.nosp@m.os.cx)

References os::FSNode::GetFileDescriptor(), os::FSNode::GetMode(), and os::Directory::Private::m_hDirIterator.

Directory::Directory ( const FileReference cRef,
int  nOpenMode = O_RDONLY 
)
Directory::Directory ( const FSNode cNode)
Directory::Directory ( int  nFD)
Description:
Construct a directory object from a open filedescriptor. The file descriptor must be referencing a directory or an errno_exception with the ENOTDIR error code will be thrown.
Parameters
nFDAn open filedescriptor referencing a directory.
Since
0.3.7
Author
Kurt Skauen (kurt@.nosp@m.athe.nosp@m.os.cx)

References os::FSNode::GetFileDescriptor(), os::FSNode::GetMode(), and os::Directory::Private::m_hDirIterator.

Directory::Directory ( const Directory cDir)
Description:
Make a independent copy of another directory.

The new directory will consume a new file descriptor so the copy might fail (throwing an errno_exception exception) if the process run out of file descriptors.

Parameters
cDirThe directory to copy
Author
Kurt Skauen (kurt@.nosp@m.athe.nosp@m.os.cx)

References os::FSNode::GetFileDescriptor(), and os::Directory::Private::m_hDirIterator.

Directory::~Directory ( )
virtual

Member Function Documentation

status_t Directory::CreateDirectory ( const String cName,
os::Directory pcDir,
int  nAccessMode = S_IRWXU 
)
Window * Directory::CreateDirectoryDialog ( const Messenger cMsgTarget,
Message pcCreateMsg,
String  cDefaultName 
)
Description:
The created window contains an input field where the user can type the name of the new directory. If a new directory has been created, a message will be sent to the supplied message target.
Note:
Don’t forget to place the window at the right position and show it.
Parameters
cMsgTarget- The target that will receive the message.
pcCreateMsg- The message that will be sent.
cDefaultName- The default name of the new directory.
Author
Arno Klenke (arno_.nosp@m.klen.nosp@m.ke@ya.nosp@m.hoo..nosp@m.de)

References GetPath().

Referenced by os::IconDirectoryView::HandleMessage().

status_t Directory::CreateFile ( const String cName,
os::File pcFile,
int  nAccessMode = S_IRWXU 
)
status_t Directory::CreateSymlink ( const String cName,
const String cDestination,
os::SymLink pcLink 
)
status_t Directory::Delete ( )
virtual
Warning: The Directory will be invalid if the call to Delete suceeds.
You should destroy the Directory instance after calling Delete() to remove any references and ensure the directory is removed from the filesystem.
Author
Kristian Van Der Vliet (vande.nosp@m.rs@l.nosp@m.iqwyd.nosp@m..com)

References os::String::c_str(), and GetPath().

status_t Directory::FDChanged ( int  nNewFD,
const struct stat &  sStat 
)
virtual

Reimplemented from os::FSNode.

References os::Directory::Private::m_hDirIterator.

status_t Directory::GetNextEntry ( String pcName)
virtual
status_t Directory::GetNextEntry ( FileReference pcRef)
virtual
status_t Directory::GetPath ( String pcPath) const
Description:
Note:
Warning:
Parameters
\return
Error codes:
See Also
Author
Kurt Skauen (kurt@.nosp@m.athe.nosp@m.os.cx)

References os::FSNode::GetFileDescriptor().

Referenced by os::SymLink::ConstructPath(), CreateDirectoryDialog(), Delete(), os::FileReference::GetPath(), and os::FileReference::Rename().

status_t Directory::Rewind ( )
virtual
status_t Directory::SetPath ( const String cPath,
int  nOpenMode = O_RDONLY 
)

status_t Directory::SetPath( const String& cPath, int nOpenMode = O_RDONLY )

Description:
Open the directory pointet to by cPath. The path must be valid and it must point to a directory.
Parameters
cPathThe directory to open.
nOpenModeFlags describing how to open the directory. Only O_RDONLY, O_WRONLY, and O_RDWR are relevant to directories. Take a look at the os::FSNode documentation for a more detailed description of open modes.
Author
Dee Sharpe (demet.nosp@m.riou.nosp@m.sshar.nosp@m.pe@n.nosp@m.etsca.nosp@m.pe.n.nosp@m.et)

References os::FSNode::GetFileDescriptor(), os::FSNode::GetMode(), os::Directory::Private::m_hDirIterator, and os::FSNode::SetTo().

status_t Directory::SetPath ( const Path cPath,
int  nOpenMode = O_RDONLY 
)

status_t Directory::SetPath( const Path& cPath, int nOpenMode = O_RDONLY )

Description:
Open the directory pointet to by cPath. The path must be valid and it must point to a directory.
Parameters
cPathThe directory to open.
nOpenModeFlags describing how to open the directory. Only O_RDONLY, O_WRONLY, and O_RDWR are relevant to directories. Take a look at the os::FSNode documentation for a more detailed description of open modes.
Author
Dee Sharpe (demet.nosp@m.riou.nosp@m.sshar.nosp@m.pe@n.nosp@m.etsca.nosp@m.pe.n.nosp@m.et)

References os::FSNode::GetFileDescriptor(), os::FSNode::GetMode(), os::Path::GetPath(), os::Directory::Private::m_hDirIterator, and os::FSNode::SetTo().