本文整理汇总了C++中FileStream::flush方法的典型用法代码示例。如果您正苦于以下问题:C++ FileStream::flush方法的具体用法?C++ FileStream::flush怎么用?C++ FileStream::flush使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类FileStream
的用法示例。
在下文中一共展示了FileStream::flush方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: write
void write(LogMessageType type, const char* msg, ...)
{
#if XL_LOGGING_ENABLED || XL_DEBUG_OUT_ENABLED
assert(type < LOG_COUNT);
//first build up the string.
va_list arg;
va_start(arg, msg);
vsprintf(s_tmpBuffer, msg, arg);
va_end(arg);
#endif
#if XL_LOGGING_ENABLED
sprintf(s_printString, "%s%s\r\n", c_logMsgType[type], s_tmpBuffer);
const size_t len = strlen(s_printString);
s_logFile.write(s_printString, (u32)len);
s_logFile.flush(); //flush to disk in case of a crash.
#endif
#if XL_DEBUG_OUT_ENABLED
sprintf(s_printString, "%s%s\n", c_logMsgType[type], s_tmpBuffer);
debugMessage(s_printString);
#endif
}
示例2: storeModule
bool storeModule( Options& options, Module* mod )
{
// this is the base path for the module
Path modPath( mod->path() );
Path tgtPath;
tgtPath.setFullLocation( options.m_sTargetDir );
// normalize module path
while( modPath.getFullLocation().startsWith("./") )
{
modPath.setFullLocation( modPath.getFullLocation().subString(2) );
}
message( String("Processing module ").A( modPath.get() ) );
// strip the main script path from the module path.
String modloc = modPath.getFullLocation();
if ( modloc.find( options.m_sMainScriptPath ) == 0 )
{
// The thing came from below the main script.
modloc = modloc.subString(options.m_sMainScriptPath.length() );
if ( modloc != "" && modloc.getCharAt(0) == '/' )
{
modloc = modloc.subString(1);
}
tgtPath.setFullLocation( tgtPath.get() + "/" + modloc );
}
else
{
// if it's coming from somewhere else in the loadpath hierarcy,
// we must store it below the topmost dir.
tgtPath.setFullLocation( tgtPath.get() + "/" + options.m_sSystemRoot );
// Find the path in LoadPath that caused this module to load,
// strip it away and reproduce it below the SystemRoot.
// For example, strip /usr/lib/falcon/ from system scripts.
std::vector<String> paths;
splitPaths( options.m_sLoadPath, paths );
for( uint32 i = 0; i < paths.size(); ++i )
{
if( modloc.startsWith( paths[i] ) )
{
String sSysPath = modloc.subString( paths[i].size() + 1 );
if( sSysPath != "" )
{
tgtPath.setFullLocation( tgtPath.get() + "/" + sSysPath );
}
break;
}
}
}
// store it
int fsStatus;
if ( ! Sys::fal_mkdir( tgtPath.getFullLocation(), fsStatus, true ) )
{
error( String("Can't create ") + tgtPath.getFullLocation() );
return false;
}
tgtPath.setFilename( modPath.getFilename() );
// should we store just sources, just fam or both?
if( modPath.getExtension() != "fam" && modPath.getExtension() != DllLoader::dllExt() )
{
// it's a source file.
if ( ! options.m_bStripSources )
{
if( ! copyFile( modPath.get(), tgtPath.get() ) )
{
error( String("Can't copy \"") + modPath.get() + "\" into \"" +
tgtPath.get() + "\"" );
return false;
}
}
// should we save the fam?
if( options.m_bStripSources || options.m_bPackFam )
{
tgtPath.setExtension("fam");
FileStream famFile;
if ( ! famFile.create( tgtPath.get(), (Falcon::BaseFileStream::t_attributes) 0644 )
|| ! mod->save(&famFile) )
{
error( "Can't create \"" + tgtPath.get() + "\"" );
return false;
}
famFile.flush();
famFile.close();
}
}
else
{
// just blindly copy everything else.
if( ! copyFile( modPath.get(), tgtPath.get() ) )
{
//.........这里部分代码省略.........
示例3: transferSysFiles
bool transferSysFiles( Options &options, bool bJustScript )
{
Path binpath, libpath;
// Under windows, the binary path is usually stored in an envvar.
String envpath;
if ( ! Sys::_getEnv( "FALCON_BIN_PATH", envpath ) || envpath == "" )
envpath = FALCON_DEFAULT_BIN;
binpath.setFullLocation(
options.m_sFalconBinDir != "" ? options.m_sFalconBinDir: envpath );
// copy falcon or falrun
if ( options.m_sRunner != "" )
binpath.setFilename( options.m_sRunner );
else
binpath.setFilename( "falcon.exe" );
// our dlls are in bin, under windows.
libpath.setFullLocation(
options.m_sFalconLibDir != "" ? options.m_sFalconLibDir : envpath );
if ( ! bJustScript )
{
Path tgtpath( options.m_sTargetDir + "/" + options.m_sSystemRoot +"/" );
libpath.setFile( "falcon_engine" );
libpath.setExtension( DllLoader::dllExt() );
tgtpath.setFilename( binpath.getFilename() );
if( ! copyFile( binpath.get(), tgtpath.get() ) )
{
warning( "Can't copy system file \"" + binpath.get()
+ "\" into target path \""+ tgtpath.get()+ "\"" );
// but continue
}
tgtpath.setFilename( libpath.getFilename() );
if( ! copyFile( libpath.get(), tgtpath.get() ) )
{
warning( "Can't copy system file \"" + libpath.get()
+ "\" into target path \""+ tgtpath.get()+ "\"" );
// but continue
}
// and now the visual C runtime, if any
copyRuntime( binpath, tgtpath );
}
// now create the startup script
Path mainScriptPath( options.m_sMainScript );
Path scriptPath( options.m_sTargetDir + "/" + mainScriptPath.getFile() + ".bat" );
message( "Creating startup script \"" + scriptPath.get() + "\"" );
FileStream startScript;
if( ! startScript.create( scriptPath.get(), (BaseFileStream::t_attributes) 0777 ) )
{
error( "Can't create startup script \"" + scriptPath.get() + "\"" );
return false;
}
startScript.writeString(
"@ECHO OFF\r\n"
"set OLD_DIR=%CD%\r\n"
"set target_dir=%~dp0\r\n"
"cd %target_dir%\r\n");
if( bJustScript )
{
startScript.writeString( "\"" + binpath.getFilename() + "\" " );
}
else
{
startScript.writeString( " \""+options.m_sSystemRoot + "\\" + binpath.getFilename() + "\" " );
startScript.writeString( " -L \"" + options.m_sSystemRoot +";.\" " );
}
// we need to discard the extension, so that the runner decides how to run the program.
Path scriptName( options.m_sMainScript );
startScript.writeString( " \"" + scriptName.getFile() +"\" \"%*\"\r\n" );
startScript.writeString( "cd %OLD_DIR%\r\n" );
startScript.flush();
return true;
}