In article <[email protected]>,
Greg Ercolano <[email protected]> wrote:
> Greg Ercolano wrote:
> > I've never used this function before, but I whipped this short
> > example together, and it seemed to work on the first shot:
>
> Oh, and I should add that code was with 1.3.x.
>
> But I find if I comment out the fl_filename_free_list() line
> (which I guess isn't in 1.1.10), it seemed to compile and run OK
> under 1.1.10 on Snow Leopard as well, eg:
>
> * * *
>
> 03/31/11 01:56:55 /usr/local/src/fltk-1.1.10/test
> [root@snow] 31 # cat filenamelist.cxx
> #include <stdio.h>
> #include <FL/filename.H>
> int main() {
> const char *dirname = "/usr";
> dirent **dlist;
> int total = fl_filename_list(dirname, &dlist, fl_alphasort);
> for ( int t=0; t<total; t++ ) {
> printf("%d) '%s'\n", t, dlist[t]->d_name);
> }
> //fl_filename_free_list(&dlist, total);
> return(0);
> }
your code works here, as a standalone application only. my code is
basically the same but doesnt work in my app:
//{
// dirent **files;
// int num_files = fl_filename_list(cfg->get_config_path(), &files);
// pmesg(1, "num files %d\n", num_files);
// for (int i = 0; i < num_files; i++)
// {
// pmesg(1, "%s\n",files[i]->d_name);
// }
// // clean up
// for (int i = num_files; i > 0;)
// free((void*) (files[--i]));
// free((void*) files);
//}
pmesg is like printf btw. in this case it only prints a number followed
by garbage.
_______________________________________________
fltk mailing list
[email protected]
http://lists.easysw.com/mailman/listinfo/fltk