Skip to content

Commit 7132b3b

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 <[email protected]> Signed-off-by: Johannes Schindelin <[email protected]>
1 parent 04a6536 commit 7132b3b

File tree

2 files changed

+3
-1
lines changed

2 files changed

+3
-1
lines changed

compat/mingw-posix.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -409,7 +409,7 @@ int mingw_fstat(int fd, struct stat *buf);
409409
#ifdef lstat
410410
#undef lstat
411411
#endif
412-
#define lstat mingw_lstat
412+
extern int (*lstat)(const char *file_name, struct stat *buf);
413413

414414

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

compat/mingw.c

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

1025+
int (*lstat)(const char *file_name, struct stat *buf) = mingw_lstat;
1026+
10251027
static int get_file_info_by_handle(HANDLE hnd, struct stat *buf)
10261028
{
10271029
BY_HANDLE_FILE_INFORMATION fdata;

0 commit comments

Comments
 (0)