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


C++ CIFile::serialBuffer方法代码示例

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


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

示例1: playSync

/// Play from memory.
bool CMusicChannelFMod::playSync(const std::string &filepath, bool loop)
{
    CIFile ifile;
    ifile.allowBNPCacheFileOnOpen(false);
    ifile.setCacheFileOnOpen(false);
    ifile.open(filepath);

    // try to load the music in memory
    uint32 fs = ifile.getFileSize();
    if (!fs) {
        nlwarning("NLSOUND FMod Driver: Empty music file");
        return false;
    }

    // read Buffer
    nlassert(!_MusicBuffer);
    _MusicBuffer = new uint8[fs];
    try {
        ifile.serialBuffer(_MusicBuffer, fs);
    }
    catch (...)
    {
        nlwarning("NLSOUND FMod Driver: Error while reading music file");
        delete[] _MusicBuffer;
        _MusicBuffer = NULL;
        return false;
    }

    // open FMOD stream
    _MusicStream = FSOUND_Stream_Open((const char*)_MusicBuffer,
                                      FSOUND_2D | FSOUND_LOADMEMORY | (loop ? FSOUND_LOOP_NORMAL : FSOUND_LOOP_OFF), 0, fs);
    if (!_MusicStream)
    {
        nlwarning("NLSOUND FMod Driver: Error while creating the FMOD stream for music file");
        delete[] _MusicBuffer;
        _MusicBuffer = NULL;
        return false;
    }

    if (!playStream())
    {
        nlwarning("NLSOUND FMod Driver: Error While trying to play sync music file");
        FSOUND_Stream_Close(_MusicStream);
        _MusicStream = NULL;
        delete[] _MusicBuffer;
        _MusicBuffer = NULL;
        return false;
    }

    return true;
}
开发者ID:Darkhunter,项目名称:Tranquillien-HCRP-Project-using-NeL,代码行数:52,代码来源:music_channel_fmod.cpp

示例2: strncmp

void	CMailForumService::checkFile(const std::string& file)
{
	uint	fsz = CFile::getFileSize(file);

	if (fsz == 0)
		return;

	vector<uint8>	buffer(fsz);

	CIFile	fi;
	if (!fi.open(file))
		return;

	fi.serialBuffer(&(buffer[0]), fsz);
	fi.close();

	char*	pb = (char*)(&(buffer[0]));
	char*	pt = pb;

	while (*pt != '\0' && strncmp(pt, "$$$$", 4))
		++pt;

	// file contents "$$$$" -> end of file marker, file is complete, can be deleted
	if (pt != '\0')
	{
		CFile::deleteFile(file);

		int		shard_id;
		char	to_username[256];
		char	from_username[256];

		int		scanned = sscanf(pb, "shard=%d to=%s from=%s", &shard_id, to_username, from_username);

		CMessage	msgout("MAIL_NOTIF");

		uint32	shardId = (uint32)shard_id;
		string	toUserName = to_username;
		string	fromUserName = from_username;

		nldebug("MAIL: sent notification for user '%s' on shard '%d'", toUserName.c_str(), shardId);

		msgout.serial(shardId, toUserName, fromUserName);

		CUnifiedNetwork::getInstance()->send("EGS", msgout);
	}
}
开发者ID:sythaeryn,项目名称:pndrpg,代码行数:46,代码来源:mail_forum_service.cpp

示例3: executeFile

// ***************************************************************************
bool CLuaState::executeFile(const std::string &pathName)
{
	//H_AUTO(Lua_CLuaState_executeFile)

	CIFile	inputFile;
	if(!inputFile.open(pathName))
		return false;

	#ifdef LUA_NEVRAX_VERSION
		if (LuaDebuggerIDE)
		{
			std::string path = NLMISC::CPath::getCurrentPath() + "/" + pathName.c_str();
			path = CPath::standardizeDosPath(path);
			LuaDebuggerIDE->addFile(path.c_str());
		}
	#endif

	// load the script text
	string	script;
	/*
	while(!inputFile.eof())
	{
		char	tmpBuff[5000];
		inputFile.getline(tmpBuff,   5000);
		script+= tmpBuff;
		script+= "\n";
	}
	*/
	script.resize(CFile::getFileSize(pathName));
	inputFile.serialBuffer((uint8 *) &script[0],  (uint)script.size());


	// execute the script text,   with dbgSrc==filename (use @ for lua internal purpose)
	executeScriptInternal(script,   string("@") + CFile::getFilename(pathName));

	return true;
}
开发者ID:mixxit,项目名称:solinia,代码行数:38,代码来源:lua_helper.cpp


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