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


C++ gcRefPtr::overridePath方法代码示例

本文整理汇总了C++中gcRefPtr::overridePath方法的典型用法代码示例。如果您正苦于以下问题:C++ gcRefPtr::overridePath方法的具体用法?C++ gcRefPtr::overridePath怎么用?C++ gcRefPtr::overridePath使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在gcRefPtr的用法示例。


在下文中一共展示了gcRefPtr::overridePath方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: installTool

gcException IPCToolMain::installTool(gcRefPtr<UserCore::ToolInfo> info)
{
	gcString exe(info->getExe());
	gcString args(info->getArgs());

	if (!UTIL::FS::isValidFile(exe.c_str()))
		return gcException(ERR_INVALIDFILE);

	if (exe.size() > 0 && args == "GAME_LIBRARY")
	{
		size_t pos = exe.find_last_of(".bz2");

		if (pos == (exe.size()-1))
		{
			UTIL::FS::Path pd(exe.c_str(), "", true);
			pd += UTIL::FS::File(info->getName());

			gcString dest = pd.getFullPath();
			uint64 size = UTIL::FS::getFileSize(exe.c_str());

			try
			{
				UTIL::FS::FileHandle srcFh(exe.c_str(), UTIL::FS::FILE_READ);
				UTIL::FS::FileHandle destFh(dest.c_str(), UTIL::FS::FILE_WRITE);

				UTIL::MISC::BZ2Worker bz2(UTIL::MISC::BZ2_DECOMPRESS);

				srcFh.read(size, [&bz2, &destFh](const unsigned char* buff, uint32 size) -> bool
				{
					UTIL::FS::FileHandle *pDest = &destFh;

					bz2.write((const char*)buff, size, [&pDest](const unsigned char* buff, uint32 size) -> bool
					{
						pDest->write((const char*)buff, size);
						return false;
					});

					return false;
				});
			}
			catch (gcException &e)
			{
				return e;
			}

			info->overridePath(dest.c_str());
			UTIL::FS::delFile(exe.c_str());	
		}
		else
		{
			info->overridePath(exe.c_str());
		}
	}
	else if (args.find("PRECHECK_") == 0)
	{
		info->setInstalled();
	}
	else
	{
		return gcException(ERR_TOOLINSTALL, gcString("Un-supported tool install [{0}]", info->getName()));
	}

	return gcException(ERR_COMPLETED);
}
开发者ID:EasyCoding,项目名称:desura-app,代码行数:64,代码来源:ToolInstallThread_nix.cpp


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