本文整理汇总了C++中FileStream::getSize方法的典型用法代码示例。如果您正苦于以下问题:C++ FileStream::getSize方法的具体用法?C++ FileStream::getSize怎么用?C++ FileStream::getSize使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类FileStream
的用法示例。
在下文中一共展示了FileStream::getSize方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: init
void init(StartGameFunc startGame, StopGameFunc stopGame)
{
s_startGame = startGame;
s_stopGame = stopGame;
for (u32 s=0; s<SOUND_COUNT; s++)
{
UI_Sound& sound = s_sounds[s];
sound.filename = c_sounds[s];
FileStream file;
if (file.open(sound.filename, FileStream::MODE_READ))
{
sound.size = file.getSize();
sound.data = malloc(sound.size);
file.read((u8*)sound.data, sound.size);
file.close();
}
else
{
sound.filename = NULL;
}
}
UISystem::setMouseOverSound(&s_sounds[SOUND_MOUSEOVER]);
}
示例2: readIni
bool readIni(const char* filename, ReadIniCallback callback, bool liberal)
{
if (!callback)
{
return false;
}
bool res = false;
FileStream file;
if ( file.open(filename, FileStream::MODE_READ) )
{
size_t size = file.getSize();
char* fileData = new char[size+1];
if (fileData)
{
file.read(fileData, (u32)size);
res = true;
}
file.close();
if (res)
{
const char* fileEnd = &fileData[size];
char* readPos = fileData;
//now read the data.
while (1)
{
char keyName[512], keyValue[512];
//we are done here.
if (!getKey(&readPos, keyName, fileEnd))
{
break;
}
if (!readValue(&readPos, keyValue, fileEnd, liberal))
{
break;
}
//remove preceding or trailing spaces, remove exterior quotation marks.
fixupString(keyName);
fixupString(keyValue);
res &= callback(keyName, keyValue);
};
}
delete [] fileData;
}
return res;
}