Win32: Make the dirent implementation pluggable
commitd3bba01436e1467df1fb0ceef000780df83a88e1
authorKarsten Blees <blees@dcon.de>
Sun, 8 Sep 2013 12:18:40 +0000 (8 14:18 +0200)
committerKarsten Blees <blees@dcon.de>
Sat, 16 Aug 2014 01:02:46 +0000 (16 03:02 +0200)
treec1133765b49cd1765c7ebd8f1ceaeeb13d89fbf3
parent0b2182045af1f87a496a641b8a244e9d7d723d57
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