#ident "$URL: svn://elmer/devel/SVN/SDDAS/trunk/libant/DirList.c $ %D% SwRI" /* DirList.c -- code to read dirs and form lists of files */ #include #include #include #include "LinkList.h" /* DirToList -- reads directory, forms list of suitable files */ LinkList DirToList(char *pathname) { DIR *dirp; /* UNIX nasty that describes directory */ struct dirent *dp; /* UNIX nasty that describes dir entry */ LinkList list=0; /* list of suitable files */ /* empty list if dir cannot open */ if (!(dirp = opendir(pathname))) return 0; /* build list of suitable files */ for (dp = readdir(dirp); dp; dp = readdir(dirp)) list = LinkAppend(list,strdup(dp->d_name)); closedir(dirp); return list; }