From 8495d7d91c77a8c4d155183b2184e7f68a9123fd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=B6nke=20Ludwig?= Date: Tue, 4 Sep 2018 10:42:08 +0200 Subject: [PATCH] Fix UCS-2 to UTF-8 conversion in the Windows watchers implementation. --- source/eventcore/drivers/winapi/watchers.d | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/source/eventcore/drivers/winapi/watchers.d b/source/eventcore/drivers/winapi/watchers.d index 2ec45eb..ea6bdb6 100644 --- a/source/eventcore/drivers/winapi/watchers.d +++ b/source/eventcore/drivers/winapi/watchers.d @@ -109,6 +109,7 @@ final class WinAPIEventDriverWatchers : EventDriverWatchers { private static nothrow void onIOCompleted(DWORD dwError, DWORD cbTransferred, OVERLAPPED_CORE* overlapped) { + import std.algorithm.iteration : map; import std.conv : to; import std.file : isDir; import std.path : dirName, baseName, buildPath; @@ -155,7 +156,7 @@ final class WinAPIEventDriverWatchers : EventDriverWatchers { } 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); ch.directory = dirName(path); if (ch.directory == ".") ch.directory = "";