17 #define strdup _strdup 18 #define strlwr _strlwr 21 #include <sys/types.h> 35 #define WIN32_LEAN_AND_MEAN 38 #define FILE_NAME_E cFileName 39 #define OS_CloseFH(a) FindClose (a) 40 #define FIND_BUFFER WIN32_FIND_DATA 41 #define DISABLE_HARD_ERRORS SetErrorMode (0) 42 #define ENABLE_HARD_ERRORS SetErrorMode (SEM_FAILCRITICALERRORS | \ 43 SEM_NOOPENFILEERRORBOX); 45 # define ERROR_EMPTY_DIR ERROR_FILE_NOT_FOUND 47 # define ATTRIBUTES (_A_SUBDIR | _A_HIDDEN | _A_SYSTEM | \ 48 _A_NORMAL | _A_RDONLY | _A_ARCH) 59 # define S_IFMT 0xf000 63 # define S_ISDIR(m) ((((m) & S_IFMT) == S_IFDIR)) 98 if ((nbuf = malloc (len + 5)) == (
char *)NULL)
102 last = &nbuf[len - 1];
114 if (((*last ==
'\\') || (*last ==
'/')) && (len > 1) &&
115 (!((len == 3) && (
name[1] ==
':'))))
121 rc = stat (nbuf, &statb);
137 if ((dirp = (
DIR *) malloc (
sizeof (
DIR))) == (
DIR *) NULL)
145 if ((*last !=
'\\') && (*last !=
'/'))
148 strcat (last,
"*.*");
155 dirp->dd_cp = (
DIRCONT *) NULL;
160 d_handle = FindFirstFile (nbuf, &dtabuf);
161 rc = (d_handle == INVALID_HANDLE_VALUE) ? GetLastError () : 0;
173 #if defined (ERROR_EMPTY_DIR) 187 ((dp->
_d_entry = strdup (dtabuf.FILE_NAME_E)) == (
char *) NULL))
202 if (dirp->dd_contents != (
DIRCONT *) NULL)
203 dirp->dd_cp = dirp->dd_cp->_d_next = dp;
206 dirp->dd_contents = dirp->dd_cp = dp;
210 }
while (FindNextFile (d_handle, &dtabuf));
212 dirp->dd_cp = dirp->dd_contents;
228 if (dirp != (
DIR *)NULL)
248 return (
struct dirent *) NULL;
281 if ((dirp == (
DIR *)NULL) || (off < 0L))
288 dirp->
dd_loc = off - (i + 1);
300 return (dirp == (
DIR *)NULL) ? (off_t) -1 : dirp->
dd_loc;
313 while ((odp = dp) != (
DIRCONT *)NULL)
337 char szCurDir [MAX_PATH];
339 if (isalpha (directory[0]) && (directory[1] ==
':'))
340 nDrive = toupper (directory[0]) -
'@';
344 GetCurrentDirectory (MAX_PATH, szCurDir);
345 nDrive = szCurDir[0] -
'A' + 1;
350 strcpy (bName,
"x:\\");
351 bName[0] = (char) (nDrive +
'@');
357 rc = GetVolumeInformation (bName, (LPTSTR)NULL, 0, (LPDWORD)NULL,
358 &maxname, &flags, (LPTSTR)NULL, 0);
361 return ((rc) && (flags & (FS_CASE_SENSITIVE | FS_CASE_IS_PRESERVED)))
struct _dircontents * _d_next
#define ENABLE_HARD_ERRORS
struct _dircontents * dd_contents
void rewinddir(DIR *dirp)
bool IsHPFSFileSystem(char *directory)
void seekdir(DIR *dirp, off_t off)
struct dirent * readdir(DIR *dirp)
HDFFCLIBAPI intf intf * flags
struct _dircontents * dd_cp
#define DISABLE_HARD_ERRORS
DIR * opendir(char *name) const
static void free_dircontents(DIRCONT *)