mirror of
https://github.com/subsurface/subsurface.git
synced 2024-12-01 06:30:26 +00:00
Files: use the new opendir() wrapper
This is a separate patch because it required more changes and branches due to how opendir() works on win32 with the separate struct type _WDIR and the according _w... methods for it. Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
parent
86ed014339
commit
a351bbde24
1 changed files with 20 additions and 5 deletions
|
@ -139,18 +139,33 @@ static long bytes_available(int file)
|
||||||
static int number_of_file(char *path)
|
static int number_of_file(char *path)
|
||||||
{
|
{
|
||||||
int count = 0;
|
int count = 0;
|
||||||
DIR * dirp;
|
#ifdef WIN32
|
||||||
struct dirent * entry;
|
struct _wdirent *entry;
|
||||||
|
_WDIR *dirp = (_WDIR *)subsurface_opendir(path);
|
||||||
|
#else
|
||||||
|
struct dirent *entry;
|
||||||
|
DIR *dirp = (DIR *)subsurface_opendir(path);
|
||||||
|
#endif
|
||||||
|
|
||||||
dirp = opendir(path);
|
while (dirp) {
|
||||||
while (dirp && (entry = readdir(dirp)) != NULL) {
|
#ifdef WIN32
|
||||||
#ifndef WIN32
|
entry = _wreaddir(dirp);
|
||||||
|
if (!entry)
|
||||||
|
break;
|
||||||
|
#else
|
||||||
|
entry = readdir(dirp);
|
||||||
|
if (!entry)
|
||||||
|
break;
|
||||||
if (entry->d_type == DT_REG) /* If the entry is a regular file */
|
if (entry->d_type == DT_REG) /* If the entry is a regular file */
|
||||||
#endif
|
#endif
|
||||||
count++;
|
count++;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
#ifdef WIN32
|
||||||
|
_wclosedir(dirp);
|
||||||
|
#else
|
||||||
closedir(dirp);
|
closedir(dirp);
|
||||||
|
#endif
|
||||||
return count;
|
return count;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue