本文整理汇总了C++中FileOutputStream::setPosition方法的典型用法代码示例。如果您正苦于以下问题:C++ FileOutputStream::setPosition方法的具体用法?C++ FileOutputStream::setPosition怎么用?C++ FileOutputStream::setPosition使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类FileOutputStream
的用法示例。
在下文中一共展示了FileOutputStream::setPosition方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: reserveDiskSpace
// =================================================================================================================
bool DiskSampleRecorder::reserveDiskSpace(String outDir, int64 lengthInBytes)
{
String audioFileName(outDir);
File* tempDataFile;
Time now;
if ( !audioFileName.endsWith(File::separatorString))
audioFileName += File::separatorString;
for (int i=0; i < processorOutputs; i++)
{
now = Time::getCurrentTime();
tempDataFile = new File(audioFileName + "channel" + String::formatted("%.2d", i) + ".dat");
if (*tempDataFile == File::nonexistent)
{
mchaRecordPlayer->logError( L"Failed to reserve disk space for data file:\t" + tempDataFile->getFullPathName() );
delete tempDataFile;
return false;
}
else
{
FileOutputStream* tempStream = tempDataFile->createOutputStream();
if (tempStream == NULL)
{
mchaRecordPlayer->logError( L"Failed to create output stream for data file:\t" + tempDataFile->getFullPathName() );
delete tempStream;
delete tempDataFile;
return false;
}
else
{
if (!tempStream->setPosition(lengthInBytes))
{
mchaRecordPlayer->logError( L"Failed to position output stream for data file:\t" + tempDataFile->getFullPathName() + ". Insufficient disk space?" );
delete tempStream;
delete tempDataFile;
return false;
}
else
{
int zeroByte = 0;
tempStream->write( (void *) &zeroByte, 1);
tempStream->flush();
}
}
RelativeTime timeDelay = Time::getCurrentTime() - now;
mchaRecordPlayer->dbgOut( "\tReserving disk space for\t" + tempDataFile->getFullPathName() + "\t" + String(lengthInBytes) + " bytes\t" + String(timeDelay.inSeconds())+ " s elapsed." );
delete tempStream;
delete tempDataFile;
}
}
return true;
}
示例2: SaveAs
void ApplicationSettingsFile::SaveAs(File file)
{
var json = toJSON();
FileOutputStream *outputStream = file.createOutputStream();
outputStream->setPosition(0);
JSON::writeToStream(*outputStream, json);
outputStream->flush();
delete outputStream;
outputStream = nullptr;
}
示例3: writeFile
void writeFile(File const& file)
{
Logger *log = Logger::getCurrentLogger();
FileOutputStream stream (file);
if(!stream.openedOk())
{
log->writeToLog("failed to open stream");
return;
}
stream.setPosition(0);
stream.truncate();
stream.writeInt(1234);
stream.writeFloat(3.142);
stream.writeDouble(0.00001234);
}