本文整理汇总了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;
}
示例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);
}
}
示例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;
}