本文整理汇总了C++中WideString::find_last_of方法的典型用法代码示例。如果您正苦于以下问题:C++ WideString::find_last_of方法的具体用法?C++ WideString::find_last_of怎么用?C++ WideString::find_last_of使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类WideString
的用法示例。
在下文中一共展示了WideString::find_last_of方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: createDirectoryRecursive
//--------------------------------
bool Utils::createDirectoryRecursive( const WideString &pathString )
{
if (pathString.length() == 0)
return false;
WideString path = pathString;
if (path[path.length()-1] != '/' && path[path.length()-1] != '\\')
path.push_back('\\');
std::list<WideString> paths;
size_t offset = WideString::npos;
while ((offset != 0) && (offset = pathString.find_last_of(L"/\\", offset)) != WideString::npos)
{
paths.push_front(pathString.substr(0, offset + 1));
if (offset != 0) --offset;
}
bool pathExists = true;
const wchar_t* currentPath = _wgetcwd(0, 0);
for (std::list<WideString>::const_iterator iPath = paths.begin(); iPath != paths.end(); ++iPath)
{
// if path exists
if (_wchdir((*iPath).c_str()) == 0)
continue;
// path does not exist, try to create it
_wmkdir((*iPath).c_str());
if (_wchdir((*iPath).c_str()) != 0)
{
pathExists = false;
break;
}
}
// Restore current path
_wchdir(currentPath);
return pathExists;
}