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

C++ Fwrite函数代码示例

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

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



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

示例1: headerWrite

int headerWrite(FD_t fd, Header h, enum hMagic magicp)
{
    ssize_t nb;
    size_t length;
    void * uh;

    uh = doHeaderUnload(h, &length);
    if (uh == NULL)
	return 1;
    switch (magicp) {
    case HEADER_MAGIC_YES:
	nb = Fwrite(rpm_header_magic, sizeof(uint8_t), sizeof(rpm_header_magic), fd);
	if (nb != sizeof(rpm_header_magic))
	    goto exit;
	break;
    case HEADER_MAGIC_NO:
	break;
    }

    nb = Fwrite(uh, sizeof(char), length, fd);

exit:
    uh = _free(uh);
    return (nb == length ? 0 : 1);
}
开发者ID:cms-externals,项目名称:rpm,代码行数:25,代码来源:header.c


示例2: rpmbfWrite

static unsigned rpmbfWrite(FD_t fd, rpmbf * bfa, size_t npkgs)
{
    const char * fn = xstrdup(fdGetOPath(fd));
    struct stat sb;
    int ix;
    int xx;

    for (ix = 0; ix < (int) npkgs; ix++) {
	rpmbf bf = bfa[ix];
	static const char _bfmagic[] = "BFL3";
	const unsigned char * _bits = (bf ? bf->bits : NULL);
	uint32_t _n = (bf ? htonl(bf->n) : 0);
	uint32_t _m = (bf ? htonl(bf->m) : 0);
	uint32_t _k = (bf ? htonl(bf->k) : 0);

	if (bf && rpmIsVerbose())
	    fprintf(stderr, "\tbf[%d] %p {%u,%u}[%u] %u bytes\n", ix, bf, (unsigned)bf->n, (unsigned)bf->m, (unsigned)bf->k, (unsigned)(16 + (bf->m+7)/8));
	xx = Fwrite(_bfmagic, 1, 2, fd);
	xx = Fwrite(&_n, 1, sizeof(_n), fd);
	xx = Fwrite(&_m, 1, sizeof(_m), fd);
	xx = Fwrite(&_k, 1, sizeof(_m), fd);
	if (bf && bf->m > 0)
	    xx = Fwrite(bf->bits, 1, (bf->m+7)/8, fd);
    }
    xx = Fclose(fd);
    xx = Stat(fn, &sb);
    xx = Unlink(fn);

    return sb.st_size;
}
开发者ID:avokhmin,项目名称:RPM5,代码行数:30,代码来源:tbf.c


示例3: headerWrite

int headerWrite(FD_t fd, Header h, int magicp)
{
    ssize_t nb;
    unsigned int length;
    void * uh;

    uh = headerExport(h, &length);
    if (uh == NULL)
	return 1;
    switch (magicp) {
    case HEADER_MAGIC_YES:
	nb = Fwrite(rpm_header_magic, sizeof(uint8_t), sizeof(rpm_header_magic), fd);
	if (nb != sizeof(rpm_header_magic))
	    goto exit;
	break;
    case HEADER_MAGIC_NO:
	break;
    }

    nb = Fwrite(uh, sizeof(char), length, fd);

exit:
    free(uh);
    return (nb == length ? 0 : 1);
}
开发者ID:fingunter,项目名称:rpm,代码行数:25,代码来源:header.c


示例4: ddstry

short ddstry(short fd, char *ext, char *text, char *name, long size)
{
	char c;
	short hdrlen, i;

	/* 4 Bytes f�r "ext", 4 Bytes f�r "size",
	   2 Bytes f�r Stringendnullen */

	hdrlen = (short) (4 + 4 + strlen(text)+1 + strlen(name)+1);


	/* Header senden */

	if (Fwrite(fd, 2L, &hdrlen) != 2L)
		return(DD_NAK);

	i = (short) Fwrite(fd, 4L, ext);
	i += (short) Fwrite(fd, 4L, &size);
	i += (short) Fwrite(fd, strlen(text)+1, text);
	i += (short) Fwrite(fd, strlen(name)+1, name);

	if (i != hdrlen)
		return(DD_NAK);


	/* auf die Antwort warten */

	if (Fread(fd, 1L, &c) != 1L)
		return(DD_NAK);

	return(c);
}
开发者ID:pcwalton,项目名称:NetSurf,代码行数:32,代码来源:dragdrop.c


