Esempio n. 1
0
static void	ls_loop_content(char *options, t_filedir *tmp_fldr, char dots)
{
	if (isdots(tmp_fldr->name) && !dots)
		return ;
	if (show_entry(options, tmp_fldr->name) || isdots(tmp_fldr->name))
	{
		ls_loop_return(options, tmp_fldr->path);
		ls_buckle(options, ls_gen_filedirs(options, tmp_fldr));
	}
	else if (ft_strchr(options, 'R'))
		ls_loop(options, ls_gen_filedirs(options, tmp_fldr), 0);
}
Esempio n. 2
0
static long
fsdirread(Chan *c, uchar *va, long count, vlong offset)
{
	char *path;
	int n, total;
	struct dirent *de;
	UnixFd *ufd;
	Dir d;

	ufd = c->aux;
	qlock(&ufd->dirlock);
	if(waserror()){
		qunlock(&ufd->dirlock);
		nexterror();
	}

	if(ufd->diroffset != offset){
		if(offset != 0)
			error(Ebadarg);
		ufd->diroffset = 0;
		ufd->nextde = nil;
		rewinddir(ufd->dir);
	}

	total = 0;
	while(total+BIT16SZ < count) {
		if(ufd->nextde){
			de = ufd->nextde;
			ufd->nextde = nil;
		}
		else if((de = readdir(ufd->dir)) == nil)
			break;
		if(isdots(de->d_name))
			continue;
		path = fspath(c, de->d_name);
		if(fsdirstat(path, c->dev, &d) < 0){
			free(path);
			continue;
		}
		n = convD2M(&d, (uchar*)va+total, count-total);
		free(path);
		if(n == BIT16SZ){
			ufd->nextde = de;
			break;
		}
		total += n;
	}
	ufd->diroffset += total;
	qunlock(&ufd->dirlock);
	poperror();
	return total;
}