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


C++ FileStream::Write方法代码示例

本文整理汇总了C++中FileStream::Write方法的典型用法代码示例。如果您正苦于以下问题:C++ FileStream::Write方法的具体用法?C++ FileStream::Write怎么用?C++ FileStream::Write使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在FileStream的用法示例。


在下文中一共展示了FileStream::Write方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: Save

// Save
//------------------------------------------------------------------------------
void Report::Save() const
{
	FileStream f;
	if ( f.Open( "report.html", FileStream::WRITE_ONLY ) )
	{
		f.Write( m_Output.Get(), m_Output.GetLength() );
	}
}
开发者ID:hilbertdu,项目名称:fastbuild,代码行数:10,代码来源:Report.cpp

示例2: GetCacheFileName

// Publish
//------------------------------------------------------------------------------
/*virtual*/ bool Cache::Publish( const AString & cacheId, const void * data, size_t dataSize )
{
    AStackString<> cacheFileName;
    GetCacheFileName( cacheId, cacheFileName );

    // make sure the cache output path exists
    char * lastSlash = cacheFileName.FindLast( NATIVE_SLASH );
    *lastSlash = 0;
    if ( !FileIO::EnsurePathExists( cacheFileName ) )
    {
        return false;
    }
    *lastSlash = NATIVE_SLASH;

    // open output cache (tmp) file
    AStackString<> cacheFileTmpName( cacheFileName );
    cacheFileTmpName += ".tmp";
    FileStream cacheTmpFile;
    if( !cacheTmpFile.Open( cacheFileTmpName.Get(), FileStream::WRITE_ONLY ) )
    {
        return false;
    }

    // write data
    bool cacheTmpWriteOk = ( cacheTmpFile.Write( data, dataSize ) == dataSize );
    cacheTmpFile.Close();

    if ( !cacheTmpWriteOk )
    {
        // failed to write to cache tmp file
        FileIO::FileDelete( cacheFileTmpName.Get() ); // try to cleanup failure
        return false;
    }

    // rename tmp file to real file
    if ( FileIO::FileMove( cacheFileTmpName, cacheFileName ) == false )
    {
        // try to delete (possibly) existing file
        FileIO::FileDelete( cacheFileName.Get() );

        // try rename again
        if ( FileIO::FileMove( cacheFileTmpName, cacheFileName ) == false )
        {
            // problem renaming file
            FileIO::FileDelete( cacheFileTmpName.Get() ); // try to cleanup tmp file
            return false;
        }
    }

    return true;
}
开发者ID:dontnod,项目名称:fastbuild,代码行数:53,代码来源:Cache.cpp

示例3: Save

// Save
//------------------------------------------------------------------------------
void WorkerSettings::Save()
{
    AStackString<> settingsPath;
    Env::GetExePath( settingsPath );
    settingsPath += ".settings";

    FileStream f;
    if ( f.Open( settingsPath.Get(), FileStream::WRITE_ONLY ) )
    {
        bool ok = true;

        // header
        ok &= ( f.Write( "FWS", 3 ) == 3 );
        ok &= ( f.Write( uint8_t( FBUILDWORKER_SETTINGS_CURRENT_VERSION ) ) == 1 );

        // settings
        ok &= f.Write( (uint32_t)m_Mode );
        ok &= f.Write( m_NumCPUsToUse );
        ok &= f.Write( m_StartMinimized );

        if ( ok )
        {
            return;
        }
    }

    #if defined( __WINDOWS__ )
        MessageBox( nullptr, "Failed to save settings.", "FBuildWorker", MB_OK );
    #elif defined( __APPLE__ )
        // TODO:MAC Implement ShowMessageBox
    #elif defined( __LINUX__ )
        // TODO:LINUX Implement ShowMessageBox
    #else
        #error Unknown Platform
    #endif
}
开发者ID:dontnod,项目名称:fastbuild,代码行数:38,代码来源:WorkerSettings.cpp

示例4: xml_in

