Fix UCS-2 to UTF-8 conversion in the Windows watchers implementation.

This commit is contained in:
Sönke Ludwig 2018-09-04 10:42:08 +02:00
parent 87fb595aee
commit 8495d7d91c

View file

@ -109,6 +109,7 @@ final class WinAPIEventDriverWatchers : EventDriverWatchers {
private static nothrow private static nothrow
void onIOCompleted(DWORD dwError, DWORD cbTransferred, OVERLAPPED_CORE* overlapped) void onIOCompleted(DWORD dwError, DWORD cbTransferred, OVERLAPPED_CORE* overlapped)
{ {
import std.algorithm.iteration : map;
import std.conv : to; import std.conv : to;
import std.file : isDir; import std.file : isDir;
import std.path : dirName, baseName, buildPath; import std.path : dirName, baseName, buildPath;
@ -155,7 +156,7 @@ final class WinAPIEventDriverWatchers : EventDriverWatchers {
} }
ch.baseDirectory = slot.directory; ch.baseDirectory = slot.directory;
auto path = () @trusted { scope (failure) assert(false); return to!string(fni.FileName[0 .. fni.FileNameLength/2]); } (); auto path = () @trusted { try return fni.FileName[0 .. fni.FileNameLength/2].map!(ch => dchar(ch)).to!string; catch (Exception e) assert(false, e.msg); } ();
auto fullpath = buildPath(slot.directory, path); auto fullpath = buildPath(slot.directory, path);
ch.directory = dirName(path); ch.directory = dirName(path);
if (ch.directory == ".") ch.directory = ""; if (ch.directory == ".") ch.directory = "";