Example #1
0
FILE *fopentmpfile(PCStr(path),int remove)
{	FILE *fp;
	int fd;

	if( isWindowsCE() ){
		fp = fopen_tmpfile(path);
		add_FILEY(FL_ARG,"fopentmpfile",fp);
	}else
	if( ACT_UNLINKABLE ){
		if( fp = fopen(path,FOPEN_RWB) )
			if( remove )
				unlink(path);
	}else{
		fd = newtmp(path);
		if( 0 <= fd ){
			if( fp = fdopen(fd,FOPEN_RWB) ){
				addtmp(fd,path);
				add_FILEY(FL_ARG,"fopentmpfile",fp);
				LV("fopentmpfile(%s) %x/%d",path,p2i(fp),fileno(fp));
			}else	LE("cannot fdopen(%d) %s",fd,path);
		}else{
			LE("cannot open tmpfile(%s)",path);
			fp = NULL;
		}
	}
	return fp;
}
Example #2
0
File: disc.c Project: 4ad/sam
Discdesc *
Dstart(void)
{
	int i, fd;
	Discdesc *dd;

	for(i=0, dd=desc; dd->fd; i++, dd++)
		if(i == NBUFFILES-1)
			panic("too many buffer files");
	fd = newtmp(i);
	if(fd < 0)
		panic("can't create buffer file");
	dd->fd = fd;
	return dd;
}