Skip to content

Commit f9a3ac1

Browse files
kbleesdscho
authored andcommitted
Win32: make the lstat implementation pluggable
Emulating the POSIX lstat API on Windows via GetFileAttributes[Ex] is quite slow. Windows operating system APIs seem to be much better at scanning the status of entire directories than checking single files. A caching implementation may improve performance by bulk-reading entire directories or reusing data obtained via opendir / readdir. Make the lstat implementation pluggable so that it can be switched at runtime, e.g. based on a config option. Signed-off-by: Karsten Blees <blees@dcon.de> Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
1 parent 7cc868e commit f9a3ac1

File tree

2 files changed

+3
-1
lines changed

2 files changed

+3
-1
lines changed

compat/mingw.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -745,6 +745,8 @@ static int do_stat_internal(int follow, const char *file_name, struct stat *buf)
745745
return do_lstat(follow, alt_name, buf);
746746
}
747747

748+
int (*lstat)(const char *file_name, struct stat *buf) = mingw_lstat;
749+
748750
static int get_file_info_by_handle(HANDLE hnd, struct stat *buf)
749751
{
750752
BY_HANDLE_FILE_INFORMATION fdata;

compat/mingw.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -419,7 +419,7 @@ int mingw_fstat(int fd, struct stat *buf);
419419
#ifdef lstat
420420
#undef lstat
421421
#endif
422-
#define lstat mingw_lstat
422+
extern int (*lstat)(const char *file_name, struct stat *buf);
423423

424424

425425
int mingw_utime(const char *file_name, const struct utimbuf *times);

0 commit comments

Comments
 (0)