Reflect::ObjectPtr Helium::Cache::ReadCacheObjectFromBuffer( const uint8_t *_buffer, const size_t _offset, const size_t _count )
{
    if (_count == 0)
    {
        Reflect::ObjectPtr null_object;
        return null_object;
    }

    Reflect::ObjectPtr cached_object;

#if USE_XML_FOR_CACHE_DATA
    {
        tstringstream xml_ss_in;
        xml_ss_in.write((tchar_t *)(_buffer + _offset), _count / sizeof(tchar_t));
        //xml_ss_in.str(xml_str);

        tstring str = xml_ss_in.str();
        FileStream* pFileStream = FileStream::OpenFileStream( TXT("test.txt"), FileStream::MODE_WRITE, true );
        pFileStream->Write(str.c_str(), sizeof(tchar_t), str.size());
        pFileStream->Close();
        delete pFileStream;

        Reflect::ArchiveXML xml_in(new Reflect::TCharStream(&xml_ss_in, false), false);
        xml_in.ReadFileHeader();
        xml_in.BeginReadingSingleObjects();
        
        xml_in.ReadSingleObject(cached_object);
    }

#else
    {
        std::stringstream binary_ss_in;
        binary_ss_in.write((char *)(_buffer + _offset), _count);

        Reflect::ArchiveBinary binary_in(new Reflect::CharStream(&binary_ss_in, false, Helium::ByteOrders::LittleEndian, Helium::Reflect::CharacterEncodings::UTF_16), false);
        
        binary_in.ReadSingleObject(cached_object);
    }

#endif

    return cached_object;
}
开发者ID:foolhuang,项目名称:Helium,代码行数:43,代码来源:Cache.cpp

示例5: Save

void Settings::Save()
{
    Directory appDataDir = GetAppDataDir();
    if (!appDataDir.Exists())
        appDataDir.CreateNewDirectory();
    auto it = m_PImpl->m_Data.Begin();
    auto end = m_PImpl->m_Data.End();
    File config;
    config.SetLocation(appDataDir.Location().OriginalString() + "/config.txt");
    config.CreateNewFile();
    FileStream fs;
    if (fs.Open(config.Location(), FileAccessMode::Write, FileAccessPriority::DelayReadWrite))
    {
        for (; it != end; ++it)
        {
            String buf = String::UnsafeStringCreation(it->first) + "=" + it->second + "\n";
            fs.Write(reinterpret_cast<const UInt8*>(buf.c_str()), 0, buf.Length());
        }
        fs.Close();
    }
}
开发者ID:wangscript,项目名称:RadonFramework,代码行数:21,代码来源:Settings.cpp

示例6: AddCacheFile

DataStream* ResourceManager::AddCacheFile(const char *filename)
{
	if (!core->GameOnCD)
		return FileStream::OpenFile(filename);

	char fname[_MAX_PATH];
	ExtractFileFromPath(fname, filename);

	FileStream *dest = OpenCacheFile(fname);

	// already in cache
	if (dest)
		return dest;

	FileStream* src = FileStream::OpenFile(fname);
	dest = CreateCacheFile(fname);

	if (!src || !dest) {
		printMessage("ResourceManager", "Failed to copy file '%s'\n", RED, fname);
		abort();
	}

	size_t blockSize = 1024 * 1000;
	char buff[1024 * 1000];
	do {
		if (blockSize > src->Remains())
			blockSize = src->Remains();
		size_t len = src->Read(buff, blockSize);
		size_t c = dest->Write(buff, len);
		if (c != len) {
			printMessage("ResourceManager", "Failed to write to file '%s'\n", RED, fname);
			abort();
		}
	} while (src->Remains());

	delete src;
	delete dest;

	return OpenCacheFile(fname);
}
开发者ID:,项目名称:,代码行数:40,代码来源:

示例7: GetAuxHdr

DataStream* CTlkOverride::GetAuxHdr(bool create)
{
	char nPath[_MAX_PATH];
	char Signature[TOH_HEADER_SIZE];

	PathJoin( nPath, core->CachePath, "default.toh", NULL );
	FileStream* fs = new FileStream();
retry:
	if (fs->Modify(nPath)) {
		return fs;
	}
	if (create) {
		fs->Create( "default", IE_TOH_CLASS_ID);
		memset(Signature,0,sizeof(Signature));
		memcpy(Signature,"TLK ",4);
		fs->Write(Signature, sizeof(Signature));
		create = false;
		goto retry;
	}
	delete fs;
	return NULL;
}
开发者ID:BlackLotus,项目名称:gemrb,代码行数:22,代码来源:TlkOverride.cpp

