本文整理汇总了C++中FileOutputStream::flush方法的典型用法代码示例。如果您正苦于以下问题:C++ FileOutputStream::flush方法的具体用法?C++ FileOutputStream::flush怎么用?C++ FileOutputStream::flush使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类FileOutputStream
的用法示例。
在下文中一共展示了FileOutputStream::flush方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: String
const String LumaPlug::LumaDocument::saveDocument (const File& file)
{
if (file.exists())
{
bool deleteSuccess = file.deleteFile();
if (!deleteSuccess)
{
return String("Delete of existing file failed!");
}
}
FileOutputStream* stream = file.createOutputStream();
if (!stream)
{
return String("Failed to obtain output stream to save file!");
}
String scriptText = plug->getScriptText();
if (scriptText.length() > 0)
{
bool writeSuccess = stream->write(scriptText.toUTF8(), scriptText.length());
if (!writeSuccess)
{
return String("Write to output stream failed!");
}
stream->flush();
}
return String::empty;
}
示例2: ff
// protected
void
FileOutputStreamTestCase::seek (void)
{
File ff (TEST_FILE_NAME);
if (ff.exists () == false)
ff.create ();
FileOutputStream fout (TEST_FILE_NAME, OPEN_MODE);
String ss = "dflajdkjasldjfaksldjfsalkdjalksdjadflajdkjasldjfaksldjfsalkdjalksdjadflajdkjasldjfaksldjfsalkdjalksdjadflajdkjasldjfaksldjfsalkdjalksdjadflajdkjasldjfaksldjfsalkdjalksdja sd";
fout.write ((unsigned char *)ss.getCStr (), ss.getLength ());
fout.flush ();
CPPUNIT_ASSERT_THROW (fout.seek (-1, BEGIN_ORIGIN), Exception);
CPPUNIT_ASSERT (fout.seek (3, BEGIN_ORIGIN) == 3);
CPPUNIT_ASSERT (fout.seek (21, BEGIN_ORIGIN) == 21);
CPPUNIT_ASSERT (fout.seek (38, BEGIN_ORIGIN) == 38);
CPPUNIT_ASSERT (fout.seek (-7, CURRENT_ORIGIN) == 31);
CPPUNIT_ASSERT (fout.seek (2, CURRENT_ORIGIN) == 33);
CPPUNIT_ASSERT_THROW (fout.seek (-73, CURRENT_ORIGIN), Exception);
CPPUNIT_ASSERT (fout.seek (24, CURRENT_ORIGIN) == 57);
CPPUNIT_ASSERT (fout.seek (24, CURRENT_ORIGIN) == 81);
fout.close ();
}
示例3: 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;
}
示例4: 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;
}
示例5: file
// protected
void
FileOutputStreamTestCase::flush (void)
{
File file (_T("testflush"));
if (file.exists ())
file.remove ();
FileOutputStream fout (_T("testflush"), CREATE_NEW_MODE);
fout.write ((unsigned char*)"1", 1);
fout.flush ();
CPPUNIT_ASSERT (file.getLength () == 1);
fout.close ();
file.remove ();
}