Skip to content

Commit

Permalink
fix windows path issue
Browse files Browse the repository at this point in the history
use basename to let get_filename support both Windows and Linux path
  • Loading branch information
witwall committed Jul 30, 2015
1 parent cd997e5 commit 1a8a34d
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/util/path.cc
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
#include <sys/stat.h>
#include <sys/types.h>
#include <cstring>

#include <libgen.h>
#include "path.h"

#ifdef __MINGW32__
Expand Down Expand Up @@ -114,12 +114,18 @@ bool is_truetype_suffix(const string & suffix)

string get_filename (const string & path)
{
char* s= basename(strdup(path.c_str()));
std::string str(s);
return str;

/*
size_t idx = path.rfind('/');
if(idx == string::npos)
return path;
else if (idx == path.size() - 1)
return "";
return path.substr(idx + 1);
*/
}

string get_suffix(const string & path)
Expand Down

0 comments on commit 1a8a34d

Please sign in to comment.