Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members   Related Pages  

Dirent.h

Go to the documentation of this file.
00001 // -*- C++ -*-
00002 
00003 //=============================================================================
00004 /**
00005  *  @file    Dirent.h
00006  *
00007  *  $Id: Dirent.h,v 1.1.1.4 2003/02/21 18:36:32 chad Exp $
00008  *
00009  *  Define a portable C++ interface to ACE_OS_Dirent directory-entry
00010  *  manipulation.
00011  *
00012  *  @author Douglas C. Schmidt <schmidt@cs.wustl.edu>
00013  */
00014 //=============================================================================
00015 
00016 #ifndef ACE_DIRENT_H
00017 #define ACE_DIRENT_H
00018 #include "ace/pre.h"
00019 
00020 #include "ace/ACE_export.h"
00021 
00022 #if !defined (ACE_LACKS_PRAGMA_ONCE)
00023 # pragma once
00024 #endif /* ACE_LACKS_PRAGMA_ONCE */
00025 
00026 #include "ace/OS_Dirent.h"
00027 
00028 /**
00029  * @class ACE_Dirent
00030  *
00031  * @brief Define a portable C++ directory-entry iterator based on the POSIX API.
00032  */
00033 class ACE_Export ACE_Dirent
00034 {
00035 public:
00036   // = Initialization and termination methods.
00037   /// Default constructor.
00038   ACE_Dirent (void);
00039 
00040   /// Constructor calls <opendir>
00041   ACE_EXPLICIT ACE_Dirent (const ACE_TCHAR *dirname);
00042 
00043   /// Opens the directory named by filename and associates a directory
00044   /// stream with it.
00045   int open (const ACE_TCHAR *filename);
00046 
00047   /// Destructor calls <closedir>.
00048   ~ACE_Dirent (void);
00049 
00050   /// Closes the directory stream and frees the <ACE_DIR> structure.
00051   void close (void);
00052 
00053   // = Iterator methods.
00054   /**
00055    * Returns a pointer to a structure representing the directory entry
00056    * at the current position in the directory stream to which dirp
00057    * refers, and positions the directory stream at the next entry,
00058    * except on read-only filesystems.  It returns a NULL pointer upon
00059    * reaching the end of the directory stream, or upon detecting an
00060    * invalid location in the directory.  <readdir> shall not return
00061    * directory entries containing empty names.  It is unspecified
00062    * whether entries are returned for dot or dot-dot.  The pointer
00063    * returned by <readdir> points to data that may be overwritten by
00064    * another call to <readdir> on the same directory stream.  This
00065    * data shall not be overwritten by another call to <readdir> on a
00066    * different directory stream.  <readdir> may buffer several
00067    * directory entries per actual read operation; <readdir> marks for
00068    * update the st_atime field of the directory each time the
00069    * directory is actually read.
00070    */
00071   dirent *read (void);
00072 
00073   /**
00074    * Has the equivalent functionality as <readdir> except that an
00075    * <entry> and <result> buffer must be supplied by the caller to
00076    * store the result.
00077    */
00078   int read (struct dirent *entry,
00079             struct dirent **result);
00080 
00081   // = Manipulators.
00082   /// Returns the current location associated with the directory
00083   /// stream.
00084   long tell (void);
00085 
00086   /**
00087    * Sets the position of the next <readdir> operation on the
00088    * directory stream.  The new position reverts to the position
00089    * associated with the directory stream at the time the <telldir>
00090    * operation that provides loc was performed.  Values returned by
00091    * <telldir> are good only for the lifetime of the <ACE_DIR> pointer from
00092    * which they are derived.  If the directory is closed and then
00093    * reopened, the <telldir> value may be invalidated due to
00094    * undetected directory compaction.  It is safe to use a previous
00095    * <telldir> value immediately after a call to <opendir> and before
00096    * any calls to readdir.
00097    */
00098   void seek (long loc);
00099 
00100   /**
00101    * Resets the position of the directory stream to the beginning of
00102    * the directory.  It also causes the directory stream to refer to
00103    * the current state of the corresponding directory, as a call to
00104    * <opendir> would.
00105    */
00106   void rewind (void);
00107 
00108 private:
00109   /// Pointer to the directory stream.
00110   ACE_DIR *dirp_;
00111 };
00112 
00113 #if defined (__ACE_INLINE__)
00114 #include "ace/Dirent.i"
00115 #endif /* __ACE_INLINE__ */
00116 
00117 #include "ace/post.h"
00118 #endif /* ACE_DIRENT_H */

Generated on Mon Jun 16 11:19:36 2003 for ACE by doxygen1.2.14 written by Dimitri van Heesch, © 1997-2002