您当前的位置:首页 > IT编程 > C++
| C语言 | Java | VB | VC | python | Android | TensorFlow | C++ | oracle | 学术与代码 | cnn卷积神经网络 | gnn | 图像修复 | Keras | 数据集 | Neo4j | 自然语言处理 | 深度学习 | 医学CAD | 医学影像 | 超参数 | pointnet | pytorch | 异常检测 | Transformers | 情感分类 | 知识图谱 |

自学教程:C++ FileRead函数代码示例

51自学网 2021-06-01 20:46:07
  C++
这篇教程C++ FileRead函数代码示例写得很实用,希望能帮到您。

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

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

示例1: ShowMessage

//---------------------------------------------------------------------------void __fastcall TMainForm::LabeledEditKeyDown(TObject *Sender, WORD &Key, TShiftState Shift){	if (Key !=0x0D) return;	RichEditPrintTicket->Clear();	LabeledEdit->ReadOnly =true;	AnsiString binFileStr =controller->config->BinFileDir +"ticket//" +LabeledEdit->Text +".bin";	if (!FileExists(binFileStr)){        ShowMessage("票号搞错了吧,没有找到这张票的数据,重新输入吧!");		return;	}	int hBinFile = FileOpen(binFileStr, fmOpenRead);	char bin[16384] ={0};	int nRead =FileRead(hBinFile, bin, sizeof(bin));	//解密文件	char *srcBin =new char[nRead];	controller->Decrypt(bin, nRead, srcBin);	FileClose(hBinFile);	char stubTxt[16384] ={0};	//借用个对象,计算一下	if (controller->terminalGroup->Count ==0) return;	CTerminal *terminal =(CTerminal *)controller->terminalGroup->Objects[0];	terminal->ParserVerifyStub(nRead, srcBin, stubTxt);	delete srcBin;	//显示票根,转换一下,避免单行超过1024字节,控件限制的错误	TStringList *text =new TStringList();	text->Text =AnsiString(stubTxt);	RichEditPrintTicket->Clear();	RichEditPrintTicket->Lines->AddStrings(text);	RichEditPrintTicket->Perform(WM_VSCROLL, SB_TOP, 0); //光标归位,免得滚下去难看	delete text;	SpeedButtonPrinterPrint->Enabled =true;}
开发者ID:limitee,项目名称:bot,代码行数:32,


示例2: ReadInFoodOpinionStats

