• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ pFile函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中pFile函数的典型用法代码示例。如果您正苦于以下问题:C++ pFile函数的具体用法?C++ pFile怎么用?C++ pFile使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



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

示例1: serveFile

        bool serveFile(const string& URI, string& contentType, string& content) const {
            if (URI.length() == 0) return false;
            
            string filename = BASE_DIR + URI;
            if (URI[URI.length() - 1] == '/') filename += DEFAULT_FILE;

            LogDebug("read file: %s", filename.c_str());

            auto deleter = [](FILE *p) {fclose(p); };
            unique_ptr<FILE, decltype(deleter)> pFile(fopen(filename.c_str(), "r"), deleter);
            if (pFile == nullptr) return false;
            
            contentType = getContentType(getFileSuffix(filename));
            
            content.clear();
            char buff[READ_FILE_BUFFER_SIZE];

            fgets(buff, READ_FILE_BUFFER_SIZE - 1, pFile.get());
            while (! feof(pFile.get())) {
                content += buff;
                fgets(buff, READ_FILE_BUFFER_SIZE - 1, pFile.get());
            }

            return true;
        }
开发者ID:aholic,项目名称:paekdusan,代码行数:25,代码来源:StaticPageHandler.hpp


示例2: MemoryCardBase

MemoryCard::MemoryCard(const std::string& filename, int _card_index, u16 sizeMb)
	: MemoryCardBase(_card_index, sizeMb)
	, m_filename(filename)
{
	File::IOFile pFile(m_filename, "rb");
	if (pFile)
	{
		// Measure size of the existing memcard file.
		memory_card_size = (u32)pFile.GetSize();
		nintendo_card_id = memory_card_size / SIZE_TO_Mb;
		m_memcard_data = std::make_unique<u8[]>(memory_card_size);
		memset(&m_memcard_data[0], 0xFF, memory_card_size);

		INFO_LOG(EXPANSIONINTERFACE, "Reading memory card %s", m_filename.c_str());
		pFile.ReadBytes(&m_memcard_data[0], memory_card_size);
	}
	else
	{
		// Create a new 128Mb memcard
		nintendo_card_id = sizeMb;
		memory_card_size = sizeMb * SIZE_TO_Mb;

		m_memcard_data = std::make_unique<u8[]>(memory_card_size);
		// Fills in MC_HDR_SIZE bytes
		GCMemcard::Format(&m_memcard_data[0], m_filename.find(".JAP.raw") != std::string::npos, sizeMb);
		memset(&m_memcard_data[MC_HDR_SIZE], 0xFF, memory_card_size - MC_HDR_SIZE);

		INFO_LOG(EXPANSIONINTERFACE, "No memory card found. A new one was created instead.");
	}

	// Class members (including inherited ones) have now been initialized, so
	// it's safe to startup the flush thread (which reads them).
	m_flush_buffer = std::make_unique<u8[]>(memory_card_size);
	m_flush_thread = std::thread(&MemoryCard::FlushThread, this);
}
开发者ID:Abrahamh08,项目名称:dolphin,代码行数:35,代码来源:GCMemcardRaw.cpp


示例3: main

int main(int argc, char * argv[])
{
	if (argc != 2)
	{
		cerr<<"No File Name";
		exit(1);
	}
	ifstream pFile(argv[1],ios_base::in);
	if(!pFile.is_open())
	{
		cerr<<"No such File";
		exit(1);
	}

    string outputFile;
    outputFile.append(argv[1]);
    outputFile = outputFile.substr(0,outputFile.size()-3);
    outputFile.append(".lextext");
	Scaner scan(pFile);
    scan.Scan(outputFile);
    cout<<"输出文件:"<<outputFile<<endl;

    Parse parse(scan);

    Node* parseTree = parse.program();

#ifdef _DEBUG
    parse.printTree( parseTree );
#endif
    cout<<"按下任何键继续..."<<endl;
    cin.get();
    return 0;
}
开发者ID:clones1201,项目名称:Toys,代码行数:33,代码来源:parseTest.cpp


