Skip to content
This repository was archived by the owner on Nov 9, 2017. It is now read-only.

Commit 5e96acf

Browse files
kbleeskasal
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]>
1 parent bab7936 commit 5e96acf

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
@@ -518,6 +518,8 @@ static int do_stat_internal(int follow, const char *file_name, struct stat *buf)
518518
return do_lstat(follow, alt_name, buf);
519519
}
520520

521+
int (*lstat)(const char *file_name, struct stat *buf) = mingw_lstat;
522+
521523
int mingw_lstat(const char *file_name, struct stat *buf)
522524
{
523525
return do_stat_internal(0, file_name, buf);

compat/mingw.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -311,7 +311,7 @@ int mingw_fstat(int fd, struct stat *buf);
311311
#ifdef lstat
312312
#undef lstat
313313
#endif
314-
#define lstat mingw_lstat
314+
extern int (*lstat)(const char *file_name, struct stat *buf);
315315

316316
#ifndef _stati64
317317
# define _stati64(x,y) mingw_stat(x,y)

0 commit comments

Comments
 (0)