示例5: createTestFiles

void createTestFiles(void)
{
    Dsetdrv(drive);             // switch to selected drive
    Dsetpath("\\");
    (void) Dcreate("TESTDIR");
    Dsetpath("\\TESTDIR");

    int i, f;
    char numString[8];
    char fileName[16];
    for(i=0; i<25; i++) {
        byteToHex(i + 1, numString);
        
        strcpy(fileName, "FILE_");
        strcat(fileName, numString);
        f = Fcreate(fileName, 0);
        Fwrite(f, 7, fileName);
        Fclose(f);
        
        strcpy(fileName, "FILENAME.X");
        strcat(fileName, numString);
        f = Fcreate(fileName, 0);
        Fwrite(f, 12, fileName);
        Fclose(f);
        
        strcpy(fileName, "DIR_");
        strcat(fileName, numString);
        (void) Dcreate(fileName);
    }
}
开发者ID:atarijookie,项目名称:ce-atari,代码行数:30,代码来源:test03.c


示例6: itm_drop

/* HR 050203: drag & drop */
static
boolean itm_drop(WINDOW *w, int n, int *list, int kstate, ICND *icnlist, int x, int y)
{
	int i, item, apid = -1, hdl = wind_find(x, y);
	long fd;
/*	ITMTYPE type;
*/	const char *path;

	if (hdl > 0)
		wind_get(hdl, WF_OWNER, &apid);

	if (apid > 0)
	{
		char ddsexts[32];

		fd = ddcreate(apid, ap_id, hdl, x, y, kstate, ddsexts);
		if (fd > 0)
		{
			if (ddstry(fd, "ARGS", "", sizeof(LNAME)) != DD_NAK)
			{
				for (i = 0; i < n; i++)
				{
					if ((item = list[i]) == -1)
						continue;
			
					path = itm_fullname(w, item);

					if (path)
					{
					/*	type = itm_type(w, item);
						alert_msg("type %d | %s | '%s'", type, name, path);
					*/
						Fwrite(fd, 1, "'");
						Fwrite(fd, strlen(path), path);
						Fwrite(fd, 1, "'");	
					}
					if (i < n - 1)
						Fwrite(fd, 1, " ");
				}
				ddclose(fd);

				itm_select(w, -1, 0, TRUE);
				return TRUE;
			}
			else
				alert_printf(1, APPNOEXT);

			ddclose(fd);
		}
		else
		{
			alert_printf(1, APPNODD);
			return FALSE;
		}
	}

	alert_printf(1, MILLDEST);
	return FALSE;
}
开发者ID:daemqn,项目名称:Atari_ST_Sources,代码行数:60,代码来源:WINDOW.C


示例7: writeINODE

void writeINODE(INODE * inodeP)
{
	//data.txt的区块偏移, 加上INODE节点区的偏移
	int offset = inodeP->inodeNumber * superBlockPointer->inodeSize + getInodeAreaOffset(superBlockPointer);
	if(fseek(dataFp, offset, SEEK_SET) == 0){
		int time_tmp = inodeP->aTime;
		Fwrite(&time_tmp, 4, 1, dataFp);
		//fwrite(&inodeP->aTime, 4, 1, dataFp);
		time_tmp = inodeP->cTime;
		Fwrite(&time_tmp, 4, 1, dataFp);
		//fwrite(&inodeP->cTime, 4, 1, dataFp);
		time_tmp = inodeP->mTime;
		Fwrite(&time_tmp, 4, 1, dataFp);
		//fwrite(&inodeP->mTime, 4, 1, dataFp);
		Fwrite(&inodeP->GID, 4, 1, dataFp);
		Fwrite(&inodeP->UID, 4, 1, dataFp);
		Fwrite(&inodeP->authority, 4, 1, dataFp);
		Fwrite(&inodeP->inodeNumber, 4, 1, dataFp);
		Fwrite(&inodeP->blockNumber, 4, 1, dataFp);
		Fwrite(&inodeP->length, 4, 1, dataFp);
		BLOCK block;
		block.blockNumber = inodeP->blockNumber;
		writeBlock(&block, inodeP->mem);
		//fwrite(inodeP, sizeof(INODE), 1, dataFp);
	}
	else{
		printf("文件指针偏移失败,请重新打开程序尝试,不成功则程序已崩溃……!\r\n");
		getchar();
		exit(-255);
	}
}
开发者ID:xzblh,项目名称:fs,代码行数:31,代码来源:inode.cpp


