Re: [Vala] Listing directory content with GIO



Hi Jan,

I'm doing it like this:

string name;
var d = Dir.open("/path/to/dir");
while ((name = d.read_name()) != null) {
 stdout.printf("dir: %s\n", name);
}

best,
DBL
____________________________________
Daniel Benjamin Lucraft

www.daniellucraft.com/blog
twitter.com/danlucraft



2009/5/6 Jan Niklas Hasse <jhasse gmail com>:
I've tried to list the files in a directory (not using async
functions). This is what I've got:

var libPath = File.new_for_path("/lib/");
var enumerator =
libPath.enumerate_children(FILE_ATTRIBUTE_STANDARD_NAME, 0, null);
var fileinfo = enumerator.next_file(null);
while(fileinfo != null)
{
       stdout.printf("%s\n", fileinfo.get_name());
       fileinfo = enumerator.next_file(null);
}

Is there an easier way of doing it? I don't like that I have "fileinfo
= enumerator.next_file(null);" two times in my code.

I also found two minor glitches in the doc.
1. At the bottom of the page the constants are over the text on the
right: http://valadoc.org/?pkg=gio-2.0&element=GLib
2. A space is missing before GLib.FileEnumerator:
http://valadoc.org/?pkg=gio-2.0&element=GLib.File.enumerate_children
_______________________________________________
Vala-list mailing list
Vala-list gnome org
http://mail.gnome.org/mailman/listinfo/vala-list




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