示例4: readarray

std::vector<std::string> readarray(std::string filename,const std::string delims=",;: \t"){
  ///@param filename The name of the file to open.
  ///@param delims A string of delimeters to split by.
  std::vector<std::string> tokens;

  const int SIZE = MAX_ELEMS_PER_LINE;
  char *buffer = new char[SIZE];
  std::ifstream pFile (filename.c_str(),std::ios::in);
  
  if(!pFile){
    fileError(filename);
    exit(0);
  }
  
  std::string tmp_string;
  //we are reading an array, so just keep reading until no more lines
  while(!pFile.eof()){
    pFile.getline(buffer,SIZE);
    tmp_string = std::string(buffer);
    get_lexemes(tmp_string,tokens,delims);
    
  }
  pFile.close();
  delete [] buffer;
  ///now we have a token array of string coerce the types now
  //typecast_stringarray(tokens);
  return tokens;
}
开发者ID:aalbrechtsen,项目名称:relate,代码行数:28,代码来源:filereader_and_conversions.cpp


示例5: UnloadHeightMap

bool TERRAIN::LoadHeightMap(const QString& filename, int size)
{
  if( heightMap.arrayHeightMap )
    UnloadHeightMap( );

  QFile pFile(filename);
#if QT_VERSION >= 0x040000
	if (!pFile.open(QIODevice::ReadOnly))
#else
	if (!pFile.open(IO_ReadOnly))
#endif
    return false;

  heightMap.arrayHeightMap = new unsigned char [size*size];

  if( heightMap.arrayHeightMap==NULL )
    return false;

  //lire la carte d'hauteurs, format RAW
  QDataStream in(&pFile);
  for (int i=0; i<sizeHeightMap*sizeHeightMap; i++)
    in >> heightMap.arrayHeightMap[i];
  
  pFile.close();

  sizeHeightMap = size;

  return true;
}
开发者ID:Sabouh,项目名称:CurvRecProject,代码行数:29,代码来源:terrain.cpp


示例6: pFile

void CBaseTopPane::CopyBackgroundPresetToForeground()
{
	// Create new background set
	IChunkFileMemory* pPresetBackgroundNew = IChunkFileMemory::Create();
	tint32 iVersionNumber = 1;
	pPresetBackgroundNew->Open(IFile::FileCreate, iVersionNumber);

	// Read current preset into background preset set
	mpGUI->OnSavePreset(dynamic_cast<IChunkFile*>(pPresetBackgroundNew));

	// Get the memory from the current background set
	tint64 iMemSize = mpPresetBackground->GetMemorySize();
	void* pMem = (void*)new char[(tuint)iMemSize];
	mpPresetBackground->GetMemory(pMem);

	// Delete the current background set
	mpPresetBackground->Destroy();

	// Switch, so the current preset is the new background
	mpPresetBackground = pPresetBackgroundNew;

	// Create chunk with old background
	CAutoDelete<IChunkFileMemory> pFile(IChunkFileMemory::Create());
	pFile->Open(IFile::FileRead, iVersionNumber, pMem, iMemSize);

	// Set the preset
	mpGUI->OnLoadPreset(pFile);

	// Delete the memory
	delete[] pMem;
}
开发者ID:grimtraveller,项目名称:koblo_software,代码行数:31,代码来源:CBaseTopPane.cpp


示例7: pFile

void CLibraryMaps::Serialize2(CArchive& ar, int nVersion)
{
	if ( nVersion < 18 ) return;

	if ( ar.IsStoring() )
	{
		ar.WriteCount( m_pDeleted.GetCount() );

		for ( POSITION pos = m_pDeleted.GetHeadPosition() ; pos ; )
		{
			m_pDeleted.GetNext( pos )->Serialize( ar, nVersion );
		}
	}
	else // Loading
	{
		for ( DWORD_PTR nCount = ar.ReadCount() ; nCount > 0 ; nCount-- )
		{
			//CLibraryFile* pFile = new CLibraryFile( NULL );
			CAutoPtr< CLibraryFile > pFile( new CLibraryFile( NULL ) );
			if ( ! pFile )
				AfxThrowMemoryException();

			pFile->Serialize( ar, nVersion );

			if ( ! LibraryMaps.LookupFileByHash( pFile ) )
				Library.AddFile( pFile.Detach() );
		}
	}
}
开发者ID:lemonxiao0,项目名称:peerproject,代码行数:29,代码来源:LibraryMaps.cpp


