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

C++ setfile函数代码示例

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

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



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

示例1: openwithcontrol

static void openwithcontrol (lua_State *L) {
  IOCtrl *ctrl = (IOCtrl *)lua_newuserdata(L, sizeof(IOCtrl));
  unsigned int i;
  ctrl->iotag = lua_newtag(L);
  ctrl->closedtag = lua_newtag(L);
  for (i=0; i<sizeof(iolibtag)/sizeof(iolibtag[0]); i++) {
    /* put `ctrl' as upvalue for these functions */
    lua_pushvalue(L, -1);
    lua_pushcclosure(L, iolibtag[i].func, 1);
    lua_setglobal(L, iolibtag[i].name);
  }
  /* create references to variable names */
  lua_pushstring(L, filenames[INFILE]);
  ctrl->ref[INFILE] = lua_ref(L, 1);
  lua_pushstring(L, filenames[OUTFILE]);
  ctrl->ref[OUTFILE] = lua_ref(L, 1);
  /* predefined file handles */
  setfile(L, ctrl, stdin, INFILE);
  setfile(L, ctrl, stdout, OUTFILE);
  setfilebyname(L, ctrl, stdin, "_STDIN");
  setfilebyname(L, ctrl, stdout, "_STDOUT");
  setfilebyname(L, ctrl, stderr, "_STDERR");
  /* close files when collected */
  lua_pushcclosure(L, file_collect, 1);  /* pops `ctrl' from stack */
  lua_settagmethod(L, ctrl->iotag, "gc");
}
开发者ID:philm001,项目名称:Omni-FEM,代码行数:26,代码来源:liolib.cpp


示例2: openwithtags

static void openwithtags() {
	int32 iotag = lua_newtag();
	int32 closedtag = lua_newtag();
	uint32 i;
	for (i = 0; i < sizeof(iolibtag) / sizeof(iolibtag[0]); i++) {
		// put both tags as upvalues for these functions
		lua_pushnumber(iotag);
		lua_pushnumber(closedtag);
		lua_pushCclosure(iolibtag[i].func, 2);
		lua_setglobal(iolibtag[i].name);
	}

	g_fin = new LuaFile();
	g_fin->_stdin = true;
	setfile(addfile(g_fin), FINPUT, iotag);

	g_fout = new LuaFile();
	g_fout->_stdout = true;
	setfile(addfile(g_fout), FOUTPUT, iotag);

	g_stdin = new LuaFile();
	g_stdin->_stdin = true;
	setfile(addfile(g_stdin), "_STDIN", iotag);

	g_stdout = new LuaFile();
	g_stdout->_stdout = true;
	setfile(addfile(g_stdout), "_STDOUT", iotag);

	g_stderr = new LuaFile();
	g_stderr->_stderr = true;
	setfile(addfile(g_stderr), "_STDERR", iotag);
}
开发者ID:raziel-,项目名称:residualvm,代码行数:32,代码来源:liolib.cpp


示例3: copy_directory

/**
 * copy a directory between branches (includes all contents of the directory)
 */
int copy_directory(const char *path, int branch_ro, int branch_rw) {
	DBG("%s\n", path);

	/* create the directory on the destination branch */
	int res = path_create(path, branch_ro, branch_rw);
	if (res != 0) {
		RETURN(res);
	}

	/* determine path to source directory on read-only branch */
	char from[PATHLEN_MAX];
	if (BUILD_PATH(from, uopt.branches[branch_ro].path, path)) RETURN(1);

	DIR *dp = opendir(from);
	if (dp == NULL) RETURN(1);

	struct dirent *de;
	while ((de = readdir(dp)) != NULL) {
		if (strcmp(de->d_name, ".") == 0 || strcmp(de->d_name, "..") == 0) continue;

		char member[PATHLEN_MAX];
		if (BUILD_PATH(member, path, "/", de->d_name)) {
			res = 1;
			break;
		}
		res = cow_cp(member, branch_ro, branch_rw, true);               
		if (res != 0) break;
	}

	closedir(dp);
	struct stat  buf;
	lstat(from, &buf);
	setfile(from, &buf);
	RETURN(res);
}
开发者ID:luckpizza,项目名称:unionfs-fuse-for-android,代码行数:38,代码来源:cow.c


