Plan 9 from Bell Labs’s /usr/web/sources/contrib/quanstro/root/sys/src/fs/ila/pdir.c

Copyright © 2021 Plan 9 Foundation.
Distributed under the MIT License.
Download the Plan 9 distribution.


#include<u.h>
#include<libc.h>
#include<bio.h>

void
main(int argc, char **argv)
{
	Dir *d;
	Biobuf b;
	long i, n;
	int fd;

	ARGBEGIN{
	}ARGEND

	if(Binit(&b, 1, OWRITE) == -1)
		sysfatal("Binit: %r");

	if(argc == 0){
		n = dirreadall(0, &d);
		for(i = 0; i < n; i++)
			Bprint(&b, "%s\n", d[i].name);
		free(d);
	}
	for(; *argv; argv++){
		fd = open(*argv, OREAD);
		if(fd == -1)
			sysfatal("open: %r");
		n = dirreadall(fd, &d);
		for(i = 0; i < n; i++)
			Bprint(&b, "%s\n", d[i].name);
		free(d);
		close(fd);
	}
	exits("");
}

Bell Labs OSI certified Powered by Plan 9

(Return to Plan 9 Home Page)

Copyright © 2021 Plan 9 Foundation. All Rights Reserved.
Comments to webmaster@9p.io.