3 //=============================================================================
7 * $Id: OS_NS_dirent.h 80826 2008-03-04 14:51:23Z wotte $
9 * @author Douglas C. Schmidt <schmidt@cs.wustl.edu>
10 * @author Jesper S. M|ller<stophph@diku.dk>
11 * @author and a cast of thousands...
15 //=============================================================================
17 #ifndef ACE_OS_NS_DIRENT_H
18 # define ACE_OS_NS_DIRENT_H
20 # include /**/ "ace/pre.h"
22 # include "ace/config-all.h"
24 # if !defined (ACE_LACKS_PRAGMA_ONCE)
26 # endif /* ACE_LACKS_PRAGMA_ONCE */
28 #include "ace/os_include/os_dirent.h"
29 #include /**/ "ace/ACE_export.h"
31 #if defined (ACE_EXPORT_MACRO)
32 # undef ACE_EXPORT_MACRO
34 #define ACE_EXPORT_MACRO ACE_Export
36 // Define the scandir() selector and comparator function types. Many platforms
37 // define these in terms of const pointers to dirent arrays/structs. Some
38 // platforms use void pointers instead. The ACE-exported API is defined in
39 // terms of the dirent-using function types, and if the OS-native scandir()
40 // uses void*, that's handled internal to the ACE_OS::scandir() wrapper using
41 // the ACE_SCANDIR_OS_COMPARATOR.
43 #if defined (ACE_SCANDIR_CMP_USES_VOIDPTR)
44 typedef int (*ACE_SCANDIR_OS_COMPARATOR
)(void *f1
, void *f2
);
45 #elif defined (ACE_SCANDIR_CMP_USES_CONST_VOIDPTR)
46 typedef int (*ACE_SCANDIR_OS_COMPARATOR
)(const void *f1
, const void *f2
);
47 #endif /* ACE_SCANDIR_CMP_USES_VOIDPTR */
48 typedef int (*ACE_SCANDIR_COMPARATOR
)(const ACE_DIRENT
**f1
,
49 const ACE_DIRENT
**f2
);
51 #if defined (ACE_SCANDIR_SEL_LACKS_CONST)
52 typedef int (*ACE_SCANDIR_OS_SELECTOR
)(ACE_DIRENT
*filename
);
53 #endif /* ACE_SCANDIR_SEL_LACKS_CONST */
54 typedef int (*ACE_SCANDIR_SELECTOR
)(const ACE_DIRENT
*filename
);
58 * We inline and undef some functions that may be implemented
59 * as macros on some platforms. This way macro definitions will
60 * be usable later as there is no way to save the macro definition
61 * using the pre-processor.
65 #if !defined (ACE_LACKS_REWINDDIR)
66 # if !defined (ACE_HAS_WREWINDDIR) || !defined (ACE_USES_WCHAR)
67 inline void ace_rewinddir_helper (ACE_DIR
*dir
)
69 # if defined (rewinddir)
74 # endif /* defined (rewinddir) */
76 # endif /* !defined (ACE_HAS_WREWINDDIR) && !defined (ACE_USES_WCHAR) */
77 #endif /* ACE_LACKS_REWINDDIR */
79 ACE_BEGIN_VERSIONED_NAMESPACE_DECL
83 ACE_NAMESPACE_INLINE_FUNCTION
84 void closedir (ACE_DIR
*);
86 ACE_NAMESPACE_INLINE_FUNCTION
87 ACE_DIR
*opendir (const ACE_TCHAR
*filename
);
89 ACE_NAMESPACE_INLINE_FUNCTION
90 struct ACE_DIRENT
*readdir (ACE_DIR
*);
92 ACE_NAMESPACE_INLINE_FUNCTION
93 int readdir_r (ACE_DIR
*dirp
,
94 struct ACE_DIRENT
*entry
,
95 struct ACE_DIRENT
**result
);
97 ACE_NAMESPACE_INLINE_FUNCTION
98 void rewinddir (ACE_DIR
*);
100 ACE_NAMESPACE_INLINE_FUNCTION
101 int scandir (const ACE_TCHAR
*dirname
,
102 struct ACE_DIRENT
**namelist
[],
103 ACE_SCANDIR_SELECTOR selector
,
104 ACE_SCANDIR_COMPARATOR comparator
);
106 ACE_NAMESPACE_INLINE_FUNCTION
107 int alphasort (const void *, const void *);
109 ACE_NAMESPACE_INLINE_FUNCTION
110 void seekdir (ACE_DIR
*,
113 ACE_NAMESPACE_INLINE_FUNCTION
114 long telldir (ACE_DIR
*);
116 // Win32 emulation functions
117 #if defined (ACE_LACKS_OPENDIR)
119 ACE_DIR
*opendir_emulation (const ACE_TCHAR
*filename
);
120 #endif /* ACE_LACKS_OPENDIR */
122 #if !defined (ACE_HAS_SCANDIR)
124 int scandir_emulation (const ACE_TCHAR
*dirname
,
125 ACE_DIRENT
**namelist
[],
126 ACE_SCANDIR_SELECTOR selector
,
127 ACE_SCANDIR_COMPARATOR comparator
);
128 #endif /* !ACE_HAS_SCANDIR */
130 #if defined (ACE_LACKS_CLOSEDIR)
132 void closedir_emulation (ACE_DIR
*);
133 #endif /* ACE_LACKS_CLOSEDIR */
135 #if defined (ACE_LACKS_READDIR)
137 struct ACE_DIRENT
*readdir_emulation (ACE_DIR
*);
138 #endif /* ACE_LACKS_READDIR */
140 } /* namespace ACE_OS */
142 ACE_END_VERSIONED_NAMESPACE_DECL
144 # if defined (ACE_HAS_INLINED_OSCALLS)
145 # if defined (ACE_INLINE)
147 # endif /* ACE_INLINE */
148 # define ACE_INLINE inline
149 # include "ace/OS_NS_dirent.inl"
150 # endif /* ACE_HAS_INLINED_OSCALLS */
152 # include /**/ "ace/post.h"
153 #endif /* ACE_OS_NS_DIRENT_H */