示例4: Prim_PCLOSE

/******************************************************************************
 * Prim_PCLOSE - close a pipe opened by Prim_POPEN().
 * (code stolen from xlfio.c:xclose())
 *
 * syntax: (pclose <stream>)
 *                  <stream> is a stream created by popen.
 * returns T if the command executed successfully, otherwise, 
 * returns the exit status of the opened command.
 *
 * Added to XLISP by Niels Mayer
 ******************************************************************************/
LVAL Prim_PCLOSE()
{
  extern LVAL true;
  LVAL fptr;
  int  result;

  /* get file pointer */
  fptr = xlgastream();
  xllastarg();

  /* make sure the file exists */
  if (getfile(fptr) == NULL)
    xlfail("file not open");

  /* close the pipe */
  result = pclose(getfile(fptr));

  if (result == -1)
    xlfail("<stream> has not been opened with popen");
    
  setfile(fptr,NULL);

  /* return T if success (exit status 0), else return exit status */
  return (result ? cvfixnum(result) : true);
}
开发者ID:carriercomm,项目名称:veos,代码行数:36,代码来源:unixstuff.c


示例5: null_close

int
null_close(void *cookie, struct z_info *info, const char *name, struct stat *sb)
{
	null_stream *s = (null_stream*) cookie;
	int err = 0;

	if (s == NULL)
		return -1;


	if (info != NULL) {
		info->mtime = 0;
		info->crc =  (u_int32_t)-1;
		info->hlen = 0;
		info->total_in = (off_t) s->total_in;
		info->total_out = (off_t) s->total_out;
	}

	setfile(name, s->fd, sb);
	err = close(s->fd);

	free(s);

	return err;
}
开发者ID:repos-holder,项目名称:openbsd-patches,代码行数:25,代码来源:nullopen.c


示例6: copy_link

int
copy_link(const FTSENT *p, int exists)
{
	int len;
	char llink[PATH_MAX];

	if (exists && nflag) {
		if (vflag)
			printf("%s not overwritten\n", to.p_path);
		return (1);
	}
	if ((len = readlink(p->fts_path, llink, sizeof(llink) - 1)) == -1) {
		warn("readlink: %s", p->fts_path);
		return (1);
	}
	llink[len] = '\0';
	if (exists && unlink(to.p_path)) {
		warn("unlink: %s", to.p_path);
		return (1);
	}
	if (symlink(llink, to.p_path)) {
		warn("symlink: %s", llink);
		return (1);
	}
	return (pflag ? setfile(p->fts_statp, -1) : 0);
}
开发者ID:jhbsz,项目名称:JabirOS-source,代码行数:26,代码来源:utils.c


示例7: outputfile

void outputfile(char *buf, char *orgbuf, char *ext)
{
    if (has_output_file)
        AddExt(buf, ext);
    else
        setfile(buf, orgbuf, ext);
}
开发者ID:doniexun,项目名称:OrangeC,代码行数:7,代码来源:osutil.c


示例8: copy_special

/**
 * copy a special file, actually we recreate this file and only copy
 * its stat() data
 */
int copy_special(struct cow *cow)
{
	if (mknod(cow->to_path, cow->stat->st_mode, cow->stat->st_rdev)) {
		syslog(LOG_WARNING,   "mknod: %s", cow->to_path);
		return (1);
	}
	return setfile(cow->to_path, cow->stat);
}
开发者ID:glk,项目名称:puffs,代码行数:12,代码来源:cow_utils.c


示例9: copy_fifo

/**
 * copy a fifo, actually we recreate the fifo and only copy
 * its stat() data
 **/
int copy_fifo(struct cow *cow)
{
	if (mkfifo(cow->to_path, cow->stat->st_mode)) {
		syslog(LOG_WARNING,   "mkfifo: %s", cow->to_path);
		return (1);
	}
	return setfile(cow->to_path, cow->stat);
}
开发者ID:glk,项目名称:puffs,代码行数:12,代码来源:cow_utils.c


示例10: cvfile

