Avoid calling stat() after readdir() on Windows as we already have what we want

This commit is contained in:
Jean-Francois Dockes
2016-01-07 18:47:13 +01:00
parent edb13a64ef
commit 0974abc6c2
4 changed files with 35 additions and 3 deletions
+6
View File
@@ -103,7 +103,13 @@ struct dirent *readdir(DIR *dir)
if(!dir->result.d_name || _findnext(dir->handle, &dir->info) != -1)
{
result = &dir->result;
result->d_mtime = dir->info.time_write;
result->d_size = dir->info.size;
result->d_name = dir->info.name;
if (dir->info.attrib & _A_SUBDIR)
result->d_mode = S_IFDIR;
else
result->d_mode = S_IFREG;
}
}
else
+6
View File
@@ -21,6 +21,12 @@ typedef struct DIR DIR;
struct dirent
{
char *d_name;
// The native call we use, findfirst/next return file attributes at once,
// no need for a separate stat() call in most cases
// Note that ctime is actually creation time. No use for posix.
time_t d_mtime;
off_t d_size;
int d_mode; // S_IFREG or S_IFDIR only
};
DIR *opendir(const char *);