本文整理汇总了C++中path::get_base方法的典型用法代码示例。如果您正苦于以下问题:C++ path::get_base方法的具体用法?C++ path::get_base怎么用?C++ path::get_base使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类path
的用法示例。
在下文中一共展示了path::get_base方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: bases
// ==================================================================================================
bool c4s::generate_next_base(path &target, const char *wild)
/*! Searches the directory (or cwd if dir part is empty) with given wild card. Then determines the next
possible unique filename and stores it to the base part. Please note that only one wild card '*' is
accepted.
\param wild A search string.
\retval bool True on succes, false on error or too many wild cards.
*/
{
const char *pos;
char next[128], *tail, *ptr, *tail_copy;
if(!strchr(wild,'*'))
return false;
// Search files based on wild
path_list bases(target,wild);
if(bases.size()==0) {
string base = target.get_base();
if(base.empty())
target.set_base("fil_001");
base=wild;
size_t ap = base.find('*');
if(ap==string::npos)
return false;
base.replace(ap,1,"001");
target.set_base(base);
return true;
}
// Get the last one
bases.sort(path_list::ST_PARTIAL);
path last = bases.back();
strcpy(next, last.get_base().c_str());
ptr = next;
// Find the 'wild' part
for(pos=wild; *pos && *pos!='*'; pos++)
ptr++;
tail = strstr(ptr,pos+1);
if(!tail)
tail = next + strlen(next) ;
tail_copy = tail;
tail--;
// Start calculating from the back.
while(tail>=ptr) {
(*tail)++;
if(*tail==0x3A) {
*tail=0x30;
tail--;
}
else if(*tail==0x5B) {
*tail=0x41;
tail--;
}
else if(*tail==0x7B) {
*tail=0x61;
tail--;
}
else
break;
}
if(tail<ptr) {
memcpy(tail_copy+1, tail_copy, tail_copy-next-1);
*tail_copy = 0x30;
}
target.set_base(next);
return true;
}