Skip to content

Commit 1a8a34d

Browse files
committed
fix windows path issue
use basename to let get_filename support both Windows and Linux path
1 parent cd997e5 commit 1a8a34d

1 file changed

Lines changed: 7 additions & 1 deletion

File tree

src/util/path.cc

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
#include <sys/stat.h>
1010
#include <sys/types.h>
1111
#include <cstring>
12-
12+
#include <libgen.h>
1313
#include "path.h"
1414

1515
#ifdef __MINGW32__
@@ -114,12 +114,18 @@ bool is_truetype_suffix(const string & suffix)
114114

115115
string get_filename (const string & path)
116116
{
117+
char* s= basename(strdup(path.c_str()));
118+
std::string str(s);
119+
return str;
120+
121+
/*
117122
size_t idx = path.rfind('/');
118123
if(idx == string::npos)
119124
return path;
120125
else if (idx == path.size() - 1)
121126
return "";
122127
return path.substr(idx + 1);
128+
*/
123129
}
124130

125131
string get_suffix(const string & path)

0 commit comments

Comments
 (0)