Win32: Make the dirent implementation pluggable
commitbab79360dd78c4e1606d08fa0f45b98d9d827733
authorKarsten Blees <blees@dcon.de>
Sun, 8 Sep 2013 12:18:40 +0000 (8 14:18 +0200)
committerStepan Kasal <kasal@ucw.cz>
Thu, 29 May 2014 08:42:33 +0000 (29 10:42 +0200)
treea084398f161273fa379bc647748f3ff31280bdd3
parent12624693a167e2982e1ce1b5a0a2afc1a8ac19f6
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