/* cvfile - convert a file pointer to a stream */
LVAL cvfile(FILE *fp)
{
    LVAL val;
    val = newnode(STREAM);
    setfile(val,fp);
    setsavech(val,'\0');
    return (val);
}
开发者ID:andreipaga,项目名称:audacity,代码行数:9,代码来源:xldmem.c


示例11: newnode

/* cvfile - convert a file pointer to a file */
NODE *cvfile( FILE *fp)
{
    NODE *val;
    val = newnode(FPTR);
    setfile(val,fp);
    setsavech(val,0);
    return (val);
}
开发者ID:8l,项目名称:csolve,代码行数:9,代码来源:xldmem.c


示例12: setreturn

static int setreturn (lua_State *L, IOCtrl *ctrl, FILE *f, int inout) {
  if (f == NULL)
    return pushresult(L, 0);
  else {
    setfile(L, ctrl, f, inout);
    lua_pushusertag(L, f, ctrl->iotag);
    return 1;
  }
}
开发者ID:philm001,项目名称:Omni-FEM,代码行数:9,代码来源:liolib.cpp


示例13: openwithtags

static void openwithtags (void)
{
  int iotag = lua_newtag();
  int closedtag = lua_newtag();
  int i;
  for (i=0; i<sizeof(iolibtag)/sizeof(iolibtag[0]); i++) {
    /* put both tags as upvalues for these functions */
    lua_pushnumber(iotag);
    lua_pushnumber(closedtag);
    lua_pushCclosure(iolibtag[i].func, 2);
    lua_setglobal(iolibtag[i].name);
  }
  setfile(stdin, FINPUT, iotag);
  setfile(stdout, FOUTPUT, iotag);
  setfile(stdin, "_STDIN", iotag);
  setfile(stdout, "_STDOUT", iotag);
  setfile(stderr, "_STDERR", iotag);
}
开发者ID:jeske,项目名称:hz,代码行数:18,代码来源:liolib.c


示例14: file

/*
 * Change to another file.  With no argument, print information about
 * the current file.
 */
int
file(char **argv)
{
    if (argv[0] == NULL) {
        newfileinfo(0);
        return (0);
    }
    if (setfile(*argv) < 0)
        return (1);
    announce();
    return (0);
}
开发者ID:Gwenio,项目名称:DragonFlyBSD,代码行数:16,代码来源:cmd3.c


示例15: copy_ro_rw_stat

/**
 *
 * Sets a file/dir stat to it's original in the RO branch
 *	path: relative path to the file/dir
 *	nbranch_ro: number of the branch used as ro
 * 	nbranch_rw: number of the branch used as rw
*/
int copy_ro_rw_stat(char * path, int nbranch_ro, int nbranch_rw)
{
	if (nbranch_ro == nbranch_rw) RETURN(0); // same file -> nothing to do here
	
	char ro_dir_path[PATHLEN_MAX]; // original dir path
	char rw_dir_path[PATHLEN_MAX]; // dir path to create
	sprintf(ro_dir_path, "%s%s", uopt.branches[nbranch_ro].path, path);
	struct stat buf;
	if (stat(ro_dir_path, &buf) == -1) RETURN(1);
	sprintf(rw_dir_path, "%s%s", uopt.branches[nbranch_rw].path, path);
	if (setfile(rw_dir_path, &buf))  RETURN(1); // directory already removed by another process?
	RETURN(0);
}
开发者ID:luckpizza,项目名称:unionfs-fuse-for-android,代码行数:20,代码来源:cow.c


示例16: copy_fifo

int
copy_fifo(struct stat *from_stat, int exists)
{
    if (exists && unlink(to.p_path)) {
        warn("unlink: %s", to.p_path);
        return (1);
    }
    if (mkfifo(to.p_path, from_stat->st_mode)) {
        warn("mkfifo: %s", to.p_path);
        return (1);
    }
    return (pflag ? setfile(from_stat, -1) : 0);
}
开发者ID:nthery,项目名称:DragonFlyBSD,代码行数:13,代码来源:utils.c


示例17: copy_special

