本文整理汇总了C++中FileOutputStream::openedOk方法的典型用法代码示例。如果您正苦于以下问题:C++ FileOutputStream::openedOk方法的具体用法?C++ FileOutputStream::openedOk怎么用?C++ FileOutputStream::openedOk使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类FileOutputStream
的用法示例。
在下文中一共展示了FileOutputStream::openedOk方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: saveDocument
Result saveDocument (const File& file) override
{
// attempt to save the contents into the given file
FileOutputStream os (file);
if (os.openedOk())
os.writeText (editor.getText(), false, false);
return Result::ok();
}
示例2: 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);
}
示例3: trimFileSize
void FileLogger::trimFileSize (int64 maxFileSizeBytes) const
{
if (maxFileSizeBytes <= 0)
{
logFile.deleteFile();
}
else
{
const int64 fileSize = logFile.getSize();
if (fileSize > maxFileSizeBytes)
{
TemporaryFile tempFile (logFile);
{
FileOutputStream out (tempFile.getFile());
FileInputStream in (logFile);
if (! (out.openedOk() && in.openedOk()))
return;
in.setPosition (fileSize - maxFileSizeBytes);
for (;;)
{
const char c = in.readByte();
if (c == 0)
return;
if (c == '\n' || c == '\r')
{
out << c;
break;
}
}
out.writeFromInputStream (in, -1);
}
tempFile.overwriteTargetFileWithTemporary();
}
}
}