[libcxx] Fix the preexisting directory_iterator code for windows
authorMartin Storsjö <martin@martin.st>
Wed, 4 Nov 2020 14:48:00 +0000 (16:48 +0200)
committerMartin Storsjö <martin@martin.st>
Fri, 18 Dec 2020 09:24:53 +0000 (11:24 +0200)
commit156180727d6c347eda3ba749730707acb8a48093
treecbbe48011e2802863af5265822a5574aa98de876
parentde698ae73444b5160dd6b8d768b30d6764be004e
[libcxx] Fix the preexisting directory_iterator code for windows

The directory_iterator.cpp file did contain an incomplete,
non-working implementation for windows.

Change it to use the wchar version of the APIs.

Don't set the windows specific errors from GetLastError() as code
in the generic category; remap the errors to the std::errc values.

Error out cleanly on empty paths.

Invoke FindFirstFile on <directoryname>/* to actually list the
entries of the directory.

If the first entry retured by FindFirstFile is to be skipped (e.g.
being "." or ".."), call advance() (which calls FindNextFile and loops)
which doesn't return until a valid entry is found (or the end is
reached).

Differential Revision: https://reviews.llvm.org/D91140
libcxx/src/filesystem/directory_iterator.cpp
libcxx/src/filesystem/filesystem_common.h
libcxx/src/filesystem/operations.cpp