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


C++ pFile函数代码示例

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


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


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