MSVC: compat: dirname() from <libgen.h>
diff --git a/compat/compat.c b/compat/compat.c
index ea8eb03..6763413 100644
--- a/compat/compat.c
+++ b/compat/compat.c
@@ -289,3 +289,18 @@
 #error No localtime_r() implementation for this platform is available.
 #endif
 #endif
+
+#ifndef HAVE_DIRNAME
+#ifdef _WIN32
+#include <shlwapi.h>
+char *
+dirname(char *path)
+{
+    PathRemoveFileSpecA(path);
+    return path;
+}
+
+#else
+#error No dirname() implementation for this platform is available.
+#endif
+#endif