diff options
author | brunsch <brunsch@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 2000-05-25 02:13:02 +0000 |
---|---|---|
committer | brunsch <brunsch@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 2000-05-25 02:13:02 +0000 |
commit | 5952780648a923aa76722d321bf554db01ff0d49 (patch) | |
tree | 2797dfd01f44b939184ce64b1ad3d5cb3da2e56c /ace/OS_Dirent.inl | |
parent | 59c2ed59d55f84c988d432bc2e7e9819147acbcc (diff) | |
download | ATCD-5952780648a923aa76722d321bf554db01ff0d49.tar.gz |
ChangeLogTag:Wed May 24 18:56:16 2000 Darrell Brunsch <brunsch@uci.edu>
Diffstat (limited to 'ace/OS_Dirent.inl')
-rw-r--r-- | ace/OS_Dirent.inl | 90 |
1 files changed, 38 insertions, 52 deletions
diff --git a/ace/OS_Dirent.inl b/ace/OS_Dirent.inl index a14dc02543e..ec78f8e5c54 100644 --- a/ace/OS_Dirent.inl +++ b/ace/OS_Dirent.inl @@ -1,6 +1,42 @@ /* -*- C++ -*- */ // $Id$ +#if !defined (ACE_WIN32) +// Win32 versions in .cpp file + +DIR * +ACE_OS_Dirent::opendir (const ACE_TCHAR *filename) +{ +#if defined (ACE_HAS_DIRENT) +# if defined (ACE_PSOS) + + // The pointer to the DIR buffer must be passed to ACE_OS_Dirent::closedir + // in order to free it and avoid a memory leak. + DIR *dir; + u_long result; + ACE_NEW_RETURN (dir, DIR, 0); +#if defined (ACE_PSOS_DIAB_PPC) + result = ::open_dir (ACE_const_cast (char *, filename), &(dir->xdir)); +#else + result = ::open_dir (ACE_const_cast (char *, filename), dir); +#endif /* defined ACE_PSOS_DIAB_PPC */ + if (result == 0) + return dir; + else + { + errno = result; + return 0; + } +# else /* ! defined (ACE_PSOS) */ + // VxWorks' ::opendir () is declared with a non-const argument. + return ::opendir (ACE_const_cast (char *, filename)); +# endif /* ! defined (ACE_PSOS) */ +#else + ACE_UNUSED_ARG (filename); + ACE_NOTSUP_RETURN (0); +#endif /* ACE_HAS_DIRENT */ +} + ACE_INLINE void ACE_OS_Dirent::closedir (DIR *d) { @@ -16,14 +52,7 @@ ACE_OS_Dirent::closedir (DIR *d) if (result != 0) errno = result; # else /* ! defined (ACE_PSOS) */ -# if defined (ACE_WIN32) - if (d->current_handle_ != INVALID_HANDLE_VALUE) - ::FindClose (d->current_handle_); - d->current_handle_ = INVALID_HANDLE_VALUE; - d->started_reading_ = 0; -# else /* defined (ACE_WIN32) */ ::closedir (d); -# endif /* defined (ACE_WIN32) */ # endif /* ! defined (ACE_PSOS) */ #else ACE_UNUSED_ARG (d); @@ -58,52 +87,7 @@ ACE_OS_Dirent::readdir (DIR *d) } # else /* ! defined (ACE_PSOS) */ -# if defined (ACE_WIN32) - if (!d->started_reading_) - { - d->current_handle_ = ACE_TEXT_FindFirstFile (d->directory_name_, - &(d->fdata_)); - - if (d->current_handle_ != INVALID_HANDLE_VALUE - && d->fdata_.dwFileAttributes != FILE_ATTRIBUTE_DIRECTORY) - { - ::FindClose (d->current_handle_); - d->current_handle_ = INVALID_HANDLE_VALUE; - } - else // Skip "." and ".." - { - int retval = 1; - while (*(d->fdata_.cFileName) == '.' - && retval - && d->current_handle_ != INVALID_HANDLE_VALUE) - { - retval = ACE_TEXT_FindNextFile (d->current_handle_, - &(d->fdata_)); - } - if (retval == 0) - d->current_handle_ = INVALID_HANDLE_VALUE; - } - - d->started_reading_ = 1; - } - else - { - int retval = ACE_TEXT_FindNextFile (d->current_handle_, - &(d->fdata_)); - if (retval == 0) - d->current_handle_ = INVALID_HANDLE_VALUE; - } - - if (d->current_handle_ != INVALID_HANDLE_VALUE) - { - d->dirent_.d_name = d->fdata_.cFileName; - return &(d->dirent_); - } - else - return 0; -# else /* defined (ACE_WIN32) */ return ::readdir (d); -# endif /* defined (ACE_WIN32) */ # endif /* ! defined (ACE_PSOS) */ #else ACE_UNUSED_ARG (d); @@ -111,6 +95,8 @@ ACE_OS_Dirent::readdir (DIR *d) #endif /* ACE_HAS_DIRENT */ } +#endif /* !ACE_WIN32 */ + ACE_INLINE int ACE_OS_Dirent::readdir_r (DIR *dirp, struct dirent *entry, |