I'm Joe Angel. I like coding and interesting in designing and developing API. So, There are something about programming and tool articles. Also, Some daily will be here!
2012年9月13日 星期四
get file basename
Two ways for getting base name frome file path.
/* way 1by Rifur */
static const char * _get_file_baseName(const char *str, int len)
{
for( ; str[len-1] != '/' && len > 0; --len );
return &str[len];
}
/* way 2 */
static const char * gnu_basename(const char *path)
{
const char *base = strrchr(path, '/');
return base ? base+1 : path;
}
訂閱:
張貼留言 (Atom)
沒有留言:
張貼留言