3 //=============================================================================
7 * @author Douglas C. Schmidt <d.schmidt@vanderbilt.edu>
8 * @author Jesper S. M|ller<stophph@diku.dk>
9 * @author and a cast of thousands...
13 //=============================================================================
15 #ifndef ACE_OS_NS_DIRENT_H
16 # define ACE_OS_NS_DIRENT_H
18 # include /**/ "ace/pre.h"
20 # include "ace/config-all.h"
22 # if !defined (ACE_LACKS_PRAGMA_ONCE)
24 # endif /* ACE_LACKS_PRAGMA_ONCE */
26 #include "ace/os_include/os_dirent.h"
27 #include /**/ "ace/ACE_export.h"
29 #if defined (ACE_EXPORT_MACRO)
30 # undef ACE_EXPORT_MACRO
32 #define ACE_EXPORT_MACRO ACE_Export
34 // Define the scandir() selector and comparator function types. Many platforms
35 // define these in terms of const pointers to dirent arrays/structs. Some
36 // platforms use void pointers instead. The ACE-exported API is defined in
37 // terms of the dirent-using function types, and if the OS-native scandir()
38 // uses void*, that's handled internal to the ACE_OS::scandir() wrapper using
39 // the ACE_SCANDIR_OS_COMPARATOR.
41 #if defined (ACE_SCANDIR_CMP_USES_VOIDPTR)
42 typedef int (*ACE_SCANDIR_OS_COMPARATOR
)(void *f1
, void *f2
);
43 #elif defined (ACE_SCANDIR_CMP_USES_CONST_VOIDPTR)
44 typedef int (*ACE_SCANDIR_OS_COMPARATOR
)(const void *f1
, const void *f2
);
45 #endif /* ACE_SCANDIR_CMP_USES_VOIDPTR */
46 typedef int (*ACE_SCANDIR_COMPARATOR
)(const ACE_DIRENT
**f1
,
47 const ACE_DIRENT
**f2
);
49 #if defined (ACE_SCANDIR_SEL_LACKS_CONST)
50 typedef int (*ACE_SCANDIR_OS_SELECTOR
)(ACE_DIRENT
*filename
);
51 #endif /* ACE_SCANDIR_SEL_LACKS_CONST */
52 typedef int (*ACE_SCANDIR_SELECTOR
)(const ACE_DIRENT
*filename
);
56 * We inline and undef some functions that may be implemented
57 * as macros on some platforms. This way macro definitions will
58 * be usable later as there is no way to save the macro definition
59 * using the pre-processor.
62 #if !defined (ACE_LACKS_REWINDDIR)
63 # if !defined (ACE_HAS_WREWINDDIR) || !defined (ACE_USES_WCHAR)
64 inline void ace_rewinddir_helper (ACE_DIR
*dir
)
66 # if defined (rewinddir)
71 # endif /* defined (rewinddir) */
73 # endif /* !defined (ACE_HAS_WREWINDDIR) && !defined (ACE_USES_WCHAR) */
74 #endif /* ACE_LACKS_REWINDDIR */
76 ACE_BEGIN_VERSIONED_NAMESPACE_DECL
80 ACE_NAMESPACE_INLINE_FUNCTION
81 void closedir (ACE_DIR
*);
83 ACE_NAMESPACE_INLINE_FUNCTION
84 ACE_DIR
*opendir (const ACE_TCHAR
*filename
);
86 ACE_NAMESPACE_INLINE_FUNCTION
87 struct ACE_DIRENT
*readdir (ACE_DIR
*);
89 ACE_NAMESPACE_INLINE_FUNCTION
90 int readdir_r (ACE_DIR
*dirp
,
91 struct ACE_DIRENT
*entry
,
92 struct ACE_DIRENT
**result
);
94 ACE_NAMESPACE_INLINE_FUNCTION
95 void rewinddir (ACE_DIR
*);
97 ACE_NAMESPACE_INLINE_FUNCTION
98 int scandir (const ACE_TCHAR
*dirname
,
99 struct ACE_DIRENT
**namelist
[],
100 ACE_SCANDIR_SELECTOR selector
,
101 ACE_SCANDIR_COMPARATOR comparator
);
103 ACE_NAMESPACE_INLINE_FUNCTION
104 int alphasort (const void *, const void *);
106 ACE_NAMESPACE_INLINE_FUNCTION
107 void seekdir (ACE_DIR
*,
110 ACE_NAMESPACE_INLINE_FUNCTION
111 long telldir (ACE_DIR
*);
113 // Win32 emulation functions
114 #if defined (ACE_LACKS_OPENDIR)
116 ACE_DIR
*opendir_emulation (const ACE_TCHAR
*filename
);
117 #endif /* ACE_LACKS_OPENDIR */
119 #if !defined (ACE_HAS_SCANDIR)
121 int scandir_emulation (const ACE_TCHAR
*dirname
,
122 ACE_DIRENT
**namelist
[],
123 ACE_SCANDIR_SELECTOR selector
,
124 ACE_SCANDIR_COMPARATOR comparator
);
125 #endif /* !ACE_HAS_SCANDIR */
127 #if defined (ACE_LACKS_CLOSEDIR)
129 void closedir_emulation (ACE_DIR
*);
130 #endif /* ACE_LACKS_CLOSEDIR */
132 #if defined (ACE_LACKS_READDIR)
134 struct ACE_DIRENT
*readdir_emulation (ACE_DIR
*);
135 #endif /* ACE_LACKS_READDIR */
137 } /* namespace ACE_OS */
139 ACE_END_VERSIONED_NAMESPACE_DECL
141 # if defined (ACE_HAS_INLINED_OSCALLS)
142 # if defined (ACE_INLINE)
144 # endif /* ACE_INLINE */
145 # define ACE_INLINE inline
146 # include "ace/OS_NS_dirent.inl"
147 # endif /* ACE_HAS_INLINED_OSCALLS */
149 # include /**/ "ace/post.h"
150 #endif /* ACE_OS_NS_DIRENT_H */