Win32: Make the dirent implementation pluggable
commita7cb32356e92d2f55fba9348a7b174dc0c82df56
authorKarsten Blees <blees@dcon.de>
Sun, 8 Sep 2013 12:18:40 +0000 (8 14:18 +0200)
committerKarsten Blees <blees@dcon.de>
Wed, 18 Dec 2013 19:20:53 +0000 (18 20:20 +0100)
tree75c9e7a6cb8b468ac9548e86c62b1eaf68e11c75
parente2e4a95503f2c76b548c23e5951680a2f3d0f29f
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