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
diff --git a/compat/compat.h.in b/compat/compat.h.in
index 6672fcf..1c19b98 100644
--- a/compat/compat.h.in
+++ b/compat/compat.h.in
@@ -65,6 +65,7 @@
#cmakedefine HAVE_LOCALTIME_R
#cmakedefine HAVE_STRPTIME
#cmakedefine HAVE_MMAP
+#cmakedefine HAVE_DIRNAME
#ifndef bswap64
#define bswap64(val) \
diff --git a/compat/posix-shims/libgen.h b/compat/posix-shims/libgen.h
new file mode 100644
index 0000000..014bb07
--- /dev/null
+++ b/compat/posix-shims/libgen.h
@@ -0,0 +1 @@
+char *dirname(char *path);