#include <stdio.h>
#include <Xfwf/Directory.h>

/*
 * Author:
 * 	Brian Totty
 * 	Department of Computer Science
 * 	University Of Illinois at Urbana-Champaign
 *	1304 West Springfield Avenue
 * 	Urbana, IL 61801
 * 
 * 	totty@cs.uiuc.edu
 * 	
 */ 

int main(argc,argv)
int argc;
char **argv;
{
	Directory directory;
	DirEntry entry;

	if (DirectoryOpen(argv[1],&directory) == FALSE)
	{
		fprintf(stderr,"Can't open directory '%s'\n",argv[1]);
		exit(-1);
	}
	printf("*** Listing Of Directory '%s' ***\n",
	       DirectoryPath(&directory));
	while (DirectoryReadNextEntry(&directory,&entry))
	{
		printf("<Type %5d,  File '%20s',  Mode %3d,  Size %d>\n",
		       DirEntryType(&entry),
		       DirEntryFileName(&entry),
		       DirEntryProt(&entry),
		       DirEntryFileSize(&entry));
	}
	printf("\nChange the directory please...sleeping 5 seconds...\n\n");
	sleep(5);
	DirectoryRestart(&directory);
	while (DirectoryReadNextEntry(&directory,&entry))
	{
		printf("<Type %5d,  File '%20s',  Mode %3d,  Size %d>\n",
		       DirEntryType(&entry),
		       DirEntryFileName(&entry),
		       DirEntryProt(&entry),
		       DirEntryFileSize(&entry));
	}
	return(1);
}
