2001-09-10 Earnie Boyd <earnie@SF.net>
* dossh: Remove inadvertantly imported file. 2001-09-10 Danny Smith <dannysmith@users.sourceforge.net> * dirent.c (opendir): Use GetFileAttributes rather than stat to determine if input arg is dir.
This commit is contained in:
parent
f3acbe3e3f
commit
34ed8fcee6
|
@ -1,3 +1,12 @@
|
||||||
|
2001-09-10 Earnie Boyd <earnie@SF.net>
|
||||||
|
|
||||||
|
* dossh: Remove inadvertantly imported file.
|
||||||
|
|
||||||
|
2001-09-10 Danny Smith <dannysmith@users.sourceforge.net>
|
||||||
|
|
||||||
|
* dirent.c (opendir): Use GetFileAttributes rather than stat
|
||||||
|
to determine if input arg is dir.
|
||||||
|
|
||||||
2001-08-29 Danny Smith <dannysmith@users.sourceforge.net>
|
2001-08-29 Danny Smith <dannysmith@users.sourceforge.net>
|
||||||
|
|
||||||
* include/stdarg.h (va_list): Typedef as __builtin_va_list if
|
* include/stdarg.h (va_list): Typedef as __builtin_va_list if
|
||||||
|
|
|
@ -8,7 +8,7 @@
|
||||||
* Updated by Jeremy Bettis <jeremy@hksys.com>
|
* Updated by Jeremy Bettis <jeremy@hksys.com>
|
||||||
* Significantly revised and rewinddir, seekdir and telldir added by Colin
|
* Significantly revised and rewinddir, seekdir and telldir added by Colin
|
||||||
* Peters <colin@fu.is.saga-u.ac.jp>
|
* Peters <colin@fu.is.saga-u.ac.jp>
|
||||||
*
|
*
|
||||||
* $Revision$
|
* $Revision$
|
||||||
* $Author$
|
* $Author$
|
||||||
* $Date$
|
* $Date$
|
||||||
|
@ -20,10 +20,12 @@
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <io.h>
|
#include <io.h>
|
||||||
#include <direct.h>
|
#include <direct.h>
|
||||||
#include <sys/stat.h>
|
|
||||||
|
|
||||||
#include <dirent.h>
|
#include <dirent.h>
|
||||||
|
|
||||||
|
#define WIN32_LEAN_AND_MEAN
|
||||||
|
#include <windows.h> /* for GetFileAttributes */
|
||||||
|
|
||||||
#define SUFFIX "*"
|
#define SUFFIX "*"
|
||||||
#define SLASH "\\"
|
#define SLASH "\\"
|
||||||
|
|
||||||
|
@ -33,12 +35,12 @@
|
||||||
* Returns a pointer to a DIR structure appropriately filled in to begin
|
* Returns a pointer to a DIR structure appropriately filled in to begin
|
||||||
* searching a directory.
|
* searching a directory.
|
||||||
*/
|
*/
|
||||||
DIR *
|
DIR *
|
||||||
opendir (const char *szPath)
|
opendir (const char *szPath)
|
||||||
{
|
{
|
||||||
DIR *nd;
|
DIR *nd;
|
||||||
struct _stat statDir;
|
unsigned int rc;
|
||||||
|
|
||||||
errno = 0;
|
errno = 0;
|
||||||
|
|
||||||
if (!szPath)
|
if (!szPath)
|
||||||
|
@ -54,15 +56,16 @@ opendir (const char *szPath)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Attempt to determine if the given path really is a directory. */
|
/* Attempt to determine if the given path really is a directory. */
|
||||||
if (_stat (szPath, &statDir))
|
rc = GetFileAttributes(szPath);
|
||||||
|
if (rc == -1)
|
||||||
{
|
{
|
||||||
/* Error, stat should have set an error value. */
|
/* call GetLastError for more error info */
|
||||||
|
errno = ENOENT;
|
||||||
return (DIR *) 0;
|
return (DIR *) 0;
|
||||||
}
|
}
|
||||||
|
if (!(rc & FILE_ATTRIBUTE_DIRECTORY))
|
||||||
if (!S_ISDIR (statDir.st_mode))
|
|
||||||
{
|
{
|
||||||
/* Error, stat reports not a directory. */
|
/* Error, entry exists but not a directory. */
|
||||||
errno = ENOTDIR;
|
errno = ENOTDIR;
|
||||||
return (DIR *) 0;
|
return (DIR *) 0;
|
||||||
}
|
}
|
||||||
|
@ -149,7 +152,7 @@ readdir (DIR * dirp)
|
||||||
/* Start the search */
|
/* Start the search */
|
||||||
dirp->dd_handle = _findfirst (dirp->dd_name, &(dirp->dd_dta));
|
dirp->dd_handle = _findfirst (dirp->dd_name, &(dirp->dd_dta));
|
||||||
|
|
||||||
if (dirp->dd_handle == -1)
|
if (dirp->dd_handle == -1)
|
||||||
{
|
{
|
||||||
/* Whoops! Seems there are no files in that
|
/* Whoops! Seems there are no files in that
|
||||||
* directory. */
|
* directory. */
|
||||||
|
|
Loading…
Reference in New Issue