> > > so ...what's wrong with my piece of code ?
> >
> > Probably nothing. File selector ALWAYS shows directories.
>
> no it doesn't.. case on the type.. if it a DL_DIR.. don't show it.
Sorry, yes it does and fl_get_dirlist() *always* returns directories.
The following simple bit of test code illustrates the situation:
#include "forms.h"
#include "try.h"
#define SOME_DIR "/"
int my_filter( const char *name, int type )
{
fprintf( stderr, "testing %s\n", name );
return type != FT_DIR;
}
int main( int argc, char **argv )
{
const FL_Dirlist *dirlist;
int nfiles;
fl_initialize( &argc, argv, 0, 0, 0 );
fl_set_dirlist_filter( my_filter );
dirlist = fl_get_dirlist( SOME_DIR, "*", &nfiles, 1 );
while ( nfiles-- )
fprintf( stderr, "returned %s\n", dirlist[nfiles].name );
exit( 0 );
}
You'll see that the filter function is not even called for type
FT_DIR.
The only workaround is to test the files returned by fl_get_dirlist()
itself for type FT_DIR and chuck them. Given that, you probably don't
even need the filter function -- there's not much point in filtering
if you have to filter again.
dirlist = fl_get_dirlist( SOME_DIR, "*", &nfiles, 1 );
while ( nfiles-- )
if ( dirlist[nfiles].type != FT_DIR )
fprintf( stderr, "%s\n", dirlist[nfiles].name );
would do the trick.
spl
_________________________________________________
To unsubscribe, send the message "unsubscribe" to
xforms-request@bob.usuf2.usuhs.mil or see
http://bob.usuf2.usuhs.mil/mailserv/xforms.html
XForms Home Page: http://bragg.phys.uwm.edu/xforms
List Archive: http://bob.usuf2.usuhs.mil/mailserv/list-archives/