예제 #1
0
파일: header.c 프로젝트: cms-externals/rpm
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);
}
예제 #2
0
파일: tbf.c 프로젝트: avokhmin/RPM5
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;
}
예제 #3
0
파일: header.c 프로젝트: fingunter/rpm
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);
}
예제 #4
0
파일: dragdrop.c 프로젝트: pcwalton/NetSurf
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);
}
예제 #5
0
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);
    }
}
예제 #6
0
/* 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;
}
예제 #7
0
파일: inode.cpp 프로젝트: xzblh/fs
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);
	}
}
예제 #8
0
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);
	}
}
예제 #9
0
파일: dragdrop.c 프로젝트: pcwalton/NetSurf
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);
}
예제 #10
0
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);
}	
예제 #11
0
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;
}
예제 #12
0
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);
}
예제 #13
0
파일: rpmio.c 프로젝트: akozumpl/rpm
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;
}
예제 #14
0
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);
}
예제 #15
0
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;
}
예제 #16
0
파일: rpmio.c 프로젝트: maxamillion/rpm
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;
}
예제 #17
0
/****************************************************************
*																*
*				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 */
예제 #18
0
파일: rpmgensig.c 프로젝트: maxamillion/rpm
/**
 * 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;
}
예제 #19
0
파일: write.c 프로젝트: ArmstrongJ/MiNTLib
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;
}
예제 #20
0
파일: block.cpp 프로젝트: xzblh/fs
void writeBlock(BLOCK * blockP, void * mem)
{
	if(NULL == mem){
		return ;
	}
	fseek(dataFp, getBlockOffset(blockP->blockNumber), SEEK_SET);
	Fwrite(mem, superBlockPointer->blockSize, 1, dataFp);
}
예제 #21
0
void vflsh()
{
VPAGE *vp;
VPAGE *vlowest;
long addr;
VFILE *vfile;
int x;
for(vfile=vfiles.link.next;
    vfile!=&vfiles;
    vfile=vfile->link.next)
 {
 loop:
 addr= MAXLONG;
 vlowest=0;
 for(x=0;x!=HTSIZE;x++)
  for(vp=htab[x];vp;vp=vp->next)
   if(vp->addr<addr && vp->dirty && vp->vfile==vfile && !vp->count)
    addr=vp->addr, vlowest=vp;
 if(vlowest)
  {
/*  if(!vfile->name) vfile->name=mktmp("/tmp/"); */  /* changed p,w. wong */

  char *pwstring="c:/joe";
  
  if (getenv("JOERC")) pwstring = getenv("JOERC");
  if(!vfile->name) vfile->name=mktmp(pwstring); 
  if(!vfile->fd)
   {
   vfile->fd=Fopen(vfile->name);
   }
  Fseek(vfile->fd,addr);
  if(addr+PGSIZE>vsize(vfile))
   {
   Fwrite(vfile->fd,vlowest->data,(int)(vsize(vfile)-addr));
   vfile->size=vsize(vfile);
   }
  else
   {
   Fwrite(vfile->fd,vlowest->data,PGSIZE);
   if(addr+PGSIZE>vfile->size) vfile->size=addr+PGSIZE;
   }
  vlowest->dirty=0;
  goto loop;
  }
 }
}
예제 #22
0
int fwriteTIMEOUT1(PCStr(b),int s,int n,FILE *fp)
{	int rc;

	fRETURN_ONTIMEOUT(fp,0);
	rc = Fwrite(b,s,n,fp);
	DONE_SUCCESSFULLY();
	return rc;
}
예제 #23
0
파일: cpio.c 프로젝트: junaruga/rpm
static int rpmcpioTrailerWrite(rpmcpio_t cpio)
{
    struct cpioCrcPhysicalHeader hdr;
    int rc;
    size_t written;

    if (cpio->fileend != cpio->offset) {
        return RPMERR_WRITE_FAILED;
    }

    rc = rpmcpioWritePad(cpio, 4);
    if (rc)
        return rc;

    memset(&hdr, '0', PHYS_HDR_SIZE);
    memcpy(&hdr.nlink, "00000001", 8);
    memcpy(&hdr.namesize, "0000000b", 8);

    written = Fwrite(CPIO_NEWC_MAGIC, 6, 1, cpio->fd);
    cpio->offset += written;
    if (written != 6) {
        return RPMERR_WRITE_FAILED;
    }

    written = Fwrite(&hdr, PHYS_HDR_SIZE, 1, cpio->fd);
    cpio->offset += written;
    if (written != PHYS_HDR_SIZE) {
        return RPMERR_WRITE_FAILED;
    }
    written = Fwrite(&CPIO_TRAILER, sizeof(CPIO_TRAILER), 1, cpio->fd);
    cpio->offset += written;
    if (written != sizeof(CPIO_TRAILER)) {
        return RPMERR_WRITE_FAILED;
    }

    /*
     * XXX GNU cpio pads to 512 bytes. This may matter for
     * tape device(s) and/or concatenated cpio archives.
     */

    rc = rpmcpioWritePad(cpio, 4);

    return rc;
}
예제 #24
0
파일: dragdrop.c 프로젝트: pcwalton/NetSurf
short ddsexts(short fd, char *exts)
{
	if (Fwrite(fd, DD_EXTSIZE, exts) != DD_EXTSIZE)
	{
		ddclose(fd);
		return(-1);
	}

	return(1);
}
예제 #25
0
static bool out(char ch)
{
	if (prn_hdl == -2)
		Cauxout(ch);
	else if (prn_hdl == -3)
		Cprnout(ch);
	else
		Fwrite(prn_hdl, 1, &ch);
	return TRUE;
}
예제 #26
0
파일: dragdrop.c 프로젝트: pcwalton/NetSurf
short ddreply(short fd, char ack)
{
	if (Fwrite(fd, 1L, &ack) != 1L)
	{
		ddclose(fd);
		return(-1);
	}

	return(1);
}
예제 #27
0
/****************************************************************
*																*
*			cr‚e un fichier vide d'une taille donn‚e			*
*																*
****************************************************************/
void creer_fichier(void)
{
	OBJECT *file_size;
	char nom[FILENAME_MAX] = "EMPTY.NEW", text[FILENAME_MAX];
	int ex, size, handle;

	if(!selecteur(nom, NULL, Messages(TAMPON_1)))
		return;

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

	rsrc_gaddr(R_TREE, TAILLE_FICHIER, &file_size);
	strcpy(file_size[CREATE_FILE_SIZE].ob_spec.tedinfo -> te_ptext, "1");

	ex = xdialog(Dialog[TAILLE_FICHIER].tree, NULL, NULL, NULL, TRUE, TRUE, DialogInWindow ? AUTO_DIAL|MODAL|NO_ICONIFY : FLY_DIAL|MODAL|NO_ICONIFY|SMART_FRAME);

	if (ex == CREATE_FILE_ANNU)
	{
		ajoute(Firstwindow, Messages(TAMPON_3));
		return;
	}

	size = atoi(file_size[CREATE_FILE_SIZE].ob_spec.tedinfo -> te_ptext);

	if ((handle = (int)Fcreate(nom, 0)) >! 0)
	{
		int i, err;
		char buffer[512];

		for (i=0; i<512; i++)	/* efface le buffer */
			buffer[i] = '\0';

		for (i=0; i<size; i++)	/* copie 'size' fois le buffer */
			if ((err = (int)Fwrite(handle, 512L, buffer)) < 0)
			{
				error_msg(err);
				break;
			}

		Fclose(handle);

		sprintf(text, Messages(TAMPON_4), nom, size*512L);
		ajoute(Firstwindow, text);

		if (nom[1] == ':')
			change_disque(toupper(nom[0]) -'A', TRUE);
	}
	else
	{
		error_msg(handle);
		sprintf(text, Messages(TAMPON_5), nom);
		ajoute(Firstwindow, text);
	}
} /* creer_fichier */
예제 #28
0
파일: cpio.c 프로젝트: junaruga/rpm
int rpmcpioStrippedHeaderWrite(rpmcpio_t cpio, int fx, off_t fsize)
{
    struct cpioStrippedPhysicalHeader hdr_s;
    struct cpioStrippedPhysicalHeader * hdr = &hdr_s;
    char field[64];
    size_t written;
    int rc = 0;

    if ((cpio->mode & O_ACCMODE) != O_WRONLY) {
        return RPMERR_WRITE_FAILED;
    }

    if (cpio->fileend != cpio->offset) {
        return RPMERR_WRITE_FAILED;
    }

    rc = rpmcpioWritePad(cpio, 4);
    if (rc) {
        return rc;
    }

    SET_NUM_FIELD(hdr->fx, fx, field);

    written = Fwrite(CPIO_STRIPPED_MAGIC, 6, 1, cpio->fd);
    cpio->offset += written;
    if (written != 6) {
        return RPMERR_WRITE_FAILED;
    }

    written = Fwrite(hdr, STRIPPED_PHYS_HDR_SIZE, 1, cpio->fd);
    cpio->offset += written;
    if (written != STRIPPED_PHYS_HDR_SIZE) {
        return RPMERR_WRITE_FAILED;
    }

    rc = rpmcpioWritePad(cpio, 4);

    cpio->fileend = cpio->offset + fsize;

    return rc;
}
예제 #29
0
main()
{
  handle = Fcreate ("READ.ME", LECT_SEUL);
  
  if (handle < 0)
    printf ("Erreur … l'ouverture du fichier!\n");
  else
  {
    Fwrite (handle, (long) strlen (ligne), ligne);
    Fclose (handle);
  }
}
INT _reentrant FSFileWrite(INT wNumberBytes, INT Handle, INT memory_type, INT iModulo, WORD *buffer)
{
    INT memtype;
    if (memory_type == 0x100000)
        memtype = P_MEMORY;
    else if (memory_type == 0x400000)
        memtype = Y_MEMORY;
    else
        memtype = X_MEMORY;

    return Fwrite(Handle, (INT *)buffer, (LONG) wNumberBytes, memtype, iModulo);
}