示例8: done

void done( void )
{
	v_show_c( handle, 0 );
	v_clsvwk( handle );
	if (score>hiscore)
	{
		puts("\033HSie haben einen neuen Highscore erreicht!");
		printf("Geben Sie Ihren Namen ein: ");
		scanf("%126s",hiname);
		highfile=(int)Fcreate("HISCORE.DAT",0);
		Fwrite(highfile, 4, &score );
		Fwrite(highfile, 128, hiname );
		Fclose(highfile);
	}
}
开发者ID:daemqn,项目名称:Atari_ST_Sources,代码行数:15,代码来源:mtet.c


示例9: ddopen

short ddopen(short ddnam, char ddmsg)
{
	long fd;

	pipename[17] = (ddnam & 0xff00) >> 8;
	pipename[18] = ddnam & 0x00ff;

	fd = Fopen(pipename, 2);

	if (fd < 0L)
		return(-1);


	/* Signalhandler konfigurieren */

	ddgetsig(&pipesig);


	if (Fwrite((short) fd, 1L, &ddmsg) != 1L)
	{
		ddclose((short) fd);
		return(-1);
	}

	return((short) fd);
}
开发者ID:pcwalton,项目名称:NetSurf,代码行数:26,代码来源:dragdrop.c


示例10: printFile

static void printFile(char *fileNam)
{
	int fi, fo;
#define NBUFF 256
	char buff[NBUFF];
	long len;
	
	fileNam[0] = 'd';			/* force data file */

	if ( (fi=Fopen(fileNam, FO_READ)) >= 0 ) {
		if ( (fo=Fcreate(prDevice, 0)) < 0)
			fo=Fopen(prDevice, FO_WRITE);
		/* Fopen may return < 0 for devices like PRN: ! */
		if ( fo > -31) {
	
			while ( (len=Fread(fi, NBUFF, buff)) > 0)
				Fwrite(fo, len, buff);
	
			Fclose(fo);
		} else {
	        uiPrintf(uiH, uiPrERR, "cannot open device|>%s<", prDevice);
		}
		Fclose(fi);
	} else {
        uiPrintf(uiH, uiPrERR, "cannot open dFile");
	}

	Fdelete(fileNam);
	fileNam[0] = 'c';			/* force control file */
	Fdelete(fileNam);
}	
开发者ID:daemqn,项目名称:Atari_ST_Sources,代码行数:31,代码来源:LPD.C


示例11: rpmwfPushRPM

rpmRC rpmwfPushRPM(rpmwf wf, const char * fn)
{
    char * b = NULL;
    size_t nb = 0;

    if (!strcmp(fn, "Lead")) {
	b = wf->l;
	nb = wf->nl;
    } else
    if (!strcmp(fn, "Signature")) {
	b = wf->s;
	nb = wf->ns;
    } else
    if (!strcmp(fn, "Header")) {
	b = wf->h;
	nb = wf->nh;
    } else
    if (!strcmp(fn, "Payload")) {
	b = wf->p;
	nb = wf->np;
    }

    if (!(b && nb > 0))
	return RPMRC_NOTFOUND;

if (_rpmwf_debug)
fprintf(stderr, "==> rpmwfPushRPM(%p, %s) %p[%u]\n", wf, fn, b, (unsigned) nb);

    if (Fwrite(b, sizeof(b[0]), nb, wf->fd) != nb)
	return RPMRC_FAIL;

    return RPMRC_OK;
}
开发者ID:cmjonze,项目名称:rpm5_tarballs,代码行数:33,代码来源:rpmwf.c


示例12: Copy_file

int Copy_file(char *tos_name,char *long_name,int attributes)
{
 short in_file,out_file;
 long size;
 int error;

 if ((in_file=Fopen(tos_name,0))<0)
  return(FALSE);

 if ((out_file=Fcreate(long_name,attributes))<0)
 {
  Fclose(in_file);
  return(FALSE);
 }

 do
 {
  size=Fread(in_file,FILE_BUFF_SIZE,file_buff);
  error=(size!=Fwrite(out_file,size,file_buff));
 } while((size==FILE_BUFF_SIZE)&&(!error));

 Fclose(out_file);
 Fclose(in_file);
 return(!error);
}
开发者ID:daemqn,项目名称:Atari_ST_Sources,代码行数:25,代码来源:CONV.C