示例8: FileTime

// FileTime
//------------------------------------------------------------------------------
void TestFileIO::FileTime() const
{
	// generate a process unique file path
	AStackString<> path;
	GenerateTempFileName( path );

	// create it
	FileStream f;
	TEST_ASSERT( f.Open( path.Get(), FileStream::WRITE_ONLY ) == true );
	f.Close();

	// get last write time
	const uint64_t oldTime = FileIO::GetFileLastWriteTime( path );
	TEST_ASSERT( oldTime != 0 );

	// wait for some time that is bigger than filesystem time granularity
    #if defined( __OSX__ )
        // HFS+ has surprisingly poor time resolution (1 second)
        Thread::Sleep( 1100 );
    #else
        Thread::Sleep( 500 );
    #endif
    
	// modify file
	FileStream f2;
	TEST_ASSERT( f.Open( path.Get(), FileStream::WRITE_ONLY ) == true );
	f.Write( (uint32_t)0 );
	f.Close();

	// get new last write time
	const uint64_t newTime = FileIO::GetFileLastWriteTime( path );
	TEST_ASSERT( newTime > oldTime );

	// manually set time back
	TEST_ASSERT( FileIO::SetFileLastWriteTime( path, oldTime ) == true );
	uint64_t timeNow = FileIO::GetFileLastWriteTime( path );
    TEST_ASSERT( timeNow == oldTime );
}
开发者ID:scott-nelson,项目名称:fastbuild,代码行数:40,代码来源:TestFileIO.cpp

示例9: WriteToFile

void JUnitOutput::WriteToFile(const Uri& URI, 
                              const TestResultCollector& Results)
{
    // ensure that a new log will be written
    File output;
    output.SetLocation(URI);
    output.Delete();

    FileStream out;
    out.Open(URI, FileAccessMode::Write, FileAccessPriority::DelayReadWrite);
    if (out.CanWrite())
    {
        //start suites
        String tag("<testsuites>\n", sizeof("<testsuites>\n"));
        out.Write(reinterpret_cast<const UInt8*>(tag.c_str()), 0, tag.Length());
        for(UInt32 i = 0; i<Results.TestResults().Count(); ++i)
        {
            //start a suite
            tag=String::Format(String("<testsuite error=\"%u\" failures=\"%u\" hostname=\"RadonFramework-TestEnvoirement\" name=\"%s\" tests=\"%u\" time=\"%.3f\" timestamp=\"%s\" id=\"%u\" package=\"%u\">\n",sizeof(
                                      "<testsuite error=\"%u\" failures=\"%u\" hostname=\"RadonFramework-TestEnvoirement\" name=\"%s\" tests=\"%u\" time=\"%.3f\" timestamp=\"%s\" id=\"%u\" package=\"%u\">\n")),
                                Results.TestResults()[i].TestsWithError,
                                Results.TestResults()[i].TestsWithFailure,
                                Results.TestResults()[i].SuiteName.c_str(),
                                Results.TestResults()[i].TestResults.Count(),
                                Results.TestResults()[i].TotalTime,
                                "2007-11-02T23:13:49",
                                0,
                                0);
            out.Write(reinterpret_cast<const UInt8*>(tag.c_str()), 0 ,tag.Length());
            for(UInt32 j = 0; j<Results.TestResults()[i].TestResults.Count(); ++j)
            {
                //start testcase
                tag=String::Format(String("<testcase classname=\"%s\" name=\"%s\" time=\"%d\">\n", sizeof(
                                        "<testcase classname=\"%s\" name=\"%s\" time=\"%d\">\n")),
                                    "",
                                    Results.TestResults()[i].TestResults[j].Name().c_str(),
                                    Results.TestResults()[i].TestResults[j].TimeRequired().Ticks());
                out.Write(reinterpret_cast<const UInt8*>(tag.c_str()), 0, tag.Length());
                // test failed
                if (!Results.TestResults()[i].TestResults[j].Passed())
                {
                    tag=String::Format(String("<error message=\"%s\" type=\"%s\">%s\n", sizeof(
                                            "<error message=\"%s\" type=\"%s\">%s\n")),
                                        "",
                                        "",
                                        "");
                    out.Write(reinterpret_cast<const UInt8*>(tag.c_str()), 0, tag.Length());
                    tag="</error>\n";
                    out.Write(reinterpret_cast<const UInt8*>(tag.c_str()), 0, tag.Length());
                }
                // test raise an exception
                if (Results.TestResults()[i].TestResults[j].Error())
                {
                    tag=String::Format(String("<failure message=\"%s\" type=\"%s\">%s\n",sizeof(
                        "<failure message=\"%s\" type=\"%s\">%s\n")),
                        "",
                        "",
                        "");
                    out.Write(reinterpret_cast<const UInt8*>(tag.c_str()), 0, tag.Length());
                    tag="</failure>\n";
                    out.Write(reinterpret_cast<const UInt8*>(tag.c_str()), 0, tag.Length());
                }
                //end testcase
                tag="</testcase>\n";
                out.Write(reinterpret_cast<const UInt8*>(tag.c_str()), 0, tag.Length());
            }
            //end the suite
            tag="</testsuite>\n";
            out.Write(reinterpret_cast<const UInt8*>(tag.c_str()), 0, tag.Length());
        }
        //end suites
        tag="</testsuites>\n";
        out.Write(reinterpret_cast<const UInt8*>(tag.c_str()), 0, tag.Length());
    }
}
开发者ID:wangscript,项目名称:RadonFramework,代码行数:75,代码来源:JUnitOutput.cpp

