summaryrefslogtreecommitdiff
path: root/goo
diff options
context:
space:
mode:
author <greg@midgaarde.localdomain>2019-02-10 16:24:29 -0500
committer <greg@midgaarde.localdomain>2019-02-10 16:24:29 -0500
commit2d1c8327c936600deca28a15230804a448e3f8a2 (patch)
tree80be38a4ad48b1ccb207e8462d739a83a85e6d4b /goo
parent0e7b76ef87378e924e9f715bfe4ff50b8af4a709 (diff)
MSVC build fix: gbasename: basename()/libgen.h don't exist in MSVC-land. Instead, use _splitpath_s.
Diffstat (limited to 'goo')
-rw-r--r--goo/gbasename.cc10
1 files changed, 9 insertions, 1 deletions
diff --git a/goo/gbasename.cc b/goo/gbasename.cc
index dd4607b4..819de885 100644
--- a/goo/gbasename.cc
+++ b/goo/gbasename.cc
@@ -39,13 +39,21 @@
//========================================================================
#include "gbasename.h"
-#include <libgen.h>
+#ifndef _MSC_VER
+# include <libgen.h>
+#endif
#include <string.h>
std::string gbasename(const char* filename)
{
+#ifdef _MSC_VER
+ char fname[_MAX_FNAME] = {}, fext[_MAX_EXT] = {};
+ errno_t z = _splitpath_s(filename, NULL, 0, NULL, 0, fname, _countof(fname), fext, _countof(fext));
+ return std::string(fname) + std::string(fext);
+#else
char* mutabl = strdup(filename);
std::string retu = basename(mutabl);
free(mutabl);
return retu;
+#endif
}