示例8: LoadRom

static bool LoadRom(const std::string& fname, int size_in_words, u16 *rom)
{
	File::IOFile pFile(fname, "rb");
	const size_t size_in_bytes = size_in_words * sizeof(u16);
	if (pFile)
	{
		pFile.ReadArray(rom, size_in_words);
		pFile.Close();

		// Byteswap the rom.
		for (int i = 0; i < size_in_words; i++)
			rom[i] = Common::swap16(rom[i]);

		// Always keep ROMs write protected.
		WriteProtectMemory(rom, size_in_bytes, false);
		return true;
	}

	PanicAlertT(
		"Failed to load DSP ROM:\t%s\n"
		"\n"
		"This file is required to use DSP LLE.\n"
		"It is not included with Dolphin as it contains copyrighted data.\n"
		"Use DSPSpy to dump the file from your physical console.\n"
		"\n"
		"You may use the DSP HLE engine which does not require ROM dumps.\n"
		"(Choose it from the \"Audio\" tab of the configuration dialog.)", fname.c_str());
	return false;
}
开发者ID:albertofem,项目名称:dolphin,代码行数:29,代码来源:DSPCore.cpp


示例9: THROW_EXCEPTION

//==================================================
//! Load a file from the VFS into memory, can throw a FileIOException
//==================================================
void System::VFS::LoadRaw( const string& strFilename, vector<byte>& data ) {
	// Check to see if it exists
	if( !PHYSFS_exists(strFilename.c_str()) ) {
		THROW_EXCEPTION( FileReadException() << FileIOExceptionFilename(strFilename) );
	}
	
	// Open the file
	shared_ptr<PHYSFS_file> pFile( PHYSFS_openRead(strFilename.c_str()), PHYSFS_close );
	if( pFile.get() == NULL ) {
		THROW_EXCEPTION( FileReadException() << FileIOExceptionFilename(strFilename) );
	}

	// Try to read the number of bytes, fail if we can't
	PHYSFS_sint64 nBytes= PHYSFS_fileLength( pFile.get() );
	if( nBytes < 0 ) {
		THROW_EXCEPTION( FileReadException() << FileIOExceptionFilename(strFilename) );
	}
	data.resize( unsigned(nBytes) );

	// Try to read the data
	PHYSFS_sint64 nBytesRead= PHYSFS_read( pFile.get(), &data[0], sizeof(byte), data.size() );
	// Check for unexpected length
	if( nBytesRead != nBytes ) {
		data.resize( unsigned(nBytesRead) );
		THROW_EXCEPTION( FileReadException() << FileIOExceptionFilename(strFilename) );
	}
}
开发者ID:schnarf,项目名称:Phaedrus-FPS,代码行数:30,代码来源:VFS.cpp


示例10: GetPlugIn

void CBaseTopPane::ActionLoad()
{
	// Get the directory
	std::string sPresetDirectory = mpGUI->GetPresetFolder();
	
	// Get product name
	tchar pszProductName[128];
	GetPlugIn()->GetProductName(pszProductName);

	// Create the dialog
	CAutoDelete<ge::IOpenDialog> pDialog(ge::IOpenDialog::Create());

	// Open dialog
	tchar pszPathName[512];
	pDialog->DoDialog((tchar*)pszPathName,
		(tchar*)(sPresetDirectory.c_str()),
		(tchar*)"*.preset",
		(tchar*)(std::string(pszProductName) + " Presets (*.preset)").c_str());

	if (pszPathName[0] == 0) {
		// Error in dialog, or user pressed cancel
		return;
	}

	msPresetPathName = std::string((char*)pszPathName);

	CAutoDelete<IChunkFile> pFile(IChunkFile::Create());
	tint32 iVersionNumber;
	if (pFile->Open((const tchar*)(msPresetPathName.c_str()),
		IFile::FileRead,
		iVersionNumber)) {
		mpGUI->OnLoadPreset(pFile);
	}
}
开发者ID:grimtraveller,项目名称:koblo_software,代码行数:34,代码来源:CBaseTopPane.cpp


