Win32: Make the dirent implementation pluggable
commit3d76202fc538be55b08498ab61a6c4508fe10f28
authorKarsten Blees <blees@dcon.de>
Sun, 8 Sep 2013 12:18:40 +0000 (8 14:18 +0200)
committerJohannes Schindelin <johannes.schindelin@gmx.de>
Sat, 10 May 2014 21:56:56 +0000 (10 16:56 -0500)
treebc40e3e920086acca97dd6207c1cd2019f22fd7a
parent659686eaed2d9701a59fbbc3b66d3e57d150ccd0
Win32: Make the dirent implementation pluggable

Emulating the POSIX dirent API on Windows via FindFirstFile/FindNextFile is
pretty staightforward, however, most of the information provided in the
WIN32_FIND_DATA structure is thrown away in the process. A more
sophisticated implementation may cache this data, e.g. for later reuse in
calls to lstat.

Make the dirent implementation pluggable so that it can be switched at
runtime, e.g. based on a config option.

Define a base DIR structure with pointers to readdir/closedir that match
the opendir implementation (i.e. similar to vtable pointers in OOP).
Define readdir/closedir so that they call the function pointers in the DIR
structure. This allows to choose the opendir implementation on a
call-by-call basis.

Move the fixed sized dirent.d_name buffer to the dirent-specific DIR
structure, as d_name may be implementation specific (e.g. a caching
implementation may just set d_name to point into the cache instead of
copying the entire file name string).

Signed-off-by: Karsten Blees <blees@dcon.de>
compat/win32/dirent.c
compat/win32/dirent.h