Re: Getting list of files in a directory with GLib

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Thu, May 10, 2012 at 11:24 PM, Jasper St. Pierre
<jstpierre@xxxxxxxxxxx> wrote:
> You want to use Gio.File nowadays. See listDirAsync in:
>    http://git.gnome.org/browse/gnome-shell/tree/js/misc/fileUtils.js

Thanks! I've sort of got it working.
How do I handle the whole asynchronous thing? My current code looks like:

let fileList = [];
let dir = Gio.file_new_for_path( '/path/to/the/directory' );
fileUtils.listDirAsync( dir,
                              function( fileinfos ) {
                                  fileList = fileinfos;
                              } );

If I perform this in the gnome looking glass, it works. When I do it
from gjs (whether the console or script), fileList is empty.

I assume I have to somehow wait for listDirAsync to finish its
business, or perhaps there is some scope problem? How can I simply get
the list of file infos found into fileList? (In the end I just want an
array of string paths).
_______________________________________________
gtk-list mailing list
gtk-list@xxxxxxxxx
http://mail.gnome.org/mailman/listinfo/gtk-list



[Index of Archives]     [Touch Screen Library]     [GIMP Users]     [Gnome]     [KDE]     [Yosemite News]     [Steve's Art]

  Powered by Linux