Beispiel #1
0
static int manio_open_next_fpath(struct manio *manio)
{
	static struct stat statp;

	free_w(&manio->offset->fpath);
	if(!(manio->offset->fpath=get_next_fpath(manio, manio->offset)))
		return -1;

	if(!strcmp(manio->mode, MANIO_MODE_READ)
	  && lstat(manio->offset->fpath, &statp))
		return 0;

	if(build_path_w(manio->offset->fpath))
		return -1;
	switch(manio->phase)
	{
		case 2:
			if(!(manio->fzp=fzp_open(manio->offset->fpath,
				manio->mode))) return -1;
			return 0;
		case 1:
		case 3:
		default:
			if(!(manio->fzp=fzp_gzopen(manio->offset->fpath,
				manio->mode))) return -1;
			return 0;
	}
}
Beispiel #2
0
int manio_open_next_fpath(struct manio *manio)
{
	static struct stat statp;

	if(!(manio->offset.fpath=get_next_fpath(manio))) return -1;

	if(!strcmp(manio->mode, MANIO_MODE_READ)
	  && lstat(manio->offset.fpath, &statp))
		return 0;

	if(build_path_w(manio->offset.fpath)
	  || !(manio->fzp=fzp_gzopen(manio->offset.fpath, manio->mode)))
		return -1;
	return 0;
}
Beispiel #3
0
static int open_next_fpath(struct manio *manio)
{
	static struct stat statp;

	if(manio->lpath) free(manio->lpath);
	manio->lpath=manio->fpath;
	if(!(manio->fpath=get_next_fpath(manio))) return -1;

	if(!strcmp(manio->mode, MANIO_MODE_READ)
	  && lstat(manio->fpath, &statp))
		return 0;

	if(build_path_w(manio->fpath)
	  || !(manio->zp=gzopen_file(manio->fpath, manio->mode)))
		return -1;
	return 0;
}
Beispiel #4
0
static int remove_trailing_files(struct manio *manio, man_off_t *offset)
{
	int ret=-1;
	char *fpath=NULL;
	struct stat statp;
	while(1)
	{
		free_w(&fpath);
		if(!(fpath=get_next_fpath(manio, offset)))
			goto end;
		if(lstat(fpath, &statp)) break;
		if(!S_ISREG(statp.st_mode))
			goto end;
		if(recursive_delete(fpath))
			goto end;
	}
	ret=0;
end:
	free_w(&fpath);
	return ret;
}