[Plib-devel] reading directories
Brought to you by:
sjbaker
From: Dave M. <Dav...@dy...> - 2000-08-02 18:58:45
|
i added some functions for reading directories to "ul" /* Directory Reading */ #define UL_NAME_MAX 256 typedef struct _ulDir ulDir ; struct ulDirEnt { char d_name [ UL_NAME_MAX+1 ]; bool d_isdir ; } ; ulDir* ulOpenDir ( const char* dirname ) ; ulDirEnt* ulReadDir ( ulDir* dir ) ; void ulCloseDir ( ulDir* dir ) ; i tested the win32 implementation and wrote a unix implementation could some kind soul please comple and test my unix implementation? here is my test program: #include <plib/ul.h> void list_files( const char* dirname ) { static int level=-1; level++; ulDir* dirp = ulOpenDir(dirname); if ( dirp != NULL ) { ulDirEnt* dp; while ( (dp = ulReadDir(dirp)) != NULL ) { for ( int i=0; i<level; i++) printf(" "); printf("%s", dp->d_name ); if ( dp->d_isdir ) printf("/"); printf("\n"); if ( dp->d_isdir && strcmp (dp->d_name, ".") && strcmp (dp->d_name, "..")) { char path[ UL_NAME_MAX+1 ]; strcpy (path, dirname); strcat (path, "/"); strcat (path, dp->d_name); list_files( path ); } } ulCloseDir(dirp); } level--; } int main(int argc, char* argv[]) { list_files("."); return 0; } Steve- could you create a folder for me so i can add my test program to CVS? plib/examples/src/ul --Dave |