2 #include "ace/OS_Memory.h"
4 #if defined (ACE_LACKS_ALPHASORT)
5 # include "ace/OS_NS_string.h"
6 #endif /* ACE_LACKS_ALPHASORT */
8 ACE_BEGIN_VERSIONED_NAMESPACE_DECL
16 #if defined (ACE_HAS_DIRENT)
17 # if (defined (ACE_WIN32) || defined (ACE_MQX)) && defined (ACE_LACKS_CLOSEDIR)
18 ACE_OS::closedir_emulation (d);
19 delete [] d->directory_name_;
21 # elif defined (ACE_HAS_WCLOSEDIR) && defined (ACE_USES_WCHAR)
23 # else /* ACE_WIN32 && ACE_LACKS_CLOSEDIR */
25 # endif /* ACE_WIN32 && ACE_LACKS_CLOSEDIR */
27 #else /* ACE_HAS_DIRENT */
29 #endif /* ACE_HAS_DIRENT */
33 opendir (const ACE_TCHAR *filename)
35 #if defined (ACE_HAS_DIRENT)
36 # if (defined (ACE_WIN32) || defined(ACE_MQX)) && defined (ACE_LACKS_OPENDIR)
37 return ::ACE_OS::opendir_emulation (filename);
38 # elif defined (ACE_HAS_WOPENDIR) && defined (ACE_USES_WCHAR)
39 return ::wopendir (filename);
40 # elif defined (ACE_HAS_NONCONST_OPENDIR)
41 return ::opendir (const_cast<char *> (filename));
42 # else /* ! ACE_WIN32 && ACE_LACKS_OPENDIR */
43 return ::opendir (ACE_TEXT_ALWAYS_CHAR (filename));
44 # endif /* ACE_WIN32 && ACE_LACKS_OPENDIR */
46 ACE_UNUSED_ARG (filename);
47 ACE_NOTSUP_RETURN (0);
48 #endif /* ACE_HAS_DIRENT */
51 ACE_INLINE struct ACE_DIRENT *
54 #if defined (ACE_HAS_DIRENT)
55 # if (defined (ACE_WIN32) || defined (ACE_MQX)) && defined (ACE_LACKS_READDIR)
56 return ACE_OS::readdir_emulation (d);
57 # elif defined (ACE_HAS_WREADDIR) && defined (ACE_USES_WCHAR)
58 return ::wreaddir (d);
59 # else /* ACE_WIN32 && ACE_LACKS_READDIR */
61 # endif /* ACE_WIN32 && ACE_LACKS_READDIR */
64 ACE_NOTSUP_RETURN (0);
65 #endif /* ACE_HAS_DIRENT */
69 rewinddir (ACE_DIR *d)
71 #if defined (ACE_HAS_DIRENT)
72 # if defined (ACE_HAS_WREWINDDIR) && defined (ACE_USES_WCHAR)
74 # elif !defined (ACE_LACKS_REWINDDIR)
75 ace_rewinddir_helper (d);
78 # endif /* !defined (ACE_LACKS_REWINDDIR) */
79 #endif /* ACE_HAS_DIRENT */
83 scandir (const ACE_TCHAR *dirname,
84 struct ACE_DIRENT **namelist[],
85 ACE_SCANDIR_SELECTOR selector,
86 ACE_SCANDIR_COMPARATOR comparator)
88 #if defined (ACE_HAS_SCANDIR)
89 return ::scandir (ACE_TEXT_ALWAYS_CHAR (dirname),
91 # if defined (ACE_SCANDIR_SEL_LACKS_CONST)
92 reinterpret_cast<ACE_SCANDIR_OS_SELECTOR> (selector),
95 # endif /* ACE_SCANDIR_SEL_LACKS_CONST */
96 # if defined (ACE_SCANDIR_CMP_USES_VOIDPTR) || \
97 defined (ACE_SCANDIR_CMP_USES_CONST_VOIDPTR)
98 reinterpret_cast<ACE_SCANDIR_OS_COMPARATOR> (comparator));
101 # endif /* ACE_SCANDIR_CMP_USES_VOIDPTR */
103 #else /* ! defined ( ACE_HAS_SCANDIR) */
104 return ACE_OS::scandir_emulation (dirname, namelist, selector, comparator);
105 #endif /* ACE_HAS_SCANDIR */
109 alphasort (const void *a, const void *b)
111 #if defined (ACE_LACKS_ALPHASORT)
112 return ACE_OS::strcmp ((*static_cast<const struct ACE_DIRENT * const *>(a))->d_name,
113 (*static_cast<const struct ACE_DIRENT * const *>(b))->d_name);
115 # if defined (ACE_SCANDIR_CMP_USES_VOIDPTR)
116 return ::alphasort (const_cast<void *>(a),
117 const_cast<void *>(b));
118 # elif defined (ACE_SCANDIR_CMP_USES_CONST_VOIDPTR)
119 return ::alphasort (a, b);
121 return ::alphasort ((const struct ACE_DIRENT **)a,
122 (const struct ACE_DIRENT **)b);
128 seekdir (ACE_DIR *d, long loc)
130 #if defined (ACE_HAS_DIRENT) && !defined (ACE_LACKS_SEEKDIR)
132 #else /* ! ACE_HAS_DIRENT || ACE_LACKS_SEEKDIR */
134 ACE_UNUSED_ARG (loc);
135 #endif /* ! ACE_HAS_DIRENT || ACE_LACKS_SEEKDIR */
141 #if defined (ACE_HAS_DIRENT) && !defined (ACE_LACKS_TELLDIR)
142 return ::telldir (d);
143 #else /* ! ACE_HAS_DIRENT || ACE_LACKS_TELLDIR */
145 ACE_NOTSUP_RETURN (-1);
146 #endif /* ! ACE_HAS_DIRENT || ACE_LACKS_TELLDIR */
151 ACE_END_VERSIONED_NAMESPACE_DECL