MSVC: extract file name from FD
diff --git a/src/in.c b/src/in.c
index 9752eff..c16b1c3 100644
--- a/src/in.c
+++ b/src/in.c
@@ -291,6 +291,14 @@
if (fcntl(in->method.fd, F_GETPATH, path) != -1) {
lydict_insert(ctx, path, 0, filepath);
}
+#elif defined _WIN32
+ HANDLE h = _get_osfhandle(in->method.fd);
+ FILE_NAME_INFO info;
+ if (GetFileInformationByHandleEx(h, FileNameInfo, &info, sizeof info)) {
+ char *buf = calloc(info.FileNameLength + 1 /* trailing NULL */, MB_CUR_MAX);
+ len = wcstombs(buf, info.FileName, info.FileNameLength * MB_CUR_MAX);
+ lydict_insert(ctx, buf, len, filepath);
+ }
#else
/* get URI if there is /proc */
sprintf(proc_path, "/proc/self/fd/%d", in->method.fd);