44 #define WIN32_LEAN_AND_MEAN 
   57 opendir(
const CHAR * szPath)
 
   61     CHAR szFullPath[MAX_PATH];
 
   69     if (szPath[0] == 
'\0') {
 
   74     rc = GetFileAttributes(szPath);
 
   75     if (rc == (
unsigned int) -1) {
 
   80     if (!(rc & FILE_ATTRIBUTE_DIRECTORY)) {
 
   86     _fullpath(szFullPath, szPath, MAX_PATH);
 
   90     nd = (DIR *) malloc(
sizeof(DIR) + (strlen(szFullPath)
 
  101     strcpy(nd->dd_name, szFullPath);
 
  104     if (nd->dd_name[0] != 
'\0' 
  105             && strchr(nd->dd_name, 
'/') != nd->dd_name
 
  106             + strlen(nd->dd_name) - 1
 
  107             && strchr(nd->dd_name, 
'\\') != nd->dd_name
 
  108             + strlen(nd->dd_name) - 1) {
 
  109         strcat(nd->dd_name, SLASH);
 
  112     strcat(nd->dd_name, SUFFIX);
 
  124     nd->dd_dir.d_ino = 0;
 
  125     nd->dd_dir.d_reclen = 0;
 
  126     nd->dd_dir.d_namlen = 0;
 
  127     memset(nd->dd_dir.d_name, 0, FILENAME_MAX);
 
  139 readdir(DIR * dirp) {
 
  145         return (
struct dirent *) 0;
 
  147     if (dirp->dd_stat < 0) {
 
  150         return (
struct dirent *) 0;
 
  151     } 
else if (dirp->dd_stat == 0) {
 
  154         dirp->dd_handle = _findfirst(dirp->dd_name, &(dirp->dd_dta));
 
  156         if (dirp->dd_handle == -1) {
 
  165         if (_findnext(dirp->dd_handle, &(dirp->dd_dta))) {
 
  169             DWORD winerr = GetLastError();
 
  170             if (winerr == ERROR_NO_MORE_FILES)
 
  172             _findclose(dirp->dd_handle);
 
  173             dirp->dd_handle = -1;
 
  182     if (dirp->dd_stat > 0) {
 
  186         dirp->dd_dir.d_namlen = strlen(dirp->dd_dta.name);
 
  187         strcpy(dirp->dd_dir.d_name, dirp->dd_dta.name);
 
  188         return &dirp->dd_dir;
 
  190     return (
struct dirent *) 0;
 
  210     if (dirp->dd_handle != -1) {
 
  211         rc = _findclose(dirp->dd_handle);
 
  226 rewinddir(DIR * dirp)
 
  234     if (dirp->dd_handle != -1) {
 
  235         _findclose(dirp->dd_handle);
 
  237     dirp->dd_handle = -1;
 
  256     return dirp->dd_stat;
 
  269 seekdir(DIR * dirp, 
long lPos)
 
  281     } 
else if (lPos == -1) {
 
  283         if (dirp->dd_handle != -1) {
 
  284             _findclose(dirp->dd_handle);
 
  286         dirp->dd_handle = -1;
 
  292         while ((dirp->dd_stat < lPos) && readdir(dirp));