示例11: innerFlush

void innerFlush(FlushData* data)
{
	File::IOFile pFile(data->filename, "wb");
	if (!pFile)
	{
		std::string dir;
		SplitPath(data->filename, &dir, 0, 0);
		if (!File::IsDirectory(dir))
			File::CreateFullPath(dir);
		pFile.Open(data->filename, "wb");
	}

	if (!pFile) // Note - pFile changed inside above if
	{
		PanicAlertT("Could not write memory card file %s.\n\n"
			"Are you running Dolphin from a CD/DVD, or is the save file maybe write protected?", data->filename.c_str());
		return;
	}

	pFile.WriteBytes(data->memcardContent, data->memcardSize);

	if (!data->bExiting)
		Core::DisplayMessage(StringFromFormat("Wrote memory card %c contents to %s",
			data->memcardIndex ? 'B' : 'A', data->filename.c_str()).c_str(), 4000);
	return;
}
开发者ID:NullNoname,项目名称:dolphin,代码行数:26,代码来源:EXI_DeviceMemoryCard.cpp


示例12: pFile

HBITMAP CSkin::LoadBitmap(CString& strName)
{
	int nPos = strName.Find( '$' );

	if ( nPos < 0 )
	{
		CImageFile pFile(strName );
		return CImageFile::LoadBitmap(strName);
	}
	else
	{
		HINSTANCE hInstance = NULL;
		UINT nID = 0;
		
		if ( _stscanf( strName.Left( nPos ), _T("%lu"), &hInstance ) != 1 ) return NULL;
		if ( _stscanf( strName.Mid( nPos + 1 ), _T("%lu"), &nID ) != 1 ) return NULL;

		if ( LPCTSTR pszType = _tcsrchr( strName, '.' ) )
		{
			pszType ++;
			CImageFile::LoadBitmap( hInstance, nID, pszType );
		}
		else
		{
			return (HBITMAP)LoadImage( hInstance, MAKEINTRESOURCE(nID), IMAGE_BITMAP, 0, 0, 0 );
		}
	}
	return NULL;
}
开发者ID:pics860,项目名称:callcenter,代码行数:29,代码来源:skin.cpp


示例13: pFile

