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

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

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

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

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

示例1: SaveToFile

staticvoid SaveToFile(Widget w, FILE *fp){	DviWidget dw = (DviWidget)w;	long pos;	int c;	if (dw->dvi.tmpFile) {		pos = ftell(dw->dvi.tmpFile);		if (dw->dvi.ungot) {			pos--;			dw->dvi.ungot = 0;			/* The ungot character is in the tmpFile, so we don't			   want to read it from file. */			(void)getc(dw->dvi.file);		}	}	else		pos = ftell(dw->dvi.file);	FileSeek(dw, 0L);	while (DviGetC(dw, &c) != EOF)		if (putc(c, fp) == EOF) {			/* XXX print error message */			break;		}	FileSeek(dw, pos);}
开发者ID:ajinkya93,项目名称:netbsd-src,代码行数:27,


示例2: FileOpen

void __fastcall TFrmMain::btRowSaveClick(TObject* Sender){    if (OpenOk == false) return;    int iFileHandle; //文件句柄    char Txtbuf[255];    int iVal;    char buf[4];    float fVal;    FILE* stream;    long curpos, length;    DWORD dwRows, dwCols, dwRowLen, dwTextLen;    DWORD dwTextStartPos;    char* pTextPtr ;    //if ((stream = fopen(CurrentOpenFile.c_str(), "r+"))    //    == NULL)    //{    //   ShowMessage("打开文件出错");    //   return;    //}    //curpos = ftell(stream);    //fseek(stream, 0L, SEEK_END);    //length = ftell(stream);    iFileHandle = FileOpen(CurrentOpenFile, fmOpenRead | fmOpenWrite); //打开文件    for (int i = 0; i < sgEdit->ColCount - 1; i++)    {        switch (thOpen->ColType[i])        {            case 0: //整型值             sgEdit->Row                //fseek(stream, 0x14+((sgEdit->Row-1)*(sgEdit->ColCount-1)+i)*4, 0);                //iVal=StrToInt(sgEdit->Cells[i+1][sgEdit->Row]);                //fwrite(&iVal, 4, 1, stream);                iVal = StrToInt(sgEdit->Cells[i + 1][sgEdit->Row]);                memcpy(buf, &iVal, 4);                FileSeek(iFileHandle, 0x14 + ((sgEdit->Row - 1) * (sgEdit->ColCount - 1) + i) * 4, 0);                FileWrite(iFileHandle, buf, 4);                break;            case 1: //浮点值                //fseek(stream, 0x14+((sgEdit->Row-1)*(sgEdit->ColCount-1)+i)*4, 0);                //fVal=StrToFloat(sgEdit->Cells[i+1][sgEdit->Row]);                //fwrite(&fVal, 4, 1, stream);                fVal = StrToFloat(sgEdit->Cells[i + 1][sgEdit->Row]);                memcpy(buf, &fVal, 4);                FileSeek(iFileHandle, 0x14 + ((sgEdit->Row - 1) * (sgEdit->ColCount - 1) + i) * 4, 0);                FileWrite(iFileHandle, buf, 4);                break;            case 2: //文本   不存                break;        }    }    //fclose(stream);    FileClose(iFileHandle);    ShowMessage("The " + IntToStr(sgEdit->Row) + " Row Write Ok!");}
开发者ID:natedahl32,项目名称:portalclassic,代码行数:59,


示例3: mdextend

/* *	mdextend() -- Add a block to the specified relation. * *		The semantics are basically the same as mdwrite(): write at the *		specified position.  However, we are expecting to extend the *		relation (ie, blocknum is the current EOF), and so in case of *		failure we clean up by truncating. * *		This routine returns true or false, with errno set as appropriate. * * Note: this routine used to call mdnblocks() to get the block position * to write at, but that's pretty silly since the caller needs to know where * the block will be written, and accordingly must have done mdnblocks() * already.  Might as well pass in the position and save a seek. */boolmdextend(SMgrRelation reln, BlockNumber blocknum, char *buffer, bool isTemp){	long		seekpos;	int			nbytes;	MdfdVec    *v;	v = _mdfd_getseg(reln, blocknum, false);#ifndef LET_OS_MANAGE_FILESIZE	seekpos = (long) (BLCKSZ * (blocknum % ((BlockNumber) RELSEG_SIZE)));	Assert(seekpos < BLCKSZ * RELSEG_SIZE);#else	seekpos = (long) (BLCKSZ * (blocknum));#endif	/*	 * Note: because caller obtained blocknum by calling _mdnblocks, which did	 * a seek(SEEK_END), this seek is often redundant and will be optimized	 * away by fd.c.  It's not redundant, however, if there is a partial page	 * at the end of the file.	In that case we want to try to overwrite the	 * partial page with a full page.  It's also not redundant if bufmgr.c had	 * to dump another buffer of the same file to make room for the new page's	 * buffer.	 */	if (FileSeek(v->mdfd_vfd, seekpos, SEEK_SET) != seekpos)		return false;	if ((nbytes = FileWrite(v->mdfd_vfd, buffer, BLCKSZ)) != BLCKSZ)	{		if (nbytes > 0)		{			int			save_errno = errno;			/* Remove the partially-written page */			FileTruncate(v->mdfd_vfd, seekpos);			FileSeek(v->mdfd_vfd, seekpos, SEEK_SET);			errno = save_errno;		}		return false;	}	if (!isTemp)	{		if (!register_dirty_segment(reln, v))			return false;	}#ifndef LET_OS_MANAGE_FILESIZE	Assert(_mdnblocks(v->mdfd_vfd, BLCKSZ) <= ((BlockNumber) RELSEG_SIZE));#endif	return true;}
开发者ID:alecclarke,项目名称:postgresql-8.1.4,代码行数:69,


示例4: delete

void TForm1::ProcessFile(String fName){    int iFileHandle;    if(theBuffer) delete [] theBuffer;    theBuffer=NULL;    for(int i=0; i<lstResults->Items->Count; i++){        delete (MyResult*)lstResults->Items->Item[i]->Data;    }    lstResults->Items->BeginUpdate();    lstResults->Items->Clear();    lstResults->Items->EndUpdate();    char* rawBuffer=NULL;    Screen->Cursor = crHourGlass;    try{        if(!FileExists(fName)) return;        iFileHandle = FileOpen(fName, fmOpenRead);        if(iFileHandle == -1){			MessageBox(this->Handle, L"Could not open the specified file.", L"Error", MB_ICONEXCLAMATION);			return;        }        int fileLength = FileSeek(iFileHandle,0,2);        FileSeek(iFileHandle,0,0);        rawBuffer = new char[fileLength+1];        FileRead(iFileHandle, rawBuffer, fileLength);        FileClose(iFileHandle);        //strip whitespace and punctuation from text        theBuffer = new char[fileLength+1];        bufSize = 0;        char *c=rawBuffer, c1;        for(int i=0; i<fileLength; i++){            c1 = *c++;            if((c1 >= 'A') && (c1 <= 'Z')){                theBuffer[bufSize++] = c1;            }            else if(((c1 >= 'a') && (c1 <= 'z'))){                theBuffer[bufSize++] = c1-32;            }        }        this->Caption = (Application->Title + " - " + fName);        textPosition = 0;    }__finally{        if(rawBuffer){            delete [] rawBuffer;        }        Screen->Cursor = crDefault;        RedrawBitmap();    }}
开发者ID:Bindambc,项目名称:MathApps,代码行数:52,


示例5: ShowMessage

//---------------------------------------------------------------------------//当前格子写入修改文件中void __fastcall TFrmMain::N4Click(TObject* Sender){    if (!thOpen) return;    int iFileHandle; //文件句柄    char buf[4];    int iVal;    float fVal;    FILE* stream;    /*       if ((stream = fopen(CurrentOpenFile.c_str(), "r+"))           == NULL)       {          ShowMessage("打开文件出错");          return;       }    */    iFileHandle = FileOpen(CurrentOpenFile, fmOpenRead | fmOpenWrite); //打开文件    switch (thOpen->ColType[sgEdit->Col])    {        case 0: //整型值            //for(int i=0;i<sgEdit->RowCount-1;i++){            /*                fseek(stream, 0x14+((sgEdit->Row-1)*(sgEdit->ColCount-1)+(sgEdit->Col-1))*4, 0);                iVal=StrToInt(sgEdit->Cells[sgEdit->Col][sgEdit->Row]);                memcpy(buf, &iVal, 4);                for(int i=0;i<4;i++)                    fwrite(buf+i, 1, 1, stream);            */            iVal = StrToInt(sgEdit->Cells[sgEdit->Col][sgEdit->Row]);            memcpy(buf, &iVal, 4);            FileSeek(iFileHandle, 0x14 + ((sgEdit->Row - 1) * (sgEdit->ColCount - 1) + (sgEdit->Col - 1)) * 4, 0);            FileWrite(iFileHandle, buf, 4);            //}            break;        case 1: //浮点值            //fseek(stream, 0x14+((sgEdit->Row-1)*(sgEdit->ColCount-1)+(sgEdit->Col-1))*4, 0);            //fVal=StrToFloat(sgEdit->Cells[sgEdit->Col][sgEdit->Row]);            //fwrite(&fVal, 4, 1, stream);            fVal = StrToFloat(sgEdit->Cells[sgEdit->Col][sgEdit->Row]);            memcpy(buf, &fVal, 4);            FileSeek(iFileHandle, 0x14 + ((sgEdit->Row - 1) * (sgEdit->ColCount - 1) + (sgEdit->Col - 1)) * 4, 0);            FileWrite(iFileHandle, buf, 4);            break;        case 2: //文本不写入            break;    }    // fclose(stream);    FileClose(iFileHandle);}
开发者ID:natedahl32,项目名称:portalclassic,代码行数:54,


示例6: FileCopy

int FileCopy( const char *pFileIn, const char *pFileOut,			  int (*pfnCallback)( const char *p1, const char *p2, unsigned int nCopied,			  unsigned int nTotal ) ){	FHANDLE fh_in, fh_out;	u8 chunk[CHUNK_SIZE];	int read;	u64 copied, total;	fh_in = FileOpen( pFileIn, O_RDONLY );	if( fh_in.fh == -1 )		return 0;	fh_out = FileOpen( pFileOut, O_RDWR | O_CREAT | O_TRUNC );	if( fh_out.fh == -1 )		return 0;	total = FileSeek( fh_in, 0, SEEK_END );	FileSeek( fh_in, 0, SEEK_SET );	// copy file in chunks	copied = 0;	while(1)	{		read = FileRead( fh_in, chunk, sizeof(chunk) );		if( read <= 0 )			break;		FileWrite( fh_out, chunk, read );		copied += read;		if( pfnCallback )		{			if( !pfnCallback( pFileIn, pFileOut, copied, total ) )			{				FileClose(fh_in);				FileClose(fh_out);				return 0;			}		}	}	FileClose(fh_in);	FileClose(fh_out);	return 1;}
开发者ID:smiley22,项目名称:myPS2,代码行数:49,


示例7: FileSeek

int BDATreader::printlist() {    int res,laststate,n;    long lastpos;    string tname;    datablockinfo db,saveddb;    if(state>0) {        laststate=state;        lastpos=pos;        saveddb=lastinfo;        state=1;pos=8;        FileSeek(f,pos,SEEK_SET);        res=getnextblockinfo(db);        printf("BDAT binary data file information:/n - name %s/n - size: %ld/n",filename.c_str(),size);        n=1;        while(res==0) {            printf(" - data block %d/n   - name: %s/n   - ID: %d/n   - type: (%08X) ",n,lastinfo.name.c_str(),lastinfo.ID,lastinfo.type);            switch (lastinfo.type) {                case DT_bit:tname="bits";break;                case DT_byte:tname="byte";break;                case DT_ubyte:tname="unsigned byte";break;                case DT_word:tname="word/2-byte integer";break;                case DT_uword:tname="unsigned word/2-byte integer";break;                case DT_int:tname="int/4-byte integer";break;                case DT_uint:tname="unsigned int/4-byte integer";break;                case DT_long:tname="long int/8-byte integer";break;                case DT_ulong:tname="unsigned long int/8-byte integer";break;                case DT_single:tname="float/4-byte floating point number";break;                case DT_double:tname="double/8-byte floating point number";break;                case DT_quad:tname="quad/16-byte floating point number";break;                case DT_csingle:tname="complex float/two 4-byte floating point numbers";break;                case DT_cdouble:tname="complex double/two 8-byte floating point numbers";break;                case DT_cquad:tname="complex quad/two 16-byte floating point number";break;                case DT_user:tname="user defined format";break;                default:tname="unknown";break;            }            printf("%s/n   - records: %d/n   - record size: %d bytes/n   - data size: %d bytes/n",tname.c_str(),lastinfo.records,lastinfo.recordsize,lastinfo.records*lastinfo.recordsize);            res=skipblock();            if(res==0) res=getnextblockinfo(db);            n++;        }        state=laststate;        pos=lastpos;        lastinfo=saveddb;        FileSeek(f,pos,SEEK_SET);    }    else return -1; //file needs to be open    return 0;};
开发者ID:demarle,项目名称:vortexfinder2,代码行数:48,


示例8: mdread

/* *	mdread() -- Read the specified block from a relation. */voidmdread(SMgrRelation reln, ForkNumber forknum, BlockNumber blocknum,	   char *buffer){	off_t		seekpos;	int			nbytes;	MdfdVec    *v;	TRACE_POSTGRESQL_SMGR_MD_READ_START(forknum, blocknum,										reln->smgr_rnode.spcNode,										reln->smgr_rnode.dbNode,										reln->smgr_rnode.relNode);	v = _mdfd_getseg(reln, forknum, blocknum, false, EXTENSION_FAIL);	seekpos = (off_t) BLCKSZ *(blocknum % ((BlockNumber) RELSEG_SIZE));	Assert(seekpos < (off_t) BLCKSZ * RELSEG_SIZE);	if (FileSeek(v->mdfd_vfd, seekpos, SEEK_SET) != seekpos)		ereport(ERROR,				(errcode_for_file_access(),				 errmsg("could not seek to block %u in file /"%s/": %m",						blocknum, FilePathName(v->mdfd_vfd))));	nbytes = FileRead(v->mdfd_vfd, buffer, BLCKSZ);	TRACE_POSTGRESQL_SMGR_MD_READ_DONE(forknum, blocknum,									   reln->smgr_rnode.spcNode,									   reln->smgr_rnode.dbNode,									   reln->smgr_rnode.relNode,									   nbytes,									   BLCKSZ);	if (nbytes != BLCKSZ)	{		if (nbytes < 0)			ereport(ERROR,					(errcode_for_file_access(),					 errmsg("could not read block %u in file /"%s/": %m",							blocknum, FilePathName(v->mdfd_vfd))));		/*		 * Short read: we are at or past EOF, or we read a partial block at		 * EOF.  Normally this is an error; upper levels should never try to		 * read a nonexistent block.  However, if zero_damaged_pages is ON or		 * we are InRecovery, we should instead return zeroes without		 * complaining.  This allows, for example, the case of trying to		 * update a block that was later truncated away.		 */		if (zero_damaged_pages || InRecovery)			MemSet(buffer, 0, BLCKSZ);		else			ereport(ERROR,					(errcode(ERRCODE_DATA_CORRUPTED),					 errmsg("could not read block %u in file /"%s/": read only %d of %d bytes",							blocknum, FilePathName(v->mdfd_vfd),							nbytes, BLCKSZ)));	}}
开发者ID:badalex,项目名称:postgresql-scratchpad,代码行数:63,


示例9: FileHandle

    FileHandle(const wchar_t* path, uint64 offset)    {        hFileSrc = CreateFileW(path, GENERIC_READ, FILE_SHARE_READ, nullptr, OPEN_EXISTING, 0, nullptr);        if (offset != 0)            FileSeek(hFileSrc, offset);    }
开发者ID:Translator5,项目名称:desura-app,代码行数:7,


示例10: switch

bool File::Seek(int p, int from){	switch(srctype)	{	case MODE_MYFILE:	case MODE_EXTFILE:	       return FileSeek(file,p,from);		break;	case MODE_MYDATA:	case MODE_EXTDATA:		switch (from)		{		//case SEEK_CUR:		case FILESEEKCURRENT:			if(datapos + p >= datasize || datapos + p < 0)				return false;			datapos += p;			break;		//case SEEK_SET:		case FILESEEKSTART:			if(p >= datasize || p < 0)				return false;			datapos = p;			break;		//case SEEK_END:		case FILESEEKEND:			if(datasize + p < 0 || p > 0)				return false;			datapos = datasize + p;			break;		}	}	return true;}
开发者ID:jtritell,项目名称:KrisLibrary,代码行数:34,


示例11: tmdLoadHeader

uint_fast8_t tmdLoadHeader(tmd_data *data, wchar_t *path) { //validate and load tmd header	File fil;	size_t offset, size;	tmd_data data_tmp;	tmd_content_chunk *content_chunk_tmp;	uint_fast16_t content_count;	uint8_t hash[SHA_256_SIZE];		if (!FileOpen(&fil, path, 0) || (		(FileRead2(&fil, &data_tmp.sig_type, sizeof(data_tmp.sig_type)) != sizeof(data_tmp.sig_type) ||		(offset = tmdHeaderOffset(data_tmp.sig_type)) == 0 ||		!FileSeek(&fil, offset) ||		FileRead2(&fil, &data_tmp.header, sizeof(data_tmp.header) + sizeof(data_tmp.content_info)) != sizeof(data_tmp.header) + sizeof(data_tmp.content_info)) &&		(FileClose(&fil) || 1)	)) return 0;	sha(hash, &data_tmp.content_info, sizeof(data_tmp.content_info), SHA_256_MODE);	if (memcmp(hash, data_tmp.header.content_info_hash, sizeof(hash))) return FileClose(&fil) && 0;	size = (content_count = __builtin_bswap16(data_tmp.header.content_count)) * sizeof(tmd_content_chunk);	content_chunk_tmp = __builtin_alloca(size);	if (FileRead2(&fil, content_chunk_tmp, size) != size) return FileClose(&fil) && 0;	FileClose(&fil);	for (uint_fast16_t info_index = 0, chunk_index = 0, chunk_count; chunk_index < content_count; info_index++, chunk_index += chunk_count) {		if (info_index >= sizeof(data_tmp.content_info)/sizeof(tmd_content_info) ||			(chunk_count = __builtin_bswap16(data_tmp.content_info[info_index].content_command_count)) == 0		) return 0;		sha(hash, &content_chunk_tmp[chunk_index], chunk_count * sizeof(tmd_content_chunk), SHA_256_MODE);		if (memcmp(hash, data_tmp.content_info[chunk_index].content_chunk_hash, sizeof(hash))) return 0;	}	*data = data_tmp;	return 1;}
开发者ID:dukesrg,项目名称:rxTools,代码行数:31,


示例12: tmdPreloadChunk

size_t tmdPreloadChunk(tmd_data *data, wchar_t *path, uint_fast16_t content_index) { //loads tmd chunk records and returns total chunks size of content index type on success	FIL fil;	size_t offset, size = 0;	uint_fast16_t content_count, chunk_count;	uint8_t hash[SHA_256_SIZE];		if (FileOpen(&fil, path, 0) && (offset = tmdHeaderOffset(data->sig_type))) {		size = (content_count = __builtin_bswap16(data->header.content_count)) * sizeof(tmd_content_chunk);		if (!data->content_chunk)			data->content_chunk = __builtin_alloca(size);		if (FileSeek(&fil, offset + sizeof(data->header) + sizeof(data->content_info)) && FileRead2(&fil, data->content_chunk, size) == size) {			size = 0;			for (uint_fast16_t info_index = 0, chunk_index = 0; chunk_index < content_count; info_index++) {				chunk_count = __builtin_bswap16(data->content_info[info_index].content_command_count);				sha(hash, &data->content_chunk[chunk_index], chunk_count * sizeof(tmd_content_chunk), SHA_256_MODE);				if (memcmp(hash, data->content_info[chunk_index].content_chunk_hash, sizeof(hash))) {					size = 0;					break;				}				for (; chunk_count > 0; chunk_index++, chunk_count--) {					if (content_index == CONTENT_INDEX_ALL || content_index == data->content_chunk[chunk_index].content_index)						size += __builtin_bswap32(data->content_chunk[chunk_index].content_size_lo);				}			}		} else size = 0;		FileClose(&fil);	}	return size;}
开发者ID:dukesrg,项目名称:rxTools,代码行数:29,


示例13: FileGets

	//! Read a complete line from a file and return it as a string, treats CR, LF, CRLF and LFCR as valid line ends	std::string FileGets(FileHandle File)	{		std::string Line;		if(!FileValid(File)) return Line;		while(!FileEof(File))		{			char c = static_cast<char>(FileGetc(File));						// Enf of line?			if((c == '/n') || (c == '/r'))			{				// If not the last item byte in the file...				if(!FileEof(File))				{					// Check the next byte, and if it is something we should not have read, push it back by seeking back					UInt64 Pos = FileTell(File);					char c2 = static_cast<char>(FileGetc(File));					// We only discard a second character if it is also a /n or /r, but not a duplicate of the first					if(((c2 != '/n') && (c2 != '/r')) || (c2 == c)) FileSeek(File, Pos);				}				break;			}			Line += c;		}		return Line;	}
开发者ID:Dheeraj-B,项目名称:mxflib,代码行数:31,


示例14: palm_fseek

/*============================================================================  Description: See documentation for standard C library fseek  ==========================================================================*/unsigned short palm_fseek( PALM_FILE* io_pSF, long in_lOffset, short in_nOrigin ){    FileOriginEnum PalmOrigin = fileOriginCurrent;/*#define SEEK_CUR    1#define SEEK_END    2#define SEEK_SET    0*/    ChASSERT(io_pSF->volRef == ((UInt16)-1));    switch( in_nOrigin  )    {        case 0:        PalmOrigin = fileOriginBeginning;        break;        case 1:        PalmOrigin = fileOriginCurrent;        break;        case 2:        PalmOrigin = fileOriginEnd;        break;        default:        // error !!        return 0xFFFF;        break;    }	    return FileSeek( io_pSF->file.fh, in_lOffset, PalmOrigin );}
开发者ID:killbug2004,项目名称:WSProf,代码行数:39,


示例15: 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,


示例16: FileOpen

void __fastcall TForm1::Button2Click(TObject *Sender){	if(this->OpenDialog1->Execute())        {        	AnsiString FileName = OpenDialog1->FileName ;                int File =   FileOpen(FileName,fmOpenRead);                //获取文件内容真正的大小		int length =  GetCompressedFileSize(FileName.c_str(),NULL);                byte *buf = (byte *)malloc(length);                char *content = (char *)malloc(length);                //read file to buf                FileRead(File,buf,length);                FileSeek(File,0,0);                FileRead(File,content,length);                FileClose(File);                this->MemoLeftData->Text = AnsiString(content);//store global data                embeddata = BinaryToString(buf,length);                embedSize = length * 8 ;                free(content);                free(buf);                       }}
开发者ID:tianfengjingjing,项目名称:C-BuilderGame,代码行数:26,


示例17: mdwrite

/* *	mdwrite() -- Write the supplied block at the appropriate location. */boolmdwrite(SMgrRelation reln, BlockNumber blocknum, char *buffer, bool isTemp){	long		seekpos;	MdfdVec    *v;	v = _mdfd_getseg(reln, blocknum, false);#ifndef LET_OS_MANAGE_FILESIZE	seekpos = (long) (BLCKSZ * (blocknum % ((BlockNumber) RELSEG_SIZE)));	Assert(seekpos < BLCKSZ * RELSEG_SIZE);#else	seekpos = (long) (BLCKSZ * (blocknum));#endif	if (FileSeek(v->mdfd_vfd, seekpos, SEEK_SET) != seekpos)		return false;	if (FileWrite(v->mdfd_vfd, buffer, BLCKSZ) != BLCKSZ)		return false;	if (!isTemp)	{		if (!register_dirty_segment(reln, v))			return false;	}	return true;}
开发者ID:alecclarke,项目名称:postgresql-8.1.4,代码行数:32,


示例18: mdwrite

/* *	mdwrite() -- Write the supplied block at the appropriate location. * *		This is to be used only for updating already-existing blocks of a *		relation (ie, those before the current EOF).  To extend a relation, *		use mdextend(). */voidmdwrite(SMgrRelation reln, ForkNumber forknum, BlockNumber blocknum,		char *buffer, bool isTemp){	off_t		seekpos;	int			nbytes;	MdfdVec    *v;	/* This assert is too expensive to have on normally ... */#ifdef CHECK_WRITE_VS_EXTEND	Assert(blocknum < mdnblocks(reln, forknum));#endif	TRACE_POSTGRESQL_SMGR_MD_WRITE_START(forknum, blocknum,										 reln->smgr_rnode.spcNode,										 reln->smgr_rnode.dbNode,										 reln->smgr_rnode.relNode);	v = _mdfd_getseg(reln, forknum, blocknum, isTemp, EXTENSION_FAIL);	seekpos = (off_t) BLCKSZ *(blocknum % ((BlockNumber) RELSEG_SIZE));	Assert(seekpos < (off_t) BLCKSZ * RELSEG_SIZE);	if (FileSeek(v->mdfd_vfd, seekpos, SEEK_SET) != seekpos)		ereport(ERROR,				(errcode_for_file_access(),				 errmsg("could not seek to block %u in file /"%s/": %m",						blocknum, FilePathName(v->mdfd_vfd))));	nbytes = FileWrite(v->mdfd_vfd, buffer, BLCKSZ);	TRACE_POSTGRESQL_SMGR_MD_WRITE_DONE(forknum, blocknum,										reln->smgr_rnode.spcNode,										reln->smgr_rnode.dbNode,										reln->smgr_rnode.relNode,										nbytes,										BLCKSZ);	if (nbytes != BLCKSZ)	{		if (nbytes < 0)			ereport(ERROR,					(errcode_for_file_access(),					 errmsg("could not write block %u in file /"%s/": %m",							blocknum, FilePathName(v->mdfd_vfd))));		/* short write: complain appropriately */		ereport(ERROR,				(errcode(ERRCODE_DISK_FULL),				 errmsg("could not write block %u in file /"%s/": wrote only %d of %d bytes",						blocknum,						FilePathName(v->mdfd_vfd),						nbytes, BLCKSZ),				 errhint("Check free disk space.")));	}	if (!isTemp)		register_dirty_segment(reln, forknum, v);}
开发者ID:badalex,项目名称:postgresql-scratchpad,代码行数:66,


示例19: 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,


示例20: Restart

	aalSBool ChunkFile::Restart()	{		offset = 0;		if (FileSeek(file, 0, SEEK_SET)) return AAL_SFALSE;		return AAL_STRUE;	}
开发者ID:OpenSourcedGames,项目名称:Arx-Fatalis,代码行数:8,


示例21: Skip

	// Skip!                                                                     //	aalSBool ChunkFile::Skip(const aalULong & size)	{		if (FileSeek(file, size, SEEK_CUR)) return AAL_SFALSE;		if (offset) offset -= size;		return AAL_STRUE;	}
开发者ID:OpenSourcedGames,项目名称:Arx-Fatalis,代码行数:9,


示例22: 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,


示例23: SetPosition

aalError CodecRAW::SetPosition(const aalULong & _position){    if (FileSeek(stream, _position, SEEK_CUR)) return AAL_ERROR_FILEIO;    cursor = _position;    return AAL_OK;}
开发者ID:sopyer,项目名称:ArxFatalis,代码行数:8,


示例24: FindPage

static voidFindPage (DviWidget dw){	int	i;	long	file_position;	if (dw->dvi.requested_page < 1)		dw->dvi.requested_page = 1;	if (dw->dvi.last_page != 0 && dw->dvi.requested_page > dw->dvi.last_page)		dw->dvi.requested_page = dw->dvi.last_page;	file_position = SearchPagePosition (dw, dw->dvi.requested_page);	if (file_position != -1) {		FileSeek(dw, file_position);		dw->dvi.current_page = dw->dvi.requested_page;	} else {		for (i=dw->dvi.requested_page; i > 0; i--) {			file_position = SearchPagePosition (dw, i);			if (file_position != -1)				break;		}		if (file_position == -1)			file_position = 0;		FileSeek (dw, file_position);		dw->dvi.current_page = i;				dw->dvi.display_enable = 0;		while (dw->dvi.current_page != dw->dvi.requested_page) {			dw->dvi.current_page = ParseInput (dw);			/*			 * at EOF, seek back to the beginning of this page.			 */			if (!dw->dvi.readingTmp && feof (dw->dvi.file)) {				file_position = SearchPagePosition (dw,						dw->dvi.current_page);				if (file_position != -1)					FileSeek (dw, file_position);				dw->dvi.requested_page = dw->dvi.current_page;				break;			}		}	}}
开发者ID:ajinkya93,项目名称:netbsd-src,代码行数:45,


示例25: FileAppend

HANDLE FileAppend(LPCTSTR FileName){	HANDLE hFile;	hFile = CreateFile( FileName, GENERIC_READ | GENERIC_WRITE, FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL );	FileSeek(hFile, 0, FILE_END );	return hFile;}
开发者ID:HipsterLion,项目名称:SRB2,代码行数:9,


示例26: AppendOnlyStorageRead_FinishOpenFile

/* * Finish the open by positioning the next read and saving information. * * file			- The open file. * filePathName - name of the segment file to open. * version		- AO table format version the file is in. * logicalEof	- snapshot version of the EOF value to use as the read end *				  of the segment file. */static voidAppendOnlyStorageRead_FinishOpenFile(AppendOnlyStorageRead *storageRead,									 File file,									 char *filePathName,									 int version,									 int64 logicalEof){	int64		seekResult;	MemoryContext oldMemoryContext;	int			segmentFileNameLen;	AORelationVersion_CheckValid(version);	/*	 * Seek to the beginning of the file.	 */	seekResult = FileSeek(file, 0, SEEK_SET);	if (seekResult != 0)	{		FileClose(file);		ereport(ERROR,				(errcode(ERRCODE_IO_ERROR),				 errmsg("Append-only Storage Read error on segment file '%s' for relation '%s'.  FileSeek offset = 0.  Error code = %d (%s)",						filePathName,						storageRead->relationName,						(int) seekResult,						strerror((int) seekResult))));	}	storageRead->file = file;	storageRead->formatVersion = version;	/*	 * When reading multiple segment files, we throw away the old segment file	 * name strings.	 */	oldMemoryContext = MemoryContextSwitchTo(storageRead->memoryContext);	if (storageRead->segmentFileName != NULL)		pfree(storageRead->segmentFileName);	segmentFileNameLen = strlen(filePathName);	storageRead->segmentFileName = (char *) palloc(segmentFileNameLen + 1);	memcpy(storageRead->segmentFileName, filePathName, segmentFileNameLen + 1);	/* Allocation is done.  Go back to caller memory-context. */	MemoryContextSwitchTo(oldMemoryContext);	storageRead->logicalEof = logicalEof;	BufferedReadSetFile(						&storageRead->bufferedRead,						storageRead->file,						storageRead->segmentFileName,						logicalEof);}
开发者ID:karthijrk,项目名称:gpdb,代码行数:65,


示例27: acoral_lseek

acoral_u32 acoral_lseek(acoral_32 fd,acoral_32 offset,acoral_u8 whence){	acoral_u32 ret,fs_ret;	ret=acoral_mutex_pend(fs_mutex,0);	if(ret!=MUTEX_SUCCED)		return -1;	fs_ret=FileSeek(fd,offset,whence);	acoral_mutex_post(fs_mutex);	return fs_ret;}
开发者ID:ChenZewei,项目名称:acoral,代码行数:10,


示例28: _mdnblocks

/* * Get number of blocks present in a single disk file */static BlockNumber_mdnblocks(File file, Size blcksz){	long		len;	len = FileSeek(file, 0L, SEEK_END);	if (len < 0)		return 0;				/* on failure, assume file is empty */	return (BlockNumber) (len / blcksz);}
开发者ID:alecclarke,项目名称:postgresql-8.1.4,代码行数:13,



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


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