00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
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
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
00032 # include <dirent.h>
00033 #endif
00034
00035
00036 # if !defined (ACE_HAS_DIRENT)
00037 typedef int ACE_DIR;
00038 struct dirent {
00039 };
00040 # endif
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
00048
00049
00050 ACE_TCHAR *d_name;
00051 };
00052
00053 struct ACE_DIR {
00054
00055 ACE_TCHAR *directory_name_;
00056
00057
00058 HANDLE current_handle_;
00059
00060
00061 dirent *dirent_;
00062
00063
00064 ACE_TEXT_WIN32_FIND_DATA fdata_;
00065
00066
00067 int started_reading_;
00068 };
00069 #elif defined (ACE_PSOS) && !defined (ACE_PSOS_DIAB_PPC)
00070
00071
00072 struct ACE_DIR
00073 {
00074
00075 XDIR xdir;
00076
00077
00078 struct dirent dirent;
00079 };
00080 #else
00081 typedef DIR ACE_DIR;
00082 # endif
00083
00084 #if defined rewinddir
00085 # undef rewinddir
00086 #endif
00087
00088
00089
00090
00091
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
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
00129 # define ACE_INLINE inline
00130 # include "ace/OS_Dirent.inl"
00131 # endif
00132
00133 #include "ace/post.h"
00134 #endif