* Significantly revised and rewinddir, seekdir and telldir added by Colin
* Peters <colin@fu.is.saga-u.ac.jp>
*
- * $Revision: 1.2 $
+ * $Revision: 1.3 $
* $Author: sam $
- * $Date: 2002/11/09 17:44:09 $
+ * $Date: 2002/11/10 18:04:23 $
*
*/
+#include "config.h"
+
#include <stdlib.h>
-#include <errno.h>
+#ifdef HAVE_ERRNO_H
+# include <errno.h>
+#else
+ static int errno;
+ /* FIXME: anything clever to put here? */
+# define EFAULT 12
+# define ENOTDIR 12
+# define ENOENT 12
+# define ENOMEM 12
+# define EINVAL 12
+#endif
#include <string.h>
-#include <io.h>
-#include <direct.h>
-#include "dirent.h"
+#ifndef UNDER_CE
+# include <io.h>
+# include <direct.h>
+#endif
#define WIN32_LEAN_AND_MEAN
#include <windows.h> /* for GetFileAttributes */
+#include "dirent.h"
+
#define SUFFIX "*"
#define SLASH "\\"
}
/* Make an absolute pathname. */
+#if defined( UNDER_CE )
+ if (szPath[0] == '\\' || szPath[0] == '/')
+ {
+ snprintf (szFullPath, MAX_PATH, "%s", szPath);
+ szFullPath[0] = '\\';
+ }
+ else
+ {
+ snprintf (szFullPath, MAX_PATH, "\\%s", szPath );
+ }
+#else
_fullpath (szFullPath, szPath, MAX_PATH);
+#endif
/* Allocate enough space to store DIR structure and the complete
* directory path given. */
strcat (nd->dd_name, SUFFIX);
/* Initialize handle to -1 so that a premature closedir doesn't try
- * to call _findclose on it. */
+ * to call FindClose on it. */
nd->dd_handle = -1;
/* Initialize the status. */
nd->dd_dir.d_ino = 0;
nd->dd_dir.d_reclen = 0;
nd->dd_dir.d_namlen = 0;
- nd->dd_dir.d_name = nd->dd_dta.name;
+ nd->dd_dir.d_name = nd->dd_dta.cFileName;
return nd;
}
return (struct dirent *) 0;
}
- if (dirp->dd_dir.d_name != dirp->dd_dta.name)
+ if (dirp->dd_dir.d_name != dirp->dd_dta.cFileName)
{
/* The structure does not seem to be set up correctly. */
errno = EINVAL;
{
/* We haven't started the search yet. */
/* Start the search */
- dirp->dd_handle = _findfirst (dirp->dd_name, &(dirp->dd_dta));
+ dirp->dd_handle = FindFirstFile (dirp->dd_name, &(dirp->dd_dta));
if (dirp->dd_handle == -1)
{
else
{
/* Get the next search entry. */
- if (_findnext (dirp->dd_handle, &(dirp->dd_dta)))
+ if (FindNextFile (dirp->dd_handle, &(dirp->dd_dta)))
{
/* We are off the end or otherwise error. */
- _findclose (dirp->dd_handle);
+ FindClose (dirp->dd_handle);
dirp->dd_handle = -1;
dirp->dd_stat = -1;
}
if (dirp->dd_handle != -1)
{
- rc = _findclose (dirp->dd_handle);
+ rc = FindClose (dirp->dd_handle);
}
/* Delete the dir structure. */
if (dirp->dd_handle != -1)
{
- _findclose (dirp->dd_handle);
+ FindClose (dirp->dd_handle);
}
dirp->dd_handle = -1;
/* Seek past end. */
if (dirp->dd_handle != -1)
{
- _findclose (dirp->dd_handle);
+ FindClose (dirp->dd_handle);
}
dirp->dd_handle = -1;
dirp->dd_stat = -1;