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

C++ FileRead函数代码示例

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

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



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


示例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,代码来源:XML_FoodOpinions.cpp


示例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,代码来源:buffile.c


示例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,代码来源:config.c


示例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,代码来源:main.c


示例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 sysinfo
int 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,代码来源:Utils.cpp


示例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,代码来源:Isa100Impl.cpp


示例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,代码来源:file.c


示例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,代码来源:STCI.cpp


示例10: ConnWriteFromFile

abyss_bool
ConnWriteFromFile(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,代码来源:abyss_conn.c


示例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,代码来源:main.c


示例12: lo_import_internal

static Oid
lo_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,代码来源:be-fsstubs.c


示例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,代码来源:rafile.c


示例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,代码来源:ChFileIO.cpp


示例15: FileGetc

int FileGetc( FHANDLE fh )
{
	char c;

	FileRead( fh, &c, 1 );

	return c;
}
开发者ID:smiley22,项目名称:myPS2,代码行数:8,代码来源:file.c


示例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,代码来源:Athena_Stream_WAV.cpp


示例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,代码来源:json_processor.cpp


示例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,代码来源:Athena_Stream_WAV.cpp


示例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,代码来源:jplace_processor.cpp


示例20: ConfReadLine

static bool
ConfReadLine(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,代码来源:conf.c



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
C++ FileSeek函数代码示例发布时间:2022-05-30
下一篇:
C++ FilePath函数代码示例发布时间: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