示例10: Extract

// Extracts specified files from zip
void ZipFile::Extract(String* FileSpec, String* DestPath, UpdateOption OverwriteWhen, Boolean RecurseSubdirectories, PathInclusion CreatePathMethod)
{
	// Any file spec in destination path will be ignored
	DestPath = JustPath(DestPath);

	char* pszPassword = NULL;
	char* pszFileName = NULL;
	OpenFileForUnzip();

	// Just wrapping in a try/catch/finally to make sure unmanaged code allocations always get released
	try
	{
		Regex* filePattern = GetFilePatternRegularExpression(FileSpec, caseSensitive);
		IEnumerator* filesEnum = files->GetEnumerator();
		CompressedFile* file;
		String* sourceFileName;
		String* destFileName;
		bool writeFile;
 		int err;

		// Get ANSI password, if one was provided
		if (password)
			if (password->get_Length())
				pszPassword = StringToCharBuffer(password);

		// Loop through compressed file collection
		while (filesEnum->MoveNext())
		{
			file = static_cast<CompressedFile*>(filesEnum->Current);
			sourceFileName = file->get_FileName();

			if (filePattern->IsMatch(GetSearchFileName(FileSpec, sourceFileName, RecurseSubdirectories)))
			{
				pszFileName = StringToCharBuffer(sourceFileName);
				err = unzLocateFile(hUnzipFile, pszFileName, (caseSensitive ? 1 : 2));
				free(pszFileName);
				pszFileName = NULL;

				// We should find file in zip file if it was in our compressed file collection
				if (err != Z_OK) throw new CompressionException(String::Concat(S"Extract Zip File Error: Compressed file \"", sourceFileName, "\" cannot be found in zip file!"));

				// Open compressed file for unzipping
				if (pszPassword)
					err = unzOpenCurrentFilePassword(hUnzipFile, pszPassword);
				else
					err = unzOpenCurrentFile(hUnzipFile);

				if (err != Z_OK) throw new CompressionException(S"Extract Zip File", err);

				// Get full destination file name
				switch (CreatePathMethod)
				{
					case PathInclusion::FullPath:
						destFileName = sourceFileName;
						break;
					case PathInclusion::NoPath:
						destFileName = String::Concat(DestPath, Path::GetFileName(sourceFileName));
						break;
					case PathInclusion::RelativePath:
						destFileName = String::Concat(DestPath, sourceFileName);
						break;
				}

				// Make sure destination directory exists
				Directory::CreateDirectory(JustPath(destFileName));

				// See if destination file already exists
				if (File::Exists(destFileName))
				{
					DateTime lastUpdate = File::GetLastWriteTime(destFileName);

					switch (OverwriteWhen)
					{
						case UpdateOption::Never:
							writeFile = false;
							break;
						case UpdateOption::Always:
							writeFile = true;
							break;
						case UpdateOption::ZipFileIsNewer:
							writeFile = (DateTime::Compare(file->get_FileDateTime(), lastUpdate) > 0);
							break;
						case UpdateOption::DiskFileIsNewer:
							writeFile = (DateTime::Compare(file->get_FileDateTime(), lastUpdate) < 0);
							break;
						default:
							writeFile = false;
							break;
					}
				}
				else
					writeFile = true;

				if (writeFile)
				{
					System::Byte buffer[] = new System::Byte[BufferSize];
					System::Byte __pin * destBuff = &buffer[0];	// pin buffer so it can be safely passed into unmanaged code...
					FileStream* fileStream = File::Create(destFileName);
					int read;
//.........这里部分代码省略.........
开发者ID:avs009,项目名称:gsf,代码行数:101,代码来源:ZipFile.cpp

示例11: ReceiveFileData

// ReceiveFileData
//------------------------------------------------------------------------------
bool ToolManifest::ReceiveFileData( uint32_t fileId, const void * data, size_t & dataSize )
{
	MutexHolder mh( m_Mutex );

	File & f = m_Files[ fileId ];

	// gracefully handle multiple receipts of the same data
	if ( f.m_Content )
	{
		ASSERT( f.m_SyncState == File::SYNCHRONIZED );
		return true;
	}

	ASSERT( f.m_SyncState == File::SYNCHRONIZING );

	// prepare name for this file
	AStackString<> fileName;
	GetRemoteFilePath( fileId, fileName );

	// prepare destination
	AStackString<> pathOnly( fileName.Get(), fileName.FindLast( NATIVE_SLASH ) );
	if ( !FileIO::EnsurePathExists( pathOnly ) )
	{
		return false; // FAILED
	}

	// write to disk
	FileStream fs;
	if ( !fs.Open( fileName.Get(), FileStream::WRITE_ONLY ) )
	{
		return false; // FAILED
	}
	if ( fs.Write( data, dataSize ) != dataSize )
	{
		return false; // FAILED
	}
	fs.Close();

	// open read-only 
	AutoPtr< FileStream > fileStream( FNEW( FileStream ) );
	if ( fileStream.Get()->Open( fileName.Get(), FileStream::READ_ONLY ) == false )
	{
		return false; // FAILED
	}

	// This file is now synchronized
	f.m_FileLock = fileStream.Release(); // NOTE: Keep file open to prevent deletion
	f.m_SyncState = File::SYNCHRONIZED;

	// is completely synchronized?
	const File * const end = m_Files.End();
	for ( const File * it = m_Files.Begin(); it != end; ++it )
	{
		if ( it->m_SyncState != File::SYNCHRONIZED )
		{
			// still some files to be received
			return true; // file stored ok
		}
	}

	// all files received
	m_Synchronized = true;
	return true; // file stored ok
}
开发者ID:zhangf911,项目名称:fastbuild,代码行数:66,代码来源:ToolManifest.cpp

示例12: Execute

void Renderer::Execute()
{
	Network::Packet* packet = m_Net->RecvNonBlocking(0);
	if (packet != NULL)
	{
		Kernel::GetInstance()->Log(m_LogTag | Logger::IS_INFORMATION, "Got package: %s", packet->GetID());
		// Some sort of data we need for rendering future pipeline
		if (packet->GetTag() == m_NetTag_Datacache)
		{
			if (StringCompare(packet->GetID(), "res") == 0)
			{
				unsigned long hash = packet->GetObject<unsigned long>(0);
				char* filename = packet->GetArray<char*>(packet->ObjectSize(1), 1);
				unsigned long datalen = packet->GetObject<unsigned long>(2);
				char* data = packet->GetArray<char*>(packet->ObjectSize(3) ,3);
				char location[256];
				Format(location, "datacache/%X_%s", (unsigned int)hash, filename);
				Kernel::GetInstance()->Log(m_LogTag | Logger::IS_INFORMATION, "Saving data to cache: %s", location);
				FileStream stream;
				stream.OpenWriteBinary(location);
				stream.Write(data, datalen);
				stream.Close();

				delete [] filename;
				delete [] data;

				m_NumRecieved++;
				Network::Packet* ackpack = m_NetDevice->CreateEmptyPacket("ackres", m_NetTag_Datacache);
				ackpack->PushInt(m_NumRecieved);
				m_Net->SendAllPacket(ackpack);
				delete ackpack;

			}
			else if (StringCompare(packet->GetID(), "ack") == 0)
			{
				// has_everything_lets_do_some_rendering()
			}
		}
		// New pipeline to render
		else if (packet->GetTag() == m_NetTag_Pipeline)
		{
			m_SendPreviews = true;
			CleanUp();
			
			m_JsonDataSize = packet->GetLength();
			m_JsonData = new char[m_JsonDataSize];
			StringCopy(m_JsonData, packet->GetData(), m_JsonDataSize);
			
			//Kernel::GetInstance()->Log(m_LogTag | Logger::IS_INFORMATION, "Got new pipeline data, loading JSON and building graph: %s", m_JsonData);
			Kernel::GetInstance()->Log(m_LogTag | Logger::IS_INFORMATION, "Got new pipeline data, loading JSON and building graph.");
			
			
			LoadJson();
			BuildGraph();
			
			m_NumRecieved = 0;

			if (m_RootBlock)
			{
				m_RootBlock->ResetPerformed();
				m_RootBlock->Execute(m_SendPreviews);
				m_SendPreviews = false;

				/*if (m_Net->NumClients() > 0)
				{
					Resource::Image* img = m_gfx->CreateImageFromTexture(GetResult());
					Network::Packet* imgpacket = m_NetDevice->CreateEmptyPacket("imgdata", m_NetTag_Preview);
					imgpacket->PushInt(img->Width());
					imgpacket->PushInt(img->Height());
					imgpacket->PushInt(img->Channels());
					imgpacket->PushString((const char*)img->Ptr(), img->Height()*img->Width()*img->Channels());

					Kernel::GetInstance()->Log(m_LogTag | Logger::IS_INFORMATION, "Sending final image to client '%d'", packet->GetSender());
					m_Net->SendAllPacket(imgpacket);

					m_NumRecieved = 0;
					delete imgpacket;
					delete img;
				}*/
				
			}
			else
			{
				Kernel::GetInstance()->Log(m_LogTag | Logger::IS_CRITICAL, "Failed to execute root block since it's NULL.");

			}
			
		}
	}
	
	if (m_RootBlock)
	{
		m_RootBlock->ResetPerformed();
		m_RootBlock->Execute(m_SendPreviews);
		m_SendPreviews = false;
	}
	else
	{
		Kernel::GetInstance()->Log(m_LogTag | Logger::IS_CRITICAL, "Failed to execute root block since it's NULL.");
	}
//.........这里部分代码省略.........
开发者ID:pxf,项目名称:pxf-tech2,代码行数:101,代码来源:Renderer.cpp

示例13: GetTestExecutable

// DoBuild
//------------------------------------------------------------------------------
/*virtual*/ Node::BuildResult TestNode::DoBuild( Job * job )
{
	// If the workingDir is empty, use the current dir for the process
	const char * workingDir = m_TestWorkingDir.IsEmpty() ? nullptr : m_TestWorkingDir.Get();

	EmitCompilationMessage( workingDir );

	// spawn the process
	Process p;
	bool spawnOK = p.Spawn( GetTestExecutable()->GetName().Get(),
							m_TestArguments.Get(),
							workingDir,
							FBuild::Get().GetEnvironmentString() );

	if ( !spawnOK )
	{
		FLOG_ERROR( "Failed to spawn process for '%s'", GetName().Get() );
		return NODE_RESULT_FAILED;
	}

	// capture all of the stdout and stderr
	AutoPtr< char > memOut;
	AutoPtr< char > memErr;
	uint32_t memOutSize = 0;
	uint32_t memErrSize = 0;
	bool timedOut = !p.ReadAllData( memOut, &memOutSize, memErr, &memErrSize, m_TestTimeOut );
	if ( timedOut )
	{
		FLOG_ERROR( "Test timed out after %u ms (%s)", m_TestTimeOut, m_TestExecutable.Get() );
		return NODE_RESULT_FAILED;
	}

	ASSERT( !p.IsRunning() );
	// Get result
	int result = p.WaitForExit();
	if ( result != 0 )
	{
		// something went wrong, print details
		Node::DumpOutput( job, memOut.Get(), memOutSize );
		Node::DumpOutput( job, memErr.Get(), memErrSize );
	}

	// write the test output (saved for pass or fail)
	FileStream fs;
	if ( fs.Open( GetName().Get(), FileStream::WRITE_ONLY ) == false )
	{
		FLOG_ERROR( "Failed to open test output file '%s'", GetName().Get() );
		return NODE_RESULT_FAILED;
	}
	if ( ( memOut.Get() && ( fs.Write( memOut.Get(), memOutSize ) != memOutSize ) ) ||
		 ( memErr.Get() && ( fs.Write( memErr.Get(), memErrSize ) != memErrSize ) ) )
	{
		FLOG_ERROR( "Failed to write test output file '%s'", GetName().Get() );
		return NODE_RESULT_FAILED;
	}
	fs.Close();

	// did the test fail?
	if ( result != 0 )
	{
		FLOG_ERROR( "Test failed (error %i) '%s'", result, GetName().Get() );
		return NODE_RESULT_FAILED;
	}

	// test passed 
	// we only keep the "last modified" time of the test output for passed tests
	m_Stamp = FileIO::GetFileLastWriteTime( m_Name );
	return NODE_RESULT_OK;
}
开发者ID:JeremieA,项目名称:fastbuild,代码行数:71,代码来源:TestNode.cpp

示例14: CacheEntry


//.........这里部分代码省略.........
    {
        HELIUM_TRACE(
            TraceLevels::Info,
            TXT( "Cache: Caching \"%s\" to \"%s\" (%" ) TPRIu32 TXT( " bytes @ offset %" ) TPRIu64 TXT( ").\n" ),
            *path.ToString(),
            *m_cacheFileName,
            size,
            entryOffset );

        uint64_t seekOffset = static_cast< uint64_t >( pCacheStream->Seek(
            static_cast< int64_t >( entryOffset ),
            SeekOrigins::SEEK_ORIGIN_BEGIN ) );
        if( seekOffset != entryOffset )
        {
            HELIUM_TRACE( TraceLevels::Error, TXT( "Cache: Cache file offset seek failed.\n" ) );

            if( bNewEntry )
            {
                m_entries.Pop();
                m_entryMap.Remove( entryAccessor );
                m_pEntryPool->Release( pEntryUpdate );
            }
            else
            {
                pEntryUpdate->offset = originalOffset;
                pEntryUpdate->timestamp = originalTimestamp;
                pEntryUpdate->size = originalSize;
            }

            bCacheSuccess = false;
        }
        else
        {
            size_t writeSize = pCacheStream->Write( pData, 1, size );
            if( writeSize != size )
            {
                HELIUM_TRACE(
                    TraceLevels::Error,
                    ( TXT( "Cache: Failed to write %" ) TPRIu32 TXT( " bytes to cache \"%s\" (%" ) TPRIuSZ
                    TXT( " bytes written).\n" ) ),
                    size,
                    *m_cacheFileName,
                    writeSize );

                if( bNewEntry )
                {
                    m_entries.Pop();
                    m_entryMap.Remove( entryAccessor );
                    m_pEntryPool->Release( pEntryUpdate );
                }
                else
                {
                    pEntryUpdate->offset = originalOffset;
                    pEntryUpdate->timestamp = originalTimestamp;
                    pEntryUpdate->size = originalSize;
                }

                bCacheSuccess = false;
            }
            else
            {
                HELIUM_TRACE( TraceLevels::Info, TXT( "Cache: Rewriting TOC file \"%s\".\n" ), *m_tocFileName );

                FileStream* pTocStream = FileStream::OpenFileStream( m_tocFileName, FileStream::MODE_WRITE, true );
                if( !pTocStream )
                {
开发者ID:foolhuang,项目名称:Helium,代码行数:67,代码来源:Cache.cpp

示例15: streamFndb

bool
FndbManager::Create (/*[in]*/ const char *		lpszFndbPath,
		     /*[in]*/ const char *		lpszRootPath,
		     /*[in]*/ ICreateFndbCallback *	pCallback,
		     /*[in]*/ bool			enableStringPooling,
		     /*[in]*/ bool			storeFileNameInfo)
{
  traceStream->WriteFormattedLine ("core",
				   T_("creating fndb file %s..."),
				   Q_(lpszFndbPath));
  unsigned rootIdx = SessionImpl::GetSession()->DeriveTEXMFRoot(lpszRootPath);
  this->enableStringPooling = enableStringPooling;
  this->storeFileNameInfo = storeFileNameInfo;
  byteArray.reserve (2 * 1024 * 1024);
  try
    {
      ReserveMem (sizeof(FileNameDatabaseHeader));
      FileNameDatabaseHeader fndb;
      fndb.Init ();
      if (pCallback == 0 && FileIsOnROMedia(lpszRootPath))
	{
	  fndb.flags |= FileNameDatabaseHeader::FndbFlags::Frozen;
	}
      if (storeFileNameInfo)
	{
	  fndb.flags |= FileNameDatabaseHeader::FndbFlags::FileNameInfo;
	}
      AlignMem ();
      fndb.foPath = PushBack(lpszRootPath);
      numDirectories = 0;
      numFiles = 0;
      deepestLevel = 0;
      currentLevel = 0;
      this->pCallback = pCallback;
#if 0				// <new>this will break prev MiKTeX</new>
      fndb.foTopDir = ProcessFolder(0, lpszRootPath, CURRENT_DIRECTORY, 0);
#else
      fndb.foTopDir =
	ProcessFolder(0,
		      lpszRootPath,
		      CURRENT_DIRECTORY,
		      fndb.foPath);
#endif
      fndb.numDirs = numDirectories;
      fndb.numFiles = numFiles;
      fndb.depth = deepestLevel;
      fndb.timeStamp = static_cast<unsigned long>(time(0)); // <sixtyfourbit/>
      fndb.size = GetMemTop();
      if ((fndb.flags & FileNameDatabaseHeader::FndbFlags::Frozen) == 0)
	{
	  size_t n = ((GetMemTop() + FNDB_EXTRA + 1) / FNDB_GRAN * FNDB_GRAN) - GetMemTop();
	  ReserveMem (n);
	}
      AlignMem (FNDB_PAGESIZE);
      SetMem (0, &fndb, sizeof(fndb));
      // <fixme>
      bool unloaded = false;
      for (size_t i = 0; ! unloaded && i < 100; ++ i)
	{
	  unloaded =
	    SessionImpl::GetSession()->UnloadFilenameDatabaseInternal(rootIdx,
								      true);
	  if (! unloaded)
	    {
	      traceStream->WriteFormattedLine ("core", "Sleep(1)");
	      Thread::Sleep (1);
	    }
	}
      if (! unloaded)
	{
	  TraceError (T_("fndb cannot be unloaded"));
	}
      // </fixme>
      PathName directory = PathName(lpszFndbPath).RemoveFileSpec();
      if (! Directory::Exists(directory))
	{
	  Directory::Create (directory);
	}
      FileStream streamFndb (File::Open(lpszFndbPath,
					FileMode::Create,
					FileAccess::Write,
					false));
      streamFndb.Write (GetMemPointer(), GetMemTop());
      traceStream->WriteFormattedLine ("core",
				       T_("fndb creation completed"));
      time_t now = time(0);
      string nowStr = NUMTOSTR(now);
      if (SessionImpl::GetSession()->IsAdminMode())
      {
	SessionImpl::GetSession()->SetConfigValue (MIKTEX_REGKEY_CORE, MIKTEX_REGVAL_LAST_ADMIN_MAINTENANCE, nowStr.c_str());
      }
      else
      {
	SessionImpl::GetSession()->SetConfigValue (MIKTEX_REGKEY_CORE, MIKTEX_REGVAL_LAST_USER_MAINTENANCE, nowStr.c_str());
      }
      return (true);
    }
  catch (const OperationCancelledException &)
    {
      traceStream->WriteFormattedLine ("core",
//.........这里部分代码省略.........
开发者ID:bngabonziza,项目名称:miktex,代码行数:101,代码来源:makefndb.cpp


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