BOOLEAN ReadInFoodOpinionStats(STR fileName){	HWFILE		hFile;	UINT32		uiBytesRead;	UINT32		uiFSize;	CHAR8 *		lpcBuffer;	XML_Parser	parser = XML_ParserCreate(NULL);	foodopinionParseData pData;	DebugMsg(TOPIC_JA2, DBG_LEVEL_3, "Loading FoodOpinion.xml" );	// Open file	hFile = FileOpen( fileName, FILE_ACCESS_READ, FALSE );	// if the file does not exist, exit	// Flugente: no need to quit the game if the xml does not exist - this data just won't be there, but the game will still work	if ( !hFile )		return( TRUE );	uiFSize = FileGetSize(hFile);	lpcBuffer = (CHAR8 *) MemAlloc(uiFSize+1);	//Read in block	if ( !FileRead( hFile, lpcBuffer, uiFSize, &uiBytesRead ) )	{		MemFree(lpcBuffer);		return( FALSE );	}	lpcBuffer[uiFSize] = 0; //add a null terminator	FileClose( hFile );	XML_SetElementHandler(parser, foodopinionStartElementHandle, foodopinionEndElementHandle);	XML_SetCharacterDataHandler(parser, foodopinionCharacterDataHandle);	memset(&pData,0,sizeof(pData));	pData.curArray = FoodOpinions;	pData.maxArraySize = NUM_PROFILES;	XML_SetUserData(parser, &pData);	if(!XML_Parse(parser, lpcBuffer, uiFSize, TRUE))	{		CHAR8 errorBuf[511];		sprintf(errorBuf, "XML Parser Error in FoodOpinion.xml: %s at line %d", XML_ErrorString(XML_GetErrorCode(parser)), XML_GetCurrentLineNumber(parser));		LiveMessage(errorBuf);		MemFree(lpcBuffer);		return FALSE;	}	MemFree(lpcBuffer);	XML_ParserFree(parser);	return( TRUE );}
开发者ID:fedya,项目名称:ja2_v1.13,代码行数:60,


示例3: BufFileLoadBuffer

/* * BufFileLoadBuffer * * Load some data into buffer, if possible, starting from curOffset. * At call, must have dirty = false, pos and nbytes = 0. * On exit, nbytes is number of bytes loaded. */static int BufFileLoadBuffer(BufFile *file, void* buffer, size_t bufsize){	int nb;	/*	 * May need to reposition physical file.	 */	if (FileSeek(file->file, file->offset, SEEK_SET) != file->offset)	{		elog(ERROR, "could not seek in temporary file: %m");	}	/*	 * Read whatever we can get, up to a full bufferload.	 */	nb = FileRead(file->file, buffer, (int)bufsize);	if (nb < 0)	{		elog(ERROR, "could not read from temporary file: %m");	}	/* we choose not to advance curOffset here */	return nb;}
开发者ID:AnLingm,项目名称:gpdb,代码行数:32,


示例4: UploadKickstart

//// UploadKickstart() ////char UploadKickstart(char *name){  int keysize=0;  char filename[12];  strncpy(filename, name, 8); // copy base name  strcpy(&filename[8], "ROM"); // add extension  BootPrint("Checking for Amiga Forever key file:");  if(FileOpen(&file,"ROM     KEY")) {    keysize=file.size;    if(file.size<sizeof(romkey)) {      int c=0;      while(c<keysize) {        FileRead(&file, &romkey[c]);        c+=512;        FileNextSector(&file);      }      BootPrint("Loaded Amiga Forever key file");    } else {      BootPrint("Amiga Forever keyfile is too large!");    }  }  BootPrint("Loading file: ");  BootPrint(filename);  if (RAOpen(&romfile, filename)) {    if (romfile.size == 0x100000) {      // 1MB Kickstart ROM      BootPrint("Uploading 1MB Kickstart ...");      SendFileV2(&romfile, NULL, 0, 0xe00000, romfile.size>>10);      SendFileV2(&romfile, NULL, 0, 0xf80000, romfile.size>>10);      return(1);    } else if(romfile.size == 0x80000) {
开发者ID:UIKit0,项目名称:mist-firmware,代码行数:35,


示例5: getSystemVersion

void getSystemVersion(){	File VersionFile;	char sysver[16];	if (FileOpen(&VersionFile, "/3ds/ASCFW/system.txt", 0)){		FileRead(&VersionFile, sysver, 16, 0);		FileClose(&VersionFile);	}	switch (sysver[0])	{	case '0': //Unsupported		systemVersion = "unsupported"; type = 0;		break;	case '1':		systemVersion = "Old 3DS V. 4.1 - 4.5";		type = 1;		break;	case '2':		systemVersion = "Old 3DS V. 8.0 - 8.1"; 		type = 2;		break;	case '3':		systemVersion = "Old 3DS V. 9.0-9.2"; 		type = 3;		break;	case '4':		systemVersion = "New 3DS V. 9.0 - 9.2";		type = 4;		break;	}}
开发者ID:AlbertoSONIC,项目名称:3DS_ASCFW,代码行数:35,


示例6: GetSysFreeMem

// returns no of bytes of free memory  conform to sysinfo call// return 0 if error occured//we need /proc/meminfo for cached, which is not reported by sysinfoint GetSysFreeMem( void ){#ifdef CYG	return 0;#else	char szData[1024];	int nLen = FileRead("/proc/meminfo", szData, sizeof(szData) - 1);	if (nLen<=0)	{	return -1;	}	szData[nLen] = 0;	struct sysinfo inf;	if ( sysinfo( &inf) )	{		LOG_ERR("ERROR GetSysFreeMem");		inf.freeram=0;	}	struct statfs buf;	long long nTmpUsed = 0;	if( statfs( "/tmp", &buf)) {		LOG_ERR( "GetSysFreeMem: statfs( /"tmp/") failed");	}else{		nTmpUsed= (buf.f_blocks-buf.f_bavail) * (long long) buf.f_bsize;	}	return inf.freeram * inf.mem_unit +		( GetFreeMemFor( szData, "Buffers:") + GetFreeMemFor( szData, "Cached:")) * 1024 - nTmpUsed;#endif}
开发者ID:dndusdndus12,项目名称:ISA100.11a-Gateway-1,代码行数:38,


示例7: LOG_ERR

CIsa100Impl::SystemStatus* CIsa100Impl::getSystemStatus( void ){    struct sysinfo inf;    struct statfs  buf;    if ( sysinfo( &inf) )    {        LOG_ERR("ERROR getSystemStatus: sysinfo");        inf.freeram = inf.totalram = 0;    }    if( statfs( "/access_node/", &buf))    {        LOG_ERR("ERROR getSystemStatus: statfs");        buf.f_blocks = buf.f_bavail = buf.f_bsize = 0;    }    doProcessorStats();    int nLen = FileRead("/proc/loadavg", m_systemStatus.load, sizeof(m_systemStatus.load) - 1);    if (nLen<=0)    {   nLen =0;    }    m_systemStatus.load[ nLen ] = 0;    m_systemStatus.sysMemTotalKb = inf.totalram / 1024;    m_systemStatus.sysMemFreeKb  = inf.freeram  / 1024;    m_systemStatus.sysFlashTotalKb = buf.f_blocks * buf.f_bsize / 1024;    m_systemStatus.sysFlashFreeKb  = buf.f_bavail * buf.f_bsize / 1024;    return &m_systemStatus;}
开发者ID:irares,项目名称:WirelessHart-Gateway,代码行数:32,


示例8: while

char *FileGets( char *string, int num, FHANDLE fh ){	char	c;	int		ret	= 0;	int		i	= 0;	while( i < num ) {		ret = FileRead( fh, &c, 1 );		if( ret < 1 )			break;		string[i] = c;		i++;		if( c == '/n' )			break;	}	if( (i >= 2 ) && string[ i - 2 ] == '/r' ) {		string[ i - 2 ] = '/n';		string[ i - 1 ] = '/0';	}	else {		string[i] = '/0';	}	if( ret < 1 )		return NULL;	return string;}
开发者ID:smiley22,项目名称:myPS2,代码行数:32,


示例9: IsSTCIETRLEFile

BOOLEAN IsSTCIETRLEFile( CHAR8 * ImageFile ){	HWFILE		hFile;	STCIHeader	Header;	UINT32		uiBytesRead;	CHECKF( FileExists( ImageFile ) );	// Open the file and read the header	hFile = FileOpen( ImageFile, FILE_ACCESS_READ, FALSE );	CHECKF( hFile );	if (!FileRead( hFile, &Header, STCI_HEADER_SIZE, &uiBytesRead ) || uiBytesRead != STCI_HEADER_SIZE || memcmp( Header.cID, STCI_ID_STRING, STCI_ID_LEN ) != 0 )	{		DbgMessage( TOPIC_HIMAGE, DBG_LEVEL_3, "Problem reading STCI header." );		FileClose( hFile );		return( FALSE );	}	FileClose( hFile );	if (Header.fFlags & STCI_ETRLE_COMPRESSED)	{	 return( TRUE );	}	else	{	 return( FALSE );	}}
开发者ID:RadekSimkanic,项目名称:JA2-1.13,代码行数:28,


示例10: ConnWriteFromFile

abyss_boolConnWriteFromFile(TConn *  const connectionP,                  TFile *  const fileP,                  uint64_t const start,                  uint64_t const last,                  void *   const buffer,                  uint32_t const buffersize,                  uint32_t const rate) {    /*----------------------------------------------------------------------------       Write the contents of the file stream *fileP, from offset 'start'       up through 'last', to the HTTP connection *connectionP.       Meter the reading so as not to read more than 'rate' bytes per second.       Use the 'bufferSize' bytes at 'buffer' as an internal buffer for this.    -----------------------------------------------------------------------------*/    abyss_bool retval;    uint32_t waittime;    abyss_bool success;    uint32_t readChunkSize;    if (rate > 0) {        readChunkSize = MIN(buffersize, rate);  /* One second's worth */        waittime = (1000 * buffersize) / rate;    } else {        readChunkSize = buffersize;        waittime = 0;    }    success = FileSeek(fileP, start, SEEK_SET);    if (!success)        retval = FALSE;    else {        uint64_t const totalBytesToRead = last - start + 1;        uint64_t bytesread;        bytesread = 0;  /* initial value */        while (bytesread < totalBytesToRead) {            uint64_t const bytesLeft = totalBytesToRead - bytesread;            uint64_t const bytesToRead = MIN(readChunkSize, bytesLeft);            uint64_t bytesReadThisTime;            bytesReadThisTime = FileRead(fileP, buffer, bytesToRead);            bytesread += bytesReadThisTime;            if (bytesReadThisTime > 0)                ConnWrite(connectionP, buffer, bytesReadThisTime);            else                break;            if (waittime > 0)                xmlrpc_millisecond_sleep(waittime);        }        retval = (bytesread >= totalBytesToRead);    }    return retval;}
开发者ID:austin98x,项目名称:opensips,代码行数:59,


示例11: LoadSettings

void LoadSettings(){	char settings[]="000100";	char str[100];	File MyFile;	if (FileOpen(&MyFile, "/rxTools/data/system.txt", 0))	{		if (FileGetSize(&MyFile) == 6)		{			FileRead(&MyFile, settings, 6, 0);			bootGUI = (settings[0] == '1');			agb_bios = (settings[2] == '1');			theme_3d = (settings[3] == '1');			silent_boot = (settings[4] == '1');						/* Disable autostart after the first boot */			if (first_boot && !bootGUI) bootGUI = true;						/* Check if the Theme Number is valid */			unsigned char theme_num = (settings[0] - 0x30);			if (theme_num >= 0 && theme_num <= 9)			{				File Menu0;				sprintf(str, "/rxTools/Theme/%c/menu0.bin", settings[1]);				if (FileOpen(&Menu0, str, 0))				{					Theme = settings[1]; //check if the theme exists, else load theme 0 (default)					FileClose(&Menu0);				} else					Theme = '0';			} else {				Theme = '0';				FileWrite(&MyFile, &Theme, 1, 1);			}			/* Check if the Language Number is valid */			if(settings[5] - 0x30 >= 0 && settings[5] - 0x30 <= N_LANG)				language = settings[5] - 0x30;			else				language = 0;			FileClose(&MyFile);			return;		} else {			FileClose(&MyFile);		}	}		/* Disable autostart after the first boot */	bootGUI = first_boot;	Theme = '0';	agb_bios = false;		/* Create system.txt */	if (FileOpen(&MyFile, "/rxTools/data/system.txt", 1))	{		FileWrite(&MyFile, settings, 6, 0);		FileClose(&MyFile);	}}
开发者ID:Golui,项目名称:rxTools,代码行数:59,


示例12: lo_import_internal

static Oidlo_import_internal(text *filename, Oid lobjOid){	File		fd;	int			nbytes,				tmp;	char		buf[BUFSIZE];	char		fnamebuf[MAXPGPATH];	LargeObjectDesc *lobj;	Oid			oid;#ifndef ALLOW_DANGEROUS_LO_FUNCTIONS	if (!superuser())		ereport(ERROR,				(errcode(ERRCODE_INSUFFICIENT_PRIVILEGE),				 errmsg("must be superuser to use server-side lo_import()"),				 errhint("Anyone can use the client-side lo_import() provided by libpq.")));#endif	CreateFSContext();	/*	 * open the file to be read in	 */	text_to_cstring_buffer(filename, fnamebuf, sizeof(fnamebuf));	fd = PathNameOpenFile(fnamebuf, O_RDONLY | PG_BINARY, S_IRWXU);	if (fd < 0)		ereport(ERROR,				(errcode_for_file_access(),				 errmsg("could not open server file /"%s/": %m",						fnamebuf)));	/*	 * create an inversion object	 */	oid = inv_create(lobjOid);	/*	 * read in from the filesystem and write to the inversion object	 */	lobj = inv_open(oid, INV_WRITE, fscxt);	while ((nbytes = FileRead(fd, buf, BUFSIZE)) > 0)	{		tmp = inv_write(lobj, buf, nbytes);		Assert(tmp == nbytes);	}	if (nbytes < 0)		ereport(ERROR,				(errcode_for_file_access(),				 errmsg("could not read server file /"%s/": %m",						fnamebuf)));	inv_close(lobj);	FileClose(fd);	return oid;}
开发者ID:GisKook,项目名称:Gis,代码行数:59,


示例13: RARead

int RARead(RAFile *file,unsigned char *pBuffer, unsigned long bytes){	int result=1;	// Since we can only read from the SD card on 512-byte aligned boundaries,	// we need to copy in multiple pieces.	unsigned long blockoffset=file->ptr&511;	// Offset within the current 512 block at which the previous read finished												// Bytes blockoffset to 512 will be drained first, before reading new data.	if(blockoffset)	// If blockoffset is zero we'll just use aligned reads and don't need to drain the buffer.	{		int i;		int l=bytes;		if(l>512)			l=512;		for(i=blockoffset;i<l;++i)		{			*pBuffer++=file->buffer[i];		}		file->ptr+=l-blockoffset;		bytes-=l-blockoffset;	}	// We've now read any bytes left over from a previous read.  If any data remains to be read we can read it	// in 512-byte aligned chunks, until the last block.	while(bytes>511)	{		result&=FileRead(&file->file,pBuffer);	// Read direct to pBuffer		FileNextSector(&file->file);		bytes-=512;		file->ptr+=512;		pBuffer+=512;	}	if(bytes)	// Do we have any bytes left to read?	{		int i;		result&=FileRead(&file->file,file->buffer);	// Read to temporary buffer, allowing us to preserve any leftover for the next read.		FileNextSector(&file->file);		for(i=0;i<bytes;++i)		{			*pBuffer++=file->buffer[i];		}		file->ptr+=bytes;	}	return(result);}
开发者ID:EgoIncarnate,项目名称:mist-board,代码行数:46,


示例14: palm_fread

/*============================================================================  Description: See documentation for standard C library fread  ==========================================================================*/size_t palm_fread( void* out_buf, size_t in_size, size_t in_count, PALM_FILE* io_pSF ){    Err err = 0;    ChASSERT(io_pSF->volRef == ((UInt16)-1));    return FileRead( io_pSF->file.fh, out_buf, in_size, in_count, &err );}
开发者ID:killbug2004,项目名称:WSProf,代码行数:13,


示例15: FileGetc

int FileGetc( FHANDLE fh ){	char c;	FileRead( fh, &c, 1 );	return c;}
开发者ID:smiley22,项目名称:myPS2,代码行数:8,


示例16: FileSeek

	// Return AAL_OK if chunk is found                                        //	aalSBool ChunkFile::Find(const char * id)	{		aalUByte cc[4];		FileSeek(file, offset, SEEK_CUR);		while (FileRead(cc, 4, 1, file))		{			if (!FileRead(&offset, 4, 1, file)) return AAL_SFALSE;			if (!memcmp(cc, id, 4)) return AAL_STRUE;			if (FileSeek(file, offset, SEEK_CUR)) return AAL_SFALSE;		}		return AAL_SFALSE;	}
开发者ID:OpenSourcedGames,项目名称:Arx-Fatalis,代码行数:18,


示例17: FromString

/** * @brief Takes a JSON document file path and parses its contents into a JsonDocument. * * Returns true iff successfull. */bool JsonProcessor::FromFile (const std::string& fn, JsonDocument& document){    if (!FileExists(fn)) {        LOG_WARN << "JSON file '" << fn << "' does not exist.";        return false;    }    return FromString(FileRead(fn), document);}
开发者ID:daviddao,项目名称:genesis,代码行数:13,


示例18: Read

	///////////////////////////////////////////////////////////////////////////////	//                                                                           //	// I/O                                                                       //	//                                                                           //	///////////////////////////////////////////////////////////////////////////////	// Read!                                                                     //	aalSBool ChunkFile::Read(aalVoid * buffer, const aalULong & size)	{		if (FileRead(buffer, 1, size, file) != size) return AAL_SFALSE;		if (offset) offset -= size;		return AAL_STRUE;	}
开发者ID:OpenSourcedGames,项目名称:Arx-Fatalis,代码行数:14,


示例19: FromString

/** * @brief Reads a file and parses it as a Jplace document into a PlacementMap object. * * Returns true iff successful. */bool JplaceProcessor::FromFile (const std::string& fn, PlacementMap& placements){    if (!FileExists(fn)) {        LOG_WARN << "Jplace file '" << fn << "' does not exist.";        return false;    }    return FromString(FileRead(fn), placements);}
开发者ID:daviddao,项目名称:genesis,代码行数:13,


示例20: ConfReadLine

static boolConfReadLine(TFile *  const fileP,             char *   const buffer,             uint32_t const lenArg) {    bool r;    char c;    char * p;    char * z;    uint32_t len;    len = lenArg;  /* initial value */    r = TRUE;  /* initial value */    z = buffer;  /* initial value */    while (--len > 0) {        int32_t bytesRead;                bytesRead = FileRead(fileP, z, 1);        if (bytesRead < 1) {            if (z == buffer)                r = FALSE;            break;        };        if (*z == CR || *z == LF)            break;        ++z;    }    if (len == 0)        while (FileRead(fileP, &c, 1) == 1)            if (c == CR || c == LF)                break;    *z = '/0';    /* Discard comments */    p = strchr(buffer, '#');    if (p)        *p = '/0';    return r;}
开发者ID:BehnamEmamian,项目名称:openholdembot,代码行数:45,


示例21: FileRead

//---------------------------------------------------------------------------int __fastcall TSafeHandleStream::Read(void * Buffer, int Count){  int Result = FileRead(FHandle, Buffer, Count);  if (Result == -1)  {    RaiseLastOSError();  }  return Result;}
开发者ID:elazzi,项目名称:winscp,代码行数:10,


示例22: Nova_DumpSlots

static void Nova_DumpSlots(void){#define MAX_KEY_FILE_SIZE 16384  /* usually around 4000, cannot grow much */    char filename[CF_BUFSIZE];    int i;    snprintf(filename, CF_BUFSIZE - 1, "%s%cts_key", GetStateDir(), FILE_SEPARATOR);    char file_contents_new[MAX_KEY_FILE_SIZE] = {0};    for (i = 0; i < CF_OBSERVABLES; i++)    {        char line[CF_MAXVARSIZE];        if (NovaHasSlot(i))        {            snprintf(line, sizeof(line), "%d,%s,%s,%s,%.3lf,%.3lf,%d/n",                    i,                    NULLStringToEmpty((char*)NovaGetSlotName(i)),                    NULLStringToEmpty((char*)NovaGetSlotDescription(i)),                    NULLStringToEmpty((char*)NovaGetSlotUnits(i)),                    NovaGetSlotExpectedMinimum(i), NovaGetSlotExpectedMaximum(i), NovaIsSlotConsolidable(i) ? 1 : 0);        }        else        {            snprintf(line, sizeof(line), "%d,spare,unused/n", i);        }        strlcat(file_contents_new, line, sizeof(file_contents_new));    }    bool contents_changed = true;    Writer *w = FileRead(filename, MAX_KEY_FILE_SIZE, NULL);    if (w)    {        if(strcmp(StringWriterData(w), file_contents_new) == 0)        {            contents_changed = false;        }        WriterClose(w);    }    if(contents_changed)    {        Log(LOG_LEVEL_VERBOSE, "Updating %s with new slot information", filename);        if(!FileWriteOver(filename, file_contents_new))        {            Log(LOG_LEVEL_ERR, "Nova_DumpSlots: Could not write file '%s'. (FileWriteOver: %s)", filename,                GetErrorStr());        }    }    chmod(filename, 0600);}
开发者ID:basvandervlies,项目名称:core,代码行数:57,


示例23: palm_fgetc

/*============================================================================  Description: See documentation for standard C library fgetc  ==========================================================================*/short palm_fgetc( PALM_FILE* io_pSF ){    Err err = 0;    char cRet = 0;    ChASSERT(io_pSF->volRef == ((UInt16)-1));    return ( 1 == FileRead( io_pSF->file.fh, (void*)(&cRet), 1, 1, &err )) ? (short)cRet : EOF;}
开发者ID:killbug2004,项目名称:WSProf,代码行数:14,


示例24: LoadContractRenewalDataFromSaveGameFile

BOOLEAN LoadContractRenewalDataFromSaveGameFile( HWFILE hFile ){	UINT32	uiNumBytesRead;	FileRead( hFile, ContractRenewalList, sizeof( ContractRenewalList ), &uiNumBytesRead );	if( uiNumBytesRead != sizeof( ContractRenewalList ) )	{		return( FALSE );	}	FileRead( hFile, &ubNumContractRenewals, sizeof( ubNumContractRenewals ), &uiNumBytesRead );	if( uiNumBytesRead != sizeof( ubNumContractRenewals ) )	{		return( FALSE );	}  return( TRUE );}
开发者ID:bowlofstew,项目名称:ja2,代码行数:18,


示例25: ReadInPatrolInfo

BOOLEAN ReadInPatrolInfo(STR fileName){	HWFILE		hFile;	UINT32		uiBytesRead;	UINT32		uiFSize;	CHAR8 *		lpcBuffer;	XML_Parser	parser = XML_ParserCreate(NULL);	patrolParseData pData;	// Open weapons file	hFile = FileOpen( fileName, FILE_ACCESS_READ, FALSE );	if ( !hFile )		return( FALSE );	uiFSize = FileGetSize(hFile);	lpcBuffer = (CHAR8 *) MemAlloc(uiFSize+1);	//Read in block	if ( !FileRead( hFile, lpcBuffer, uiFSize, &uiBytesRead ) )	{		MemFree(lpcBuffer);		return( FALSE );	}	lpcBuffer[uiFSize] = 0; //add a null terminator	FileClose( hFile );	XML_SetElementHandler(parser, patrolStartElementHandle, patrolEndElementHandle);	XML_SetCharacterDataHandler(parser, patrolCharacterDataHandle);	memset(&pData,0,sizeof(pData));	XML_SetUserData(parser, &pData);	iOrigPatrolArraySize = 0;	if(!XML_Parse(parser, lpcBuffer, uiFSize, TRUE))	{		CHAR8 errorBuf[511];		sprintf(errorBuf, "XML Parser Error in PatrolGroups.xml: %s at line %d", XML_ErrorString(XML_GetErrorCode(parser)), XML_GetCurrentLineNumber(parser));		LiveMessage(errorBuf);		MemFree(lpcBuffer);		return FALSE;	}	MemFree(lpcBuffer);	XML_ParserFree(parser);	return TRUE;}
开发者ID:RadekSimkanic,项目名称:JA2-1.13,代码行数:56,


示例26: HandleLimitedNumExecutions

void HandleLimitedNumExecutions( ){	// Get system directory  HWFILE     hFileHandle;	UINT8	ubSysDir[ 512 ];	INT8	bNumRuns;	GetSystemDirectory( ubSysDir, sizeof( ubSysDir ) );	// Append filename	strcat( ubSysDir, "//winaese.dll" );	// Open file and check # runs...	if ( FileExists( ubSysDir ) )	{		// Open and read		if ( ( hFileHandle = FileOpen( ubSysDir, FILE_ACCESS_READ, FALSE)) == 0)		{			return;		}		// Read value		FileRead( hFileHandle, &bNumRuns, sizeof( bNumRuns ) , NULL);		// Close file		FileClose( hFileHandle );		if ( bNumRuns <= 0 )		{			// Fail!			SET_ERROR( "Error 1054: Cannot execute - contact Sir-Tech Software." );			return;		}			}	else	{		bNumRuns = 10;	}	// OK, decrement # runs...	bNumRuns--;	// Open and write	if ( ( hFileHandle = FileOpen( ubSysDir, FILE_ACCESS_WRITE, FALSE)) == 0)	{		return;	}	// Write value	FileWrite( hFileHandle, &bNumRuns, sizeof( bNumRuns ) , NULL);	// Close file	FileClose( hFileHandle );}
开发者ID:bowlofstew,项目名称:ja2,代码行数:56,


示例27: BeginChangeFile

static HRESULT BeginChangeFile(    __in LPCWSTR pwzFile,    __in int iCompAttributes,    __inout LPWSTR* ppwzCustomActionData    ){    Assert(pwzFile && *pwzFile && ppwzCustomActionData);    HRESULT hr = S_OK;    BOOL fIs64Bit = iCompAttributes & msidbComponentAttributes64bit;    LPBYTE pbData = NULL;    DWORD cbData = 0;    LPWSTR pwzRollbackCustomActionData = NULL;    if (fIs64Bit)    {        hr = WcaWriteIntegerToCaData((int)xaOpenFilex64, ppwzCustomActionData);        ExitOnFailure(hr, "failed to write 64-bit file indicator to custom action data");    }    else    {        hr = WcaWriteIntegerToCaData((int)xaOpenFile, ppwzCustomActionData);        ExitOnFailure(hr, "failed to write file indicator to custom action data");    }    hr = WcaWriteStringToCaData(pwzFile, ppwzCustomActionData);    ExitOnFailure1(hr, "failed to write file to custom action data: %ls", pwzFile);    // If the file already exits, then we have to put it back the way it was on failure    if (FileExistsEx(pwzFile, NULL))    {        hr = FileRead(&pbData, &cbData, pwzFile);        ExitOnFailure1(hr, "failed to read file: %ls", pwzFile);        // Set up the rollback for this file        hr = WcaWriteIntegerToCaData((int)fIs64Bit, &pwzRollbackCustomActionData);        ExitOnFailure(hr, "failed to write component bitness to rollback custom action data");        hr = WcaWriteStringToCaData(pwzFile, &pwzRollbackCustomActionData);        ExitOnFailure1(hr, "failed to write file name to rollback custom action data: %ls", pwzFile);        hr = WcaWriteStreamToCaData(pbData, cbData, &pwzRollbackCustomActionData);        ExitOnFailure(hr, "failed to write file contents to rollback custom action data.");        hr = WcaDoDeferredAction(PLATFORM_DECORATION(L"ExecXmlConfigRollback"), pwzRollbackCustomActionData, COST_XMLFILE);        ExitOnFailure1(hr, "failed to schedule ExecXmlConfigRollback for file: %ls", pwzFile);        ReleaseStr(pwzRollbackCustomActionData);    }LExit:    ReleaseMem(pbData);    return hr;}
开发者ID:BMurri,项目名称:wix3,代码行数:56,



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


C++ FileSeek函数代码示例
C++ FilePath函数代码示例
万事OK自学网:51自学网_软件自学网_CAD自学网自学excel、自学PS、自学CAD、自学C语言、自学css3实例,是一个通过网络自主学习工作技能的自学平台,网友喜欢的软件自学网站。