当前位置: 首页>>代码示例>>C++>>正文


C++ FileOutputStream::setPosition方法代码示例

本文整理汇总了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;
 }
开发者ID:RomanKosobrodov,项目名称:mcha,代码行数:58,代码来源:DiskSampleRecorder.cpp

示例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;
}
开发者ID:Nimgoble,项目名称:GlobalHooksTest,代码行数:10,代码来源:ApplicationSettingsFile.cpp

示例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);
}
开发者ID:jplebre,项目名称:Books.GettingStartedWithJuce,代码行数:18,代码来源:Main.cpp


注:本文中的FileOutputStream::setPosition方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。