当前位置: 首页>>代码示例>>C++>>正文


C++ Fclose函数代码示例

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


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

示例1: printf

//------------------------------------------------------------------
void Error::FileA(const char *class_name, const char *func_name,
                  const char *file_name)   // file name
{
    FILE *fp;
    error_func_name = "FileA";

    printf(error_string[file_a], class_name, func_name, file_name);

    if( (fp = Fopen(ALL_NODES,error_file_name, "w")) == NULL ) {
        printf(error_string[file_w], error_class_name, error_func_name, error_file_name);
        Exit(exit_value[file_w]);
    }
    Fprintf(fp, error_string[file_a], class_name, func_name, file_name);
    Fclose(fp);

    Exit(exit_value[file_a]);
}
开发者ID:DeanHowarth,项目名称:QUDA-CPS,代码行数:18,代码来源:error.C

示例2: rpmwfFini

rpmRC rpmwfFini(rpmwf wf)
{
    int xx;

if (_rpmwf_debug)
fprintf(stderr, "==> rpmwfFini(%p)\n", wf);

    if (wf->b && wf->b != (void *)-1) {
	xx = munmap(wf->b, wf->nb);
	wf->b = NULL;
    }
    if (wf->fd) {
	(void) Fclose(wf->fd);
	wf->fd = NULL;
    }
    return RPMRC_OK;
}
开发者ID:cmjonze,项目名称:rpm5_tarballs,代码行数:17,代码来源:rpmwf.c

示例3: load

/*
 * Load a file of user definitions.
 */
void
load(char *name)
{
	FILE *in, *oldin;

	if ((in = Fopen(name, "r")) == NULL)
		return;
	oldin = input;
	input = in;
	loading = 1;
	sourcing = 1;
	commands();
	loading = 0;
	sourcing = 0;
	input = oldin;
	(void)Fclose(in);
}
开发者ID:coyizumi,项目名称:cs111,代码行数:20,代码来源:lex.c

示例4: makeGPGSignature

/**
 * Generate GPG signature(s) for a header+payload file.
 * @param sigh		signature header
 * @param ishdr		header-only signature?
 * @param sigt		signature target
 * @param passPhrase	private key pass phrase
 * @return		0 on success, 1 on failure
 */