// M-- modify the read of point
void RTreeIndex::CreateRTree()
{
	diskfile = StorageManager::createNewDiskStorageManager(treeFile, rtreePageSize);		//4k size page
	file = StorageManager::createNewRandomEvictionsBuffer(*diskfile, cacheblock, false);		//cache block number 1000
	tree = RTree::createNewRTree(*file, 0.7, capacity, capacity, 2, SpatialIndex::RTree::RV_RSTAR, indexIdentifier);

	ifstream pFile(pointFile.c_str());
	if (pFile.is_open())
	{		
		int count = 0;
		while (! pFile.eof() )
		{
			string line;
			getline(pFile, line);
			if(line == "")
				continue;
			int id;char c;
			double coor[2];
			istringstream iss(line);
			// M--
			//iss>> id >>c>>coor[0]>>c>>coor[1];
			iss >> id >> coor[0] >> coor[1];
			Point p = Point(coor, 2);			
			tree->insertData(0, 0, p, count);
			count++;
		}
		pFile.close();		
	}
开发者ID:zpf2013zb,项目名称:KAGWCP,代码行数:29,代码来源:RTreeIndex.cpp


示例14: GetItem

void CSchedulerWnd::OnSchedulerActivate()
{
	HRESULT hr;

	CString sTaskName = GetItem( m_wndList.GetNextItem( -1, LVIS_SELECTED ) );
	if ( sTaskName.IsEmpty() )
		return;

	CComPtr< ITask > pTask;
	hr = m_pScheduler->Activate( sTaskName, IID_ITask, (IUnknown**)&pTask );
	if ( FAILED( hr ) )
		return;

	DWORD nFlags = 0;
	hr = pTask->GetFlags( &nFlags );
	if ( ( nFlags & TASK_FLAG_DISABLED ) == TASK_FLAG_DISABLED )
	{
		hr = pTask->SetFlags( nFlags & ~TASK_FLAG_DISABLED );
		if ( SUCCEEDED( hr ) )
		{
			CComQIPtr< IPersistFile > pFile( pTask );
			if ( pFile )
			{
				hr = pFile->Save( NULL, TRUE );
				if ( SUCCEEDED( hr ) )
				{
					Update();
				}
			}
		}
	}
}
开发者ID:ivan386,项目名称:Shareaza,代码行数:32,代码来源:WndScheduler.cpp


示例15: card_index

CEXIMemoryCard::CEXIMemoryCard(const int index)
	: card_index(index)
	, m_bDirty(false)
{
	m_strFilename = (card_index == 0) ? SConfig::GetInstance().m_strMemoryCardA : SConfig::GetInstance().m_strMemoryCardB;
	if (Movie::IsPlayingInput() && Movie::IsConfigSaved() && Movie::IsUsingMemcard() && Movie::IsStartingFromClearSave())
		m_strFilename = File::GetUserPath(D_GCUSER_IDX) + "Movie.raw";

	// we're potentially leaking events here, since there's no UnregisterEvent until emu shutdown, but I guess it's inconsequential
	et_this_card = CoreTiming::RegisterEvent((card_index == 0) ? "memcardFlushA" : "memcardFlushB", FlushCallback);
	et_cmd_done = CoreTiming::RegisterEvent((card_index == 0) ? "memcardDoneA" : "memcardDoneB", CmdDoneCallback);

	interruptSwitch = 0;
	m_bInterruptSet = 0;
	command = 0;
	status = MC_STATUS_BUSY | MC_STATUS_UNLOCKED | MC_STATUS_READY;
	m_uPosition = 0;
	memset(programming_buffer, 0, sizeof(programming_buffer));
	formatDelay = 0;

	//Nintendo Memory Card EXI IDs
	//0x00000004 Memory Card 59		4Mbit
	//0x00000008 Memory Card 123	8Mb
	//0x00000010 Memory Card 251	16Mb
	//0x00000020 Memory Card 507	32Mb
	//0x00000040 Memory Card 1019	64Mb
	//0x00000080 Memory Card 2043	128Mb

	//0x00000510 16Mb "bigben" card
	//card_id = 0xc243;

	card_id = 0xc221; // It's a Nintendo brand memcard

	File::IOFile pFile(m_strFilename, "rb");
	if (pFile)
	{
		// Measure size of the memcard file.
		memory_card_size = (int)pFile.GetSize();
		nintendo_card_id = memory_card_size / SIZE_TO_Mb;
		memory_card_content = new u8[memory_card_size];
		memset(memory_card_content, 0xFF, memory_card_size);

		INFO_LOG(EXPANSIONINTERFACE, "Reading memory card %s", m_strFilename.c_str());
		pFile.ReadBytes(memory_card_content, memory_card_size);

	}
	else
	{
		// Create a new 128Mb memcard
		nintendo_card_id = 0x00000080;
		memory_card_size = nintendo_card_id * SIZE_TO_Mb;

		memory_card_content = new u8[memory_card_size];
		GCMemcard::Format(memory_card_content, m_strFilename.find(".JAP.raw") != std::string::npos, nintendo_card_id);
		memset(memory_card_content+MC_HDR_SIZE, 0xFF, memory_card_size-MC_HDR_SIZE);
		WARN_LOG(EXPANSIONINTERFACE, "No memory card found. Will create a new one.");
	}
	SetCardFlashID(memory_card_content, card_index);
}
开发者ID:DiamondLord64,项目名称:dolphin-emu,代码行数:59,代码来源:EXI_DeviceMemoryCard.cpp


示例16: pFile

bool DotWriter::SendToDotAppOutputDirectory(const wxString& dot_fn)
{ // (re)write dot.txt file
    wxFile pFile(dot_fn, wxFile::write);

    bool ok = pFile.Write(m_OutputString);

    return ok;
}
开发者ID:eranif,项目名称:codelite,代码行数:8,代码来源:dotwriter.cpp


示例17: m_strFilename

CEXIMemoryCard::CEXIMemoryCard(const std::string& _rName, const std::string& _rFilename, int _card_index) :
	m_strFilename(_rFilename),
	card_index(_card_index),
	m_bDirty(false)
{
	cards[_card_index] = this;
	et_this_card = CoreTiming::RegisterEvent(_rName.c_str(), FlushCallback);
	reloadOnState = SConfig::GetInstance().b_reloadMCOnState;
 
	interruptSwitch = 0;
	m_bInterruptSet = 0;
	command = 0;
	status = MC_STATUS_BUSY | MC_STATUS_UNLOCKED | MC_STATUS_READY;
	m_uPosition = 0;
	memset(programming_buffer, 0, sizeof(programming_buffer));
	formatDelay = 0;
 
	//Nintendo Memory Card EXI IDs
	//0x00000004 Memory Card 59		4Mbit
	//0x00000008 Memory Card 123	8Mb
	//0x00000010 Memory Card 251	16Mb
	//0x00000020 Memory Card 507	32Mb
	//0x00000040 Memory Card 1019	64Mb
	//0x00000080 Memory Card 2043	128Mb
 
	//0x00000510 16Mb "bigben" card
	//card_id = 0xc243;
 
	card_id = 0xc221; // It's a nintendo brand memcard
 
	File::IOFile pFile(m_strFilename, "rb");
	if (pFile)
	{
		// Measure size of the memcard file.
		memory_card_size = (int)pFile.GetSize();
		nintendo_card_id = memory_card_size / SIZE_TO_Mb;
		memory_card_content = new u8[memory_card_size];
		memset(memory_card_content, 0xFF, memory_card_size);
 
		INFO_LOG(EXPANSIONINTERFACE, "Reading memory card %s", m_strFilename.c_str());
		pFile.ReadBytes(memory_card_content, memory_card_size);
		SetCardFlashID(memory_card_content, card_index);

	}
	else
	{
		// Create a new 128Mb memcard
		nintendo_card_id = 0x00000080;
		memory_card_size = nintendo_card_id * SIZE_TO_Mb;

		memory_card_content = new u8[memory_card_size];
		memset(memory_card_content, 0xFF, memory_card_size);
 
		WARN_LOG(EXPANSIONINTERFACE, "No memory card found. Will create new.");
		Flush();
	}
}
开发者ID:NullNoname,项目名称:dolphin,代码行数:57,代码来源:EXI_DeviceMemoryCard.cpp


示例18: pFile

void ObjModel::loadMaterialFile( std::string fileName, std::string dirName )
{
	std::ifstream pFile(fileName.c_str());
	if (!pFile.is_open())
	{
		std::cout << "Could not open file " << fileName << std::endl;
		return;
	}

	MaterialInfo* currentMaterial = NULL;

	while(!pFile.eof())
	{
		std::string line;
		std::getline(pFile, line);

		line = replace(line, "\t", " ");
		line = replace(line, "\r", " ");
		while(line.find("  ") != std::string::npos)
			line = replace(line, "  ", " ");
		if(line == "")
			continue;
		if(line[0] == ' ')
			line = line.substr(1);
		if(line == "")
			continue;
		if(line[line.length()-1] == ' ')
			line = line.substr(0, line.length()-1);
		if(line == "")
			continue;
		if(line[0] == '#')
			continue;

		std::vector<std::string> params = split(line, " ");
		params[0] = toLower(params[0]);

		if(params[0] == "newmtl")
		{
			if(currentMaterial != NULL)
			{
				materials.push_back(currentMaterial);
			}
			currentMaterial = new MaterialInfo();
			currentMaterial->name = params[1];
		}
		else if(params[0] == "map_kd")
		{
			currentMaterial->hasTexture = true;
			currentMaterial->texture = new Texture(dirName + "/" + params[1]);
		}
		else
			std::cout<<"Didn't parse "<<params[0]<<" in material file"<<std::endl;
	}
	if(currentMaterial != NULL)
		materials.push_back(currentMaterial);

}
开发者ID:BilelAvans,项目名称:Menghindar_Diri,代码行数:57,代码来源:ObjModel.cpp


示例19: INFO_LOG

CChunkFileReader::Error CChunkFileReader::SaveFile(const std::string& _rFilename, int _Revision, const char *_VersionString, u8 *buffer, size_t sz) {
    INFO_LOG(COMMON, "ChunkReader: Writing %s" , _rFilename.c_str());

    File::IOFile pFile(_rFilename, "wb");
    if (!pFile)
    {
        ERROR_LOG(COMMON, "ChunkReader: Error opening file for write");
        return ERROR_BAD_FILE;
    }

    bool compress = true;

    // Create header
    SChunkHeader header;
    header.Compress = compress ? 1 : 0;
    header.Revision = _Revision;
    header.ExpectedSize = (u32)sz;
    header.UncompressedSize = (u32)sz;
    strncpy(header.GitVersion, _VersionString, 32);
    header.GitVersion[31] = '\0';

    // Write to file
    if (compress) {
        size_t comp_len = snappy_max_compressed_length(sz);
        u8 *compressed_buffer = new u8[comp_len];
        snappy_compress((const char *)buffer, sz, (char *)compressed_buffer, &comp_len);
        delete [] buffer;
        header.ExpectedSize = (u32)comp_len;
        if (!pFile.WriteArray(&header, 1))
        {
            ERROR_LOG(COMMON, "ChunkReader: Failed writing header");
            return ERROR_BAD_FILE;
        }
        if (!pFile.WriteBytes(&compressed_buffer[0], comp_len)) {
            ERROR_LOG(COMMON, "ChunkReader: Failed writing compressed data");
            return ERROR_BAD_FILE;
        }	else {
            INFO_LOG(COMMON, "Savestate: Compressed %i bytes into %i", (int)sz, (int)comp_len);
        }
        delete [] compressed_buffer;
    } else {
        if (!pFile.WriteArray(&header, 1))
        {
            ERROR_LOG(COMMON, "ChunkReader: Failed writing header");
            return ERROR_BAD_FILE;
        }
        if (!pFile.WriteBytes(&buffer[0], sz))
        {
            ERROR_LOG(COMMON, "ChunkReader: Failed writing data");
            return ERROR_BAD_FILE;
        }
        delete [] buffer;
    }

    INFO_LOG(COMMON, "ChunkReader: Done writing %s",  _rFilename.c_str());
    return ERROR_NONE;
}
开发者ID:CTimpone,项目名称:libretro-ppsspp,代码行数:57,代码来源:ChunkFile.cpp


示例20: pCons

void CPocoLoggerTester::test_SplitterLogger()
{
    Poco::AutoPtr<Poco::ConsoleChannel> pCons(new Poco::ConsoleChannel);  
    Poco::AutoPtr<Poco::SimpleFileChannel> pFile(new Poco::SimpleFileChannel("test.log"));  
    Poco::AutoPtr<Poco::SplitterChannel> pSplitter(new Poco::SplitterChannel);  
    pSplitter->addChannel(pCons);  
    pSplitter->addChannel(pFile);  
    Poco::Logger::root().setChannel(pSplitter);  
    Poco::Logger::root().information("This is a test");
}
开发者ID:moon-sky,项目名称:fishjam-template-library,代码行数:10,代码来源:PocoLoggerTester.cpp



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ pLock函数代码示例发布时间:2022-05-30
下一篇:
C++ p9_debug函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap