Commit 2d1c8327 authored by 's avatar

MSVC build fix: gbasename: basename()/libgen.h don't exist in MSVC-land. Instead, use _splitpath_s.

parent 0e7b76ef
......@@ -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
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment