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 # else /* ! ACE_WIN32 && ACE_LACKS_OPENDIR */
41 return ::opendir (ACE_TEXT_ALWAYS_CHAR (filename));
42 # endif /* ACE_WIN32 && ACE_LACKS_OPENDIR */
44 ACE_UNUSED_ARG (filename);
45 ACE_NOTSUP_RETURN (0);
46 #endif /* ACE_HAS_DIRENT */
49 ACE_INLINE struct ACE_DIRENT *
52 #if defined (ACE_HAS_DIRENT)
53 # if (defined (ACE_WIN32) || defined (ACE_MQX)) && defined (ACE_LACKS_READDIR)
54 return ACE_OS::readdir_emulation (d);
55 # elif defined (ACE_HAS_WREADDIR) && defined (ACE_USES_WCHAR)
56 return ::wreaddir (d);
57 # else /* ACE_WIN32 && ACE_LACKS_READDIR */
59 # endif /* ACE_WIN32 && ACE_LACKS_READDIR */
62 ACE_NOTSUP_RETURN (0);
63 #endif /* ACE_HAS_DIRENT */
67 rewinddir (ACE_DIR *d)
69 #if defined (ACE_HAS_DIRENT)
70 # if defined (ACE_HAS_WREWINDDIR) && defined (ACE_USES_WCHAR)
72 # elif !defined (ACE_LACKS_REWINDDIR)
73 ace_rewinddir_helper (d);
76 # endif /* !defined (ACE_LACKS_REWINDDIR) */
77 #endif /* ACE_HAS_DIRENT */
81 scandir (const ACE_TCHAR *dirname,
82 struct ACE_DIRENT **namelist[],
83 ACE_SCANDIR_SELECTOR selector,
84 ACE_SCANDIR_COMPARATOR comparator)
86 #if defined (ACE_HAS_SCANDIR)
87 return ::scandir (ACE_TEXT_ALWAYS_CHAR (dirname),
90 # if defined (ACE_SCANDIR_CMP_USES_VOIDPTR) || \
91 defined (ACE_SCANDIR_CMP_USES_CONST_VOIDPTR)
92 reinterpret_cast<ACE_SCANDIR_OS_COMPARATOR> (comparator));
95 # endif /* ACE_SCANDIR_CMP_USES_VOIDPTR */
97 #else /* ! defined ( ACE_HAS_SCANDIR) */
98 return ACE_OS::scandir_emulation (dirname, namelist, selector, comparator);
99 #endif /* ACE_HAS_SCANDIR */
103 alphasort (const void *a, const void *b)
105 #if defined (ACE_LACKS_ALPHASORT)
106 return ACE_OS::strcmp ((*static_cast<const struct ACE_DIRENT * const *>(a))->d_name,
107 (*static_cast<const struct ACE_DIRENT * const *>(b))->d_name);
109 # if defined (ACE_SCANDIR_CMP_USES_VOIDPTR)
110 return ::alphasort (const_cast<void *>(a),
111 const_cast<void *>(b));
112 # elif defined (ACE_SCANDIR_CMP_USES_CONST_VOIDPTR)
113 return ::alphasort (a, b);
115 return ::alphasort ((const struct ACE_DIRENT **)a,
116 (const struct ACE_DIRENT **)b);
122 seekdir (ACE_DIR *d, long loc)
124 #if defined (ACE_HAS_DIRENT) && !defined (ACE_LACKS_SEEKDIR)
126 #else /* ! ACE_HAS_DIRENT || ACE_LACKS_SEEKDIR */
128 ACE_UNUSED_ARG (loc);
129 #endif /* ! ACE_HAS_DIRENT || ACE_LACKS_SEEKDIR */
135 #if defined (ACE_HAS_DIRENT) && !defined (ACE_LACKS_TELLDIR)
136 return ::telldir (d);
137 #else /* ! ACE_HAS_DIRENT || ACE_LACKS_TELLDIR */
139 ACE_NOTSUP_RETURN (-1);
140 #endif /* ! ACE_HAS_DIRENT || ACE_LACKS_TELLDIR */
145 ACE_END_VERSIONED_NAMESPACE_DECL