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

OS_Dirent.h

Go to the documentation of this file.
00001 // -*- C++ -*-
00002 
00003 //=============================================================================
00004 /**
00005  *  @file   OS_Dirent.h
00006  *
00007  *  $Id: OS_Dirent.h,v 1.1.1.3 2003/02/21 18:36:32 chad Exp $
00008  *
00009  *  @author Doug Schmidt <schmidt@cs.wustl.edu>
00010  *  @author Jesper S. M|ller<stophph@diku.dk>
00011  *  @author and a cast of thousands...
00012  */
00013 //=============================================================================
00014 
00015 #ifndef ACE_OS_DIRENT_H
00016 #define ACE_OS_DIRENT_H
00017 #include "ace/pre.h"
00018 
00019 #include "ace/OS_Export.h"
00020 
00021 #if !defined (ACE_LACKS_PRAGMA_ONCE)
00022 # pragma once
00023 #endif /* ACE_LACKS_PRAGMA_ONCE */
00024 
00025 #include "ace/OS_Errno.h"
00026 
00027 #if !defined (ACE_WIN32) && !defined (ACE_PSOS) && !defined (ACE_HAS_WINCE)
00028 # include /**/ <sys/types.h>
00029 # if !defined (ACE_LACKS_UNISTD_H)
00030 #   include /**/ <unistd.h>  // VxWorks needs this to compile
00031 # endif /* !ACE_LACKS_UNISTD_H */
00032 # include /**/ <dirent.h>
00033 #endif /* !ACE_WIN32 && !ACE_PSOS */
00034 
00035 // At least compile on some of the platforms without <ACE_DIR> info yet.
00036 # if !defined (ACE_HAS_DIRENT)
00037 typedef int ACE_DIR;
00038 struct dirent {
00039 };
00040 # endif /* ACE_HAS_DIRENT */
00041 
00042 #if defined (ACE_LACKS_STRUCT_DIR)
00043 struct dirent {
00044   unsigned short d_ino;
00045   unsigned short d_off;
00046   unsigned short d_reclen;
00047   // This must be a ACE_TCHAR * and not a one element
00048   // ACE_TCHAR array.  It causes problems on wide
00049   // character builds with Visual C++ 6.0.
00050   ACE_TCHAR *d_name;
00051 };
00052 
00053 struct ACE_DIR {
00054   /// The name of the directory we are looking into
00055   ACE_TCHAR *directory_name_;
00056 
00057   /// Remember the handle between calls.
00058   HANDLE current_handle_;
00059 
00060   /// The struct for the results
00061   dirent *dirent_;
00062 
00063   /// The struct for intermediate results.
00064   ACE_TEXT_WIN32_FIND_DATA fdata_;
00065 
00066   /// A flag to remember if we started reading already.
00067   int started_reading_;
00068 };
00069 #elif defined (ACE_PSOS) && !defined (ACE_PSOS_DIAB_PPC)
00070 // Create our own definition of the DIR struct, like what
00071 // is available in the newer DIAB PPC header files
00072 struct ACE_DIR
00073 {
00074   /// The directory handle
00075   XDIR            xdir;
00076 
00077   /// The directory entry
00078   struct dirent   dirent;
00079 };
00080 #else
00081 typedef DIR ACE_DIR;
00082 # endif /* ACE_LACKS_STRUCT_DIR */
00083 
00084 #if defined rewinddir
00085 # undef rewinddir
00086 #endif /* rewinddir */
00087 
00088 /**
00089  * @class ACE_OS_Dirent
00090  *
00091  * @brief This class is a wrapper for the dirent.h operations
00092  *
00093  */
00094 class ACE_OS_Export ACE_OS_Dirent
00095 {
00096 public:
00097   static ACE_DIR *opendir (const ACE_TCHAR *filename);
00098   static void closedir (ACE_DIR *);
00099   static dirent *readdir (ACE_DIR *);
00100   static int readdir_r (ACE_DIR *dirp,
00101                         struct dirent *entry,
00102                         struct dirent **result);
00103   static long telldir (ACE_DIR *);
00104   static void seekdir (ACE_DIR *,
00105                        long loc);
00106   static void rewinddir (ACE_DIR *);
00107 
00108   static int scandir (const ACE_TCHAR *dirname,
00109                       struct dirent **namelist[],
00110                       int (*selector) (const struct dirent *filename),
00111                       int (*comparator) (const struct dirent **f1,
00112                                          const struct dirent **f2));
00113 private:
00114   // Win32 emulation functions
00115   static ACE_DIR *opendir_emulation (const ACE_TCHAR *filename);
00116   static int scandir_emulation (const ACE_TCHAR *dirname,
00117                                 dirent **namelist[],
00118                                 int (*selector)(const dirent *entry),
00119                                 int (*comparator)(const dirent **f1,
00120                                                   const dirent**f2));
00121   static void closedir_emulation (ACE_DIR *);
00122   static dirent *readdir_emulation (ACE_DIR *);
00123 };
00124 
00125 # if defined (ACE_HAS_INLINED_OSCALLS)
00126 #   if defined (ACE_INLINE)
00127 #     undef ACE_INLINE
00128 #   endif /* ACE_INLINE */
00129 #   define ACE_INLINE inline
00130 #   include "ace/OS_Dirent.inl"
00131 # endif /* ACE_HAS_INLINED_OSCALLS */
00132 
00133 #include "ace/post.h"
00134 #endif /* ACE_OS_DIRENT_H */

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