Skip to content

Commit 5228a5a

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 c3fb594 commit 5228a5a

File tree

2 files changed

+3
-1
lines changed

2 files changed

+3
-1
lines changed

Diff for: compat/mingw.c

+2
Original file line numberDiff line numberDiff line change
@@ -1007,6 +1007,8 @@ static int do_stat_internal(int follow, const char *file_name, struct stat *buf)
10071007
return do_lstat(follow, alt_name, buf);
10081008
}
10091009

1010+
int (*lstat)(const char *file_name, struct stat *buf) = mingw_lstat;
1011+
10101012
static int get_file_info_by_handle(HANDLE hnd, struct stat *buf)
10111013
{
10121014
BY_HANDLE_FILE_INFORMATION fdata;

Diff for: compat/mingw.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -427,7 +427,7 @@ int mingw_fstat(int fd, struct stat *buf);
427427
#ifdef lstat
428428
#undef lstat
429429
#endif
430-
#define lstat mingw_lstat
430+
extern int (*lstat)(const char *file_name, struct stat *buf);
431431

432432

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

0 commit comments

Comments
 (0)