Win32: Make the dirent implementation pluggable
commiteecc236696f60bf950f33e603829dfa4926ae1a2
authorKarsten Blees <blees@dcon.de>
Sun, 8 Sep 2013 12:18:40 +0000 (8 14:18 +0200)
committerJohannes Schindelin <johannes.schindelin@gmx.de>
Mon, 17 Feb 2014 18:39:25 +0000 (17 12:39 -0600)
tree8b59f446a1aa9cb40f5cb761b6f75f30066e1ad2
parent38007080a9c62c6c6ea0fa0e82805320170120a5
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