示例13: ufdCopy

int ufdCopy(FD_t sfd, FD_t tfd)
{
    char buf[BUFSIZ];
    int itemsRead;
    int itemsCopied = 0;
    int rc = 0;

    while (1) {
	rc = Fread(buf, sizeof(buf[0]), sizeof(buf), sfd);
	if (rc < 0)
	    break;
	else if (rc == 0) {
	    rc = itemsCopied;
	    break;
	}
	itemsRead = rc;
	rc = Fwrite(buf, sizeof(buf[0]), itemsRead, tfd);
	if (rc < 0)
	    break;
 	if (rc != itemsRead) {
	    rc = -1;
	    break;
	}

	itemsCopied += itemsRead;
    }

    DBGIO(sfd, (stderr, "++ copied %d bytes\n", itemsCopied));

    return rc;
}
开发者ID:akozumpl,项目名称:rpm,代码行数:31,代码来源:rpmio.c


示例14: makenewscore

short makenewscore() {

   short ret = 0;

   scoreentries = 0;
#if ATARIST
	if ((sfdbn = Fcreate(SCOREFILE, 0)) < 0) ret = E_FOPENSCORE;
	else {
		Fwrite(sfdbn, 2L, &scoreentries);
		Fclose(sfdbn);
	}
#else
   while( creat( LOCKFILE) < 0);
   if( (scorefile = fopen( SCOREFILE, "w")) == NULL)
      ret = E_FOPENSCORE;
   else {
      sfdbn = fileno( scorefile);
      write( sfdbn, &scoreentries, 2);
      fclose( scorefile);
   }
   unlink( LOCKFILE);
#endif

   return( (ret == 0) ? E_ENDGAME : ret);
}
开发者ID:daemqn,项目名称:Atari_ST_Sources,代码行数:25,代码来源:SCORE.C


示例15: _tiffSeekProc

static toff_t
_tiffSeekProc(thandle_t fd, off_t off, int whence)
{
	char buf[256];
	long current_off, expected_off, new_off;

	if (whence == SEEK_END || off <= 0)
		return Fseek(off, (int) fd, whence);
	current_off = Fseek(0, (int) fd, SEEK_CUR); /* find out where we are */
	if (whence == SEEK_SET)
		expected_off = off;
	else
		expected_off = off + current_off;
	new_off = Fseek(off, (int) fd, whence);
	if (new_off == expected_off)
		return new_off;
	/* otherwise extend file -- zero filling the hole */
	if (new_off < 0)            /* error? */
		new_off = Fseek(0, (int) fd, SEEK_END); /* go to eof */
	_TIFFmemset(buf, 0, sizeof(buf));
	while (expected_off > new_off) {
		off = expected_off - new_off;
		if (off > sizeof(buf))
			off = sizeof(buf);
		if ((current_off = Fwrite((int) fd, off, buf)) != off)
			return (current_off > 0) ?
			    new_off + current_off : new_off;
		new_off += off;
	}
	return new_off;
}
开发者ID:shivshankardayal,项目名称:Universal-C-C--,代码行数:31,代码来源:tif_atari.c


示例16: ufdCopy

off_t ufdCopy(FD_t sfd, FD_t tfd)
{
    char buf[BUFSIZ];
    ssize_t rdbytes, wrbytes;
    off_t total = 0;

    while (1) {
	rdbytes = Fread(buf, sizeof(buf[0]), sizeof(buf), sfd);

	if (rdbytes > 0) {
	    wrbytes = Fwrite(buf, sizeof(buf[0]), rdbytes, tfd);
	    if (wrbytes != rdbytes) {
		total = -1;
		break;
	    }
	    total += wrbytes;
	} else {
	    if (rdbytes < 0)
		total = -1;
	    break;
	}
    }

    return total;
}
开发者ID:maxamillion,项目名称:rpm,代码行数:25,代码来源:rpmio.c


示例17: sauver_tampon

