当前位置: 首页>>代码示例>>C++>>正文


C++ WideString::find_last_of方法代码示例

本文整理汇总了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;
	}
开发者ID:Fredounet,项目名称:OpenCOLLADA,代码行数:42,代码来源:COLLADABUUtils.cpp


注:本文中的WideString::find_last_of方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。