int
copy_special(struct stat *from_stat, int exists)
{
    if (exists && unlink(to.p_path)) {
        warn("unlink: %s", to.p_path);
        return (1);
    }
    if (mknod(to.p_path, from_stat->st_mode, from_stat->st_rdev)) {
        warn("mknod: %s", to.p_path);
        return (1);
    }
    return (pflag ? setfile(from_stat, -1) : 0);
}
开发者ID:nthery,项目名称:DragonFlyBSD,代码行数:13,代码来源:utils.c


示例18: setreffile

void setreffile(struct file *datafile,struct data *d,char *refpar)
{
  char filename[MAXPATHLEN],refname[MAXPATHLEN];
  int i,filenamectr=0,refnamectr=0;

  /* Get the reference name from the reference parameter */
  strcpy(refname,*sval(refpar,&d->p));

  /* If recon is straight after acquisition ... */
  if (vnmrj_recon && spar(d,"file","exp")) {
      /* Use the reference name as is */
      setfile(datafile,refname);
  } else {
    if (vnmrj_recon) { /* Recon from within VnmrJ */
      /* Use the path as defined in the parameter "file" */
      strcpy(filename,*sval("file",&d->p));
    } else { /* Recon outside of VnmrJ */
      /* Use the path as defined in d->file */
      strcpy(filename,d->file);
      filename[strlen(filename)-8]=0;  /* NULL terminate to remove .fid/fid */
    }
    /* Now use the path as defined in filename */
    for (i=0;i<strlen(filename);i++)
      if (filename[i] == '/') filenamectr=i;
    if (filenamectr>0) filenamectr++;
    for (i=0;i<strlen(refname);i++)
      if (refname[i] == '/') refnamectr=i;
    if (refnamectr>0) refnamectr++;
    for (i=refnamectr;i<strlen(refname);i++) {
      filename[filenamectr]=refname[i];
      filenamectr++;
    }
    filename[filenamectr]=0; /* NULL terminate */
    setfile(datafile,filename);
  }

}
开发者ID:DanIverson,项目名称:OpenVnmrJ,代码行数:37,代码来源:dutils.c


示例19: eqn

int
eqn(int argc,char **argv) {
	int i, type;

	setfile(argc,argv);
	init_tbl();	/* install keywords in tables */
	while ((type=getline(&in, &insize)) != EOF) {
		eqline = linect;
		if (type == lefteq)
			do_inline();
		else if (*in == '.') {
			char *p;
			printf("%s",in);
			for (p = in + 1; *p == ' ' || *p == '\t'; p++);
			if (!*p || *p != 'E' || p[1] != 'Q') continue;
			for (i=11; i<100; used[i++]=0);
			printf(".nr 99 \\n(.s\n.nr 98 \\n(.f\n");
			printf(".if \\n(.X .nrf 99 \\n(.s\n");
			markline = 0;
			init();
			yyparse();
			if (eqnreg>0) {
				printf(".nr %d \\w'\\*(%d'\n", eqnreg, eqnreg);
				/* printf(".if \\n(%d>\\n(.l .tm too-long eqn, file %s, between lines %d-%d\n",	*/
				/*	eqnreg, svargv[ifile], eqline, linect);	*/
				printf(".nr MK %d\n", markline);	/* for -ms macros */
				printf(".if %d>\\n(.v .ne %du\n", eqnht, eqnht);
				printf(".rn %d 10\n", eqnreg);
				if(!noeqn)printf("\\*(10\n");
			}
			printf(".ps \\n(99\n.ft \\n(98\n");
			printf(".EN");
			if (lastchar == EOF) {
				putchar('\n');
				break;
			}
			if (putchar(lastchar) != '\n')
				while (putchar(gtc()) != '\n');
		} else
			printf("%s",in);
	}
	return(0);
}
开发者ID:bapt,项目名称:heirloom-doctools,代码行数:43,代码来源:io.c


示例20: xclose

/* xclose - close a file */
LVAL xclose(void)
{
    LVAL fptr;

    /* get file pointer */
    fptr = xlgastream();
    xllastarg();

    /* make sure the file exists */
    if (getfile(fptr) == NULL)
        xlfail("file not open");

    /* close the file */
    osclose(getfile(fptr));
    setfile(fptr,NULL);

    /* return nil */
    return (NIL);
}
开发者ID:AaronFae,项目名称:VimProject,代码行数:20,代码来源:xlfio.c



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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