static int makeGPGSignature(Header sigh, int ishdr, sigTarget sigt)
{
    char * sigfile = rstrscat(NULL, sigt->fileName, ".sig", NULL);
    struct stat st;
    uint8_t * pkt = NULL;
    size_t pktlen = 0;
    int rc = 1; /* assume failure */

    if (runGPG(sigt, sigfile))
	goto exit;

    if (stat(sigfile, &st)) {
	/* GPG failed to write signature */
	rpmlog(RPMLOG_ERR, _("gpg failed to write signature\n"));
	goto exit;
    }

    pktlen = st.st_size;
    rpmlog(RPMLOG_DEBUG, "GPG sig size: %zd\n", pktlen);
    pkt = xmalloc(pktlen);

    {	FD_t fd;

	rc = 0;
	fd = Fopen(sigfile, "r.ufdio");
	if (fd != NULL && !Ferror(fd)) {
	    rc = Fread(pkt, sizeof(*pkt), pktlen, fd);
	    (void) Fclose(fd);
	}
	if (rc != pktlen) {
	    rpmlog(RPMLOG_ERR, _("unable to read the signature\n"));
	    goto exit;
	}
    }

    rpmlog(RPMLOG_DEBUG, "Got %zd bytes of GPG sig\n", pktlen);

    /* Parse the signature, change signature tag as appropriate. */
    rc = putSignature(sigh, ishdr, pkt, pktlen);
exit:
    (void) unlink(sigfile);
    free(sigfile);
    free(pkt);

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

示例5: F_close

F_close()
    {
    register char wRetStat;
    register int iocb16, iocb;

    iocb16 = reg_X;
    iocb = iocb16 >> 4;

    Fclose(rgwDOShand[iocb]);
    rgwDOShand[iocb] = -1;

    wRetStat = 1;
    reg_Y = wRetStat;

    reg_Z = wRetStat;
    reg_N = (wRetStat & 0x80) ? TRUE : FALSE;
    reg_PC = 0xE45B;
    }
开发者ID:daemqn,项目名称:Atari_ST_Sources,代码行数:18,代码来源:XFDRIVER.C

示例6: Fopen

void RpmTransaction::addToTransactionInstall(const StringVector& files)
{
  for (StringVector::size_type i = 0;i < files.size();i++)
    {
      FD_t fd = Fopen(files[i].c_str(), "r.ufdio");
      if (fd == NULL)
	throw PkgBackEndException("Fopen(" + files[i] + ")");
      Header hdr;
      int rc = rpmReadPackageHeader(fd, &hdr, 0, NULL, NULL);
      if (rc != 0)
	throw PkgBackEndException("rpmReadPackageHeader()");
      rc = rpmtransAddPackage(m_ts, hdr, NULL, files[i].c_str(), 0, 0);
      if (rc != 0)
	throw PkgBackEndException("rpmtransAddPackage()");
      headerFree(hdr);
      Fclose(fd);
    }
}
开发者ID:marigostra,项目名称:deepsolver,代码行数:18,代码来源:RpmTransaction.cpp

示例7: Fopen

void RpmTransaction::addToTransactionUpgrade(const StringVector& files)
{
  for (StringVector::size_type i = 0;i < files.size();i++)
    {
      FD_t fd = Fopen(files[i].c_str(), "r.ufdio");
      if (fd == NULL)
	RPMSTOP("Fopen()");
      Header hdr;
      int rc = rpmReadPackageHeader(fd, &hdr, 0, NULL, NULL);
      if (rc != 0)
	RPMSTOP("rpmReadPackageHeader()");
      rc = rpmtransAddPackage(m_ts, hdr, NULL, files[i].c_str(), 1, 0);
      if (rc != 0)
	RPMSTOP("rpmtransAddPackage()");
      headerFree(hdr);
      Fclose(fd);
    }
}
开发者ID:marigostra,项目名称:deepsolver,代码行数:18,代码来源:rpmtrans.cpp

示例8: main

int main(int argc, char* argv[])
{
    FILE *fp;
    const char *file = "kj2010030144.txt";
    char buf[500];
    int len;

    memset(buf, 0, sizeof(buf));
    fp = Fopen(file, "r");
    Fgets(buf, 500, fp);
    len = strlen(buf) - 1;
    buf[len] = 0;

    printf("%s", buf);

    Fclose(fp);
	return 0;
}
开发者ID:bsdcpp,项目名称:mylib,代码行数:18,代码来源:file.c

示例9: ReadTestFile

//###################################################################################
void ReadTestFile(char *name, unsigned char *buf, U16 bufsize)
//###################################################################################
{
 unsigned long i;
 S16 fileid;

 fileid=Fopen("01.TXT",F_READ);
 if(fileid>=0 && fileid<MAX_OPEN_FILE)
  {
   StartTimer();
   for(i=0; i<TEST_FILE_SIZE; i+=bufsize)
    {
     if(Fread(buf,bufsize,fileid)!=bufsize) break;
    }
   Fclose(fileid);
   printf("% 3lu",(U32)bufsize);
   StopTimer();
  }
}
开发者ID:976717326,项目名称:imu_autopilot,代码行数:20,代码来源:main.c

示例10: mesedit

/*
 * Edit the message being collected on fp.
 * On return, make the edit file the new temp file.
 */
static void 
mesedit(int c, struct header *hp)
{
	sighandler_type sigint = safe_signal(SIGINT, SIG_IGN);
	FILE *nf = run_editor(collf, (off_t)-1, c, 0, hp, NULL, SEND_MBOX,
			sigint);

	if (nf != NULL) {
		if (hp) {
			rewind(nf);
			makeheader(nf, hp);
		} else {
			fseek(nf, 0L, SEEK_END);
			Fclose(collf);
			collf = nf;
		}
	}
	safe_signal(SIGINT, sigint);
}
开发者ID:Babar,项目名称:check_multi,代码行数:23,代码来源:collect.c

示例11: resetdccs

int resetdccs(){
short temp=9;
while(temp>-1){
if(dcc[temp].dcfh){Fclose(dcc[temp].dcfh);dcc[temp].dcfh=-1;}
if(dcc[temp].cn)TCP_close(dcc[temp].cn,1);
strcpy(dcc[temp].avec,"\0");
strcpy(dcc[temp].fname,"\0");

dcc[temp].cn=0;
dcc[temp].dcfh=-1;
dcc[temp].stat=0;
dcc[temp].cnt=0;
dcc[temp].lack=0;
dcc[temp].dir=-1;
temp--;
}

return 0;
}
开发者ID:daemqn,项目名称:Atari_ST_Sources,代码行数:19,代码来源:dcc.c

示例12: rpmcliVerify

int rpmcliVerify(rpmts ts, QVA_t qva, char * const * argv)
{
    rpmVSFlags vsflags, ovsflags;
    int ec = 0;
    FD_t scriptFd = fdDup(STDOUT_FILENO);

    /* 
     * Open the DB + indices explicitly before possible chroot,
     * otherwises BDB is going to be unhappy...
     */
    rpmtsOpenDB(ts, O_RDONLY);
    rpmdbOpenAll(rpmtsGetRdb(ts));
    if (rpmChrootSet(rpmtsRootDir(ts)) || rpmChrootIn()) {
	ec = 1;
	goto exit;
    }

    if (qva->qva_showPackage == NULL)
        qva->qva_showPackage = showVerifyPackage;

    vsflags = rpmExpandNumeric("%{?_vsflags_verify}");
    vsflags |= rpmcliVSFlags;
    vsflags &= ~RPMVSF_NEEDPAYLOAD;

    rpmtsSetScriptFd(ts, scriptFd);
    ovsflags = rpmtsSetVSFlags(ts, vsflags);
    ec = rpmcliArgIter(ts, qva, argv);
    rpmtsSetVSFlags(ts, ovsflags);
    rpmtsSetScriptFd(ts, NULL);

    if (qva->qva_showPackage == showVerifyPackage)
        qva->qva_showPackage = NULL;

    rpmtsEmpty(ts);

    if (rpmChrootOut() || rpmChrootSet(NULL))
	ec = 1;

exit:
    Fclose(scriptFd);

    return ec;
}
开发者ID:nforro,项目名称:rpm,代码行数:43,代码来源:verify.c

示例13: rpmPackageFilesArchive

static int rpmPackageFilesArchive(rpmfiles fi, int isSrc,
				  FD_t cfd, ARGV_t dpaths,
				  rpm_loff_t * archiveSize, char ** failedFile)
{
    int rc = 0;
    rpmfi archive = rpmfiNewArchiveWriter(cfd, fi);

    while (!rc && (rc = rpmfiNext(archive)) >= 0) {
        /* Copy file into archive. */
	FD_t rfd = NULL;
	const char *path = dpaths[rpmfiFX(archive)];

	rfd = Fopen(path, "r.ufdio");
	if (Ferror(rfd)) {
	    rc = RPMERR_OPEN_FAILED;
	} else {
	    rc = rpmfiArchiveWriteFile(archive, rfd);
	}

	if (rc && failedFile)
	    *failedFile = xstrdup(path);
	if (rfd) {
	    /* preserve any prior errno across close */
	    int myerrno = errno;
	    Fclose(rfd);
	    errno = myerrno;
	}
    }

    if (rc == RPMERR_ITER_END)
	rc = 0;

    /* Finish the payload stream */
    if (!rc)
	rc = rpmfiArchiveClose(archive);

    if (archiveSize)
	*archiveSize = (rc == 0) ? rpmfiArchiveTell(archive) : 0;

    rpmfiFree(archive);

    return rc;
}
开发者ID:nforro,项目名称:rpm,代码行数:43,代码来源:pack.c

示例14: wfd_close

static void wfd_close(FD_t *wfdp)
{
    if (wfdp && *wfdp) {
	int myerrno = errno;
	static int oneshot = 0;
	static int flush_io = 0;
	if (!oneshot) {
	    flush_io = rpmExpandNumeric("%{?_flush_io}");
	    oneshot = 1;
	}
	if (flush_io) {
	    int fdno = Fileno(*wfdp);
	    fsync(fdno);
	}
	Fclose(*wfdp);
	*wfdp = NULL;
	errno = myerrno;
    }
}
开发者ID:nforro,项目名称:rpm,代码行数:19,代码来源:fsm.c

示例15: read_labels

mnist_labels_t read_labels(uint32_t train)
{
    char *full_path;
    if (train) {
        full_path = concat_fname(mnist_path, train_label_fname);
    } else {
        full_path = concat_fname(mnist_path, test_label_fname);
    }

    char *mode = FILE_MODE;

    FILE *fp = Fopen(full_path, mode); 

    uint8_t header[LABEL_HEADER_SIZE];
    Fread(header, sizeof(uint8_t), LABEL_HEADER_SIZE, fp);

    uint32_t num_labels = read_word(header, NUM_ITEMS_OFFSET);

    vector_t lbls = Vector((size_t) num_labels);

    uint8_t *label_bytes = (uint8_t*) Calloc(num_labels, sizeof(uint8_t));
    uint32_t actual_size;
    if ((actual_size = fread(label_bytes, sizeof(uint8_t), num_labels, fp)) < num_labels) {
        Free(label_bytes);
        vector_destroy(lbls);
        return NULL;
    }

    uint32_t *vector_data = (uint32_t*) Calloc(num_labels, sizeof(uint32_t));
    for (uint32_t i = 0; i < num_labels; i++) {
        vector_data[i] = (uint32_t) label_bytes[i];
    }
    lbls->data = vector_data;

    mnist_labels_t mnist_lbls = Mnist_labels((size_t) num_labels);
    mnist_lbls->labels = lbls;

    Free(full_path);
    Free(label_bytes);
    Fclose(fp);
    return mnist_lbls;
}
开发者ID:kkudrolli,项目名称:Team-SDK-545,代码行数:42,代码来源:mnist.c


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