OS_NS_dirent.h

Go to the documentation of this file.
00001 // -*- C++ -*-
00002 
00003 //=============================================================================
00004 /**
00005  *  @file   OS_NS_dirent.h
00006  *
00007  *  $Id: OS_NS_dirent.h 80826 2008-03-04 14:51:23Z wotte $
00008  *
00009  *  @author Douglas C. Schmidt <schmidt@cs.wustl.edu>
00010  *  @author Jesper S. M|ller<stophph@diku.dk>
00011  *  @author and a cast of thousands...
00012  *
00013  *  Originally in OS.h.
00014  */
00015 //=============================================================================
00016 
00017 #ifndef ACE_OS_NS_DIRENT_H
00018 # define ACE_OS_NS_DIRENT_H
00019 
00020 # include /**/ "ace/pre.h"
00021 
00022 # include "ace/config-all.h"
00023 
00024 # if !defined (ACE_LACKS_PRAGMA_ONCE)
00025 #  pragma once
00026 # endif /* ACE_LACKS_PRAGMA_ONCE */
00027 
00028 #include "ace/os_include/os_dirent.h"
00029 #include /**/ "ace/ACE_export.h"
00030 
00031 #if defined (ACE_EXPORT_MACRO)
00032 #  undef ACE_EXPORT_MACRO
00033 #endif
00034 #define ACE_EXPORT_MACRO ACE_Export
00035 
00036 // Define the scandir() selector and comparator function types. Many platforms
00037 // define these in terms of const pointers to dirent arrays/structs. Some
00038 // platforms use void pointers instead. The ACE-exported API is defined in
00039 // terms of the dirent-using function types, and if the OS-native scandir()
00040 // uses void*, that's handled internal to the ACE_OS::scandir() wrapper using
00041 // the ACE_SCANDIR_OS_COMPARATOR.
00042 extern "C" {
00043 #if defined (ACE_SCANDIR_CMP_USES_VOIDPTR)
00044   typedef int (*ACE_SCANDIR_OS_COMPARATOR)(void *f1, void *f2);
00045 #elif defined (ACE_SCANDIR_CMP_USES_CONST_VOIDPTR)
00046   typedef int (*ACE_SCANDIR_OS_COMPARATOR)(const void *f1, const void *f2);
00047 #endif /* ACE_SCANDIR_CMP_USES_VOIDPTR */
00048   typedef int (*ACE_SCANDIR_COMPARATOR)(const ACE_DIRENT **f1,
00049                                         const ACE_DIRENT **f2);
00050 
00051 #if defined (ACE_SCANDIR_SEL_LACKS_CONST)
00052   typedef int (*ACE_SCANDIR_OS_SELECTOR)(ACE_DIRENT *filename);
00053 #endif /* ACE_SCANDIR_SEL_LACKS_CONST */
00054   typedef int (*ACE_SCANDIR_SELECTOR)(const ACE_DIRENT *filename);
00055 }
00056 
00057 /*
00058  * We inline and undef some functions that may be implemented
00059  * as macros on some platforms. This way macro definitions will
00060  * be usable later as there is no way to save the macro definition
00061  * using the pre-processor.
00062  *
00063  */
00064 
00065 #if !defined (ACE_LACKS_REWINDDIR)
00066 #  if !defined (ACE_HAS_WREWINDDIR) || !defined (ACE_USES_WCHAR)
00067 inline void ace_rewinddir_helper (ACE_DIR *dir)
00068 {
00069 #    if defined (rewinddir)
00070    rewinddir (dir);
00071 #    undef rewinddir
00072 #    else
00073   ::rewinddir (dir);
00074 #    endif /* defined (rewinddir) */
00075 }
00076 #  endif /* !defined (ACE_HAS_WREWINDDIR) && !defined (ACE_USES_WCHAR) */
00077 #endif /* ACE_LACKS_REWINDDIR */
00078 
00079 ACE_BEGIN_VERSIONED_NAMESPACE_DECL
00080 
00081 namespace ACE_OS {
00082 
00083   ACE_NAMESPACE_INLINE_FUNCTION
00084   void closedir (ACE_DIR *);
00085 
00086   ACE_NAMESPACE_INLINE_FUNCTION
00087   ACE_DIR *opendir (const ACE_TCHAR *filename);
00088 
00089   ACE_NAMESPACE_INLINE_FUNCTION
00090   struct ACE_DIRENT *readdir (ACE_DIR *);
00091 
00092   ACE_NAMESPACE_INLINE_FUNCTION
00093   int readdir_r (ACE_DIR *dirp,
00094                  struct ACE_DIRENT *entry,
00095                  struct ACE_DIRENT **result);
00096 
00097   ACE_NAMESPACE_INLINE_FUNCTION
00098   void rewinddir (ACE_DIR *);
00099 
00100   ACE_NAMESPACE_INLINE_FUNCTION
00101   int scandir (const ACE_TCHAR *dirname,
00102                struct ACE_DIRENT **namelist[],
00103                ACE_SCANDIR_SELECTOR selector,
00104                ACE_SCANDIR_COMPARATOR comparator);
00105 
00106   ACE_NAMESPACE_INLINE_FUNCTION
00107   int alphasort (const void *, const void *);
00108 
00109   ACE_NAMESPACE_INLINE_FUNCTION
00110   void seekdir (ACE_DIR *,
00111                 long loc);
00112 
00113   ACE_NAMESPACE_INLINE_FUNCTION
00114   long telldir (ACE_DIR *);
00115 
00116   // Win32 emulation functions
00117 #if defined (ACE_LACKS_OPENDIR)
00118   extern ACE_Export
00119   ACE_DIR *opendir_emulation (const ACE_TCHAR *filename);
00120 #endif /* ACE_LACKS_OPENDIR */
00121 
00122 #if !defined (ACE_HAS_SCANDIR)
00123   extern ACE_Export
00124   int scandir_emulation (const ACE_TCHAR *dirname,
00125                          ACE_DIRENT **namelist[],
00126                          ACE_SCANDIR_SELECTOR selector,
00127                          ACE_SCANDIR_COMPARATOR comparator);
00128 #endif /* !ACE_HAS_SCANDIR */
00129 
00130 #if defined (ACE_LACKS_CLOSEDIR)
00131   extern ACE_Export
00132   void closedir_emulation (ACE_DIR *);
00133 #endif /* ACE_LACKS_CLOSEDIR */
00134 
00135 #if defined (ACE_LACKS_READDIR)
00136   extern ACE_Export
00137   struct ACE_DIRENT *readdir_emulation (ACE_DIR *);
00138 #endif /* ACE_LACKS_READDIR */
00139 
00140 } /* namespace ACE_OS */
00141 
00142 ACE_END_VERSIONED_NAMESPACE_DECL
00143 
00144 # if defined (ACE_HAS_INLINED_OSCALLS)
00145 #   if defined (ACE_INLINE)
00146 #     undef ACE_INLINE
00147 #   endif /* ACE_INLINE */
00148 #   define ACE_INLINE inline
00149 #   include "ace/OS_NS_dirent.inl"
00150 # endif /* ACE_HAS_INLINED_OSCALLS */
00151 
00152 # include /**/ "ace/post.h"
00153 #endif /* ACE_OS_NS_DIRENT_H */

Generated on Tue Feb 2 17:18:41 2010 for ACE by  doxygen 1.4.7