//filePath为文件路径,suffix为后缀名
bool AnalyticalDecoder::decideSuffix( char* filePath, char* suffix )
{char* fileExt;
char *ptr, c = '.';
//最后一个出现c的位置
ptr = strrchr(filePath, c);
//用指针相减 求得索引
int pos = ptr-filePath;
//获取后缀
fileExt=substr(filePath,pos+1,strlen(filePath));
//判断后缀是否相同
if (0==strcmp(fileExt,suffix))
return true;
else
return false;
}
//求子串
char* AnalyticalDecoder::substr(const char*str, unsigned start, unsigned end)
{
unsigned n = end - start;
static char stbuf[256];
//复制最后三个字符,即后缀
strncpy(stbuf, str + start, n);
//字串最后加上0
stbuf[n] = 0;
return stbuf;
}