/****************************************************************
*																*
*				sauve le tampon dans un fichier					*
*																*
****************************************************************/
void sauver_tampon(void)
{
	int handle;
	char nom[FILENAME_MAX] = "", text[FILENAME_MAX];

	if(!selecteur(nom, "*.BUF", Messages(TAMPON_6)))
		return;

	sprintf(text, Messages(TAMPON_7), nom);
	ajoute(Firstwindow, text);

	if ((handle = (int)Fcreate(nom, 0)) >= 0)
	{
		int err;

		if ((err = (int)Fwrite(handle, 512L, Tampon -> fonction.tampon.secteurBin)) < 0)
			error_msg(err);
		else
			ajoute(Firstwindow, Messages(TAMPON_8));

		Fclose(handle);
	}
	else
		ajoute(Firstwindow, Messages(TAMPON_9));
} /* sauver_tampon */
开发者ID:daemqn,项目名称:Atari_ST_Sources,代码行数:30,代码来源:TAMPON.C


示例18: copyFile

/**
 * Copy header+payload, calculating digest(s) on the fly.
 * @param sfdp source file
 * @param sfnp source path
 * @param tfdp destination file
 * @param tfnp destination path
 */
static int copyFile(FD_t *sfdp, const char *sfnp,
		FD_t *tfdp, const char *tfnp)
{
    unsigned char buf[BUFSIZ];
    ssize_t count;
    int rc = 1;

    while ((count = Fread(buf, sizeof(buf[0]), sizeof(buf), *sfdp)) > 0)
    {
	if (Fwrite(buf, sizeof(buf[0]), count, *tfdp) != count) {
	    rpmlog(RPMLOG_ERR, _("%s: Fwrite failed: %s\n"), tfnp,
		Fstrerror(*tfdp));
	    goto exit;
	}
    }
    if (count < 0) {
	rpmlog(RPMLOG_ERR, _("%s: Fread failed: %s\n"), sfnp, Fstrerror(*sfdp));
	goto exit;
    }
    if (Fflush(*tfdp) != 0) {
	rpmlog(RPMLOG_ERR, _("%s: Fflush failed: %s\n"), tfnp,
	    Fstrerror(*tfdp));
    }

    rc = 0;

exit:
    return rc;
}
开发者ID:maxamillion,项目名称:rpm,代码行数:36,代码来源:rpmgensig.c


示例19: __write

long
#else
int
#endif
__write (int fd, const void *buf, size_t size)
{
	unsigned char c, *foo;
	unsigned flags;
	long r;
	struct xattr statbuf;
	_DOSTIME timebuf;

	if (__mint == 0 && isatty(fd)) {
		r = __OPEN_INDEX(fd);
		if (r < 0 || r >= __NHANDLES)
			r = __NHANDLES - 1;
		flags = __open_stat[r].flags;
		if ((flags & RAW) || _sig_handler[SIGINT] != SIG_DFL) {
			foo = (unsigned char *) buf;
			r = size;
			while (r-- > 0) {
				c = *foo++;
				if (c == '\n' && (flags & CRMOD))
					_console_write_byte(fd, '\r');
				_console_write_byte(fd, c);
			}
			return size;
		}
	}

	r = Fwrite(fd, size, buf);
	if (r < 0) {
		__set_errno (-r);
		return -1;
	}
	if (size && r == 0) {
	  if (__mint >= 9)
	    {
	      if ((r = Fcntl (fd, &statbuf, FSTAT)) < 0)
		{
		  __set_errno (-r);
		  return -1;
		}
	      if (((mode_t) statbuf.st_mode & S_IFMT) == S_IFREG)
		{
		  __set_errno (ENOSPC);
		  return -1;
		}
	    }
	  else if (Fdatime (&timebuf, fd, 0) == 0
		   && Fseek (0L, fd, SEEK_CUR) >= 0)
	    {
	      __set_errno (ENOSPC);
	      return -1;
	    }
	}

	return r;
}
开发者ID:ArmstrongJ,项目名称:MiNTLib,代码行数:59,代码来源:write.c


示例20: writeBlock

void writeBlock(BLOCK * blockP, void * mem)
{
	if(NULL == mem){
		return ;
	}
	fseek(dataFp, getBlockOffset(blockP->blockNumber), SEEK_SET);
	Fwrite(mem, superBlockPointer->blockSize, 1, dataFp);
}
开发者ID:xzblh,项目名称:fs,代码行数:8,代码来源:block.cpp



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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