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>
This commit is contained in:
Karsten Blees 2013-09-08 14:21:30 +02:00 коммит произвёл Johannes Schindelin
Родитель 0cbb45fd6d
Коммит 53403b7ba0
2 изменённых файлов: 3 добавлений и 1 удалений

Просмотреть файл

@ -790,6 +790,8 @@ static int do_stat_internal(int follow, const char *file_name, struct stat *buf)
return do_lstat(follow, alt_name, buf); return do_lstat(follow, alt_name, buf);
} }
int (*lstat)(const char *file_name, struct stat *buf) = mingw_lstat;
static int get_file_info_by_handle(HANDLE hnd, struct stat *buf) static int get_file_info_by_handle(HANDLE hnd, struct stat *buf)
{ {
BY_HANDLE_FILE_INFORMATION fdata; BY_HANDLE_FILE_INFORMATION fdata;

Просмотреть файл

@ -410,7 +410,7 @@ int mingw_fstat(int fd, struct stat *buf);
#ifdef lstat #ifdef lstat
#undef lstat #undef lstat
#endif #endif
#define lstat mingw_lstat extern int (*lstat)(const char *file_name, struct stat *buf);
int mingw_utime(const char *file_name, const struct utimbuf *times); int mingw_utime(const char *file_name, const struct utimbuf *times);