I'm new to D and GtkD. Sorry my English. Sorry for the edition of the text.
I need to use a gio.File for many things but I can not create one for a directory path and to enumerate it's contents. I need to know how to get the gio.File and enumerate its children asyncronously. What I'm doing wrong.
My code is:
class HelloWorld : ApplicationWindow
{
private Button button;
private gio.File.File myfile;
private GFile * file;
this(Application application)
{
super(application);
setTitle("GtkD");
setBorderWidth(10);
Box vbox = new Box(Orientation.VERTICAL, 0);
vbox.add (new Label("Presione para leer el File"));
button = new Button("Leer Archivo");
vbox.add(button);
button.addOnClicked(delegate void(Button btn) {
//GFile * file;
size_t bytesRead;
//string filenameFromUtf8(string utf8string, ptrdiff_t len, out size_t bytesRead)
string dirPath = CharacterSet.filenameFromUtf8("D:\\Willy", "D:\\Willy".length, bytesRead);
writeln(dirPath);
file = g_file_new_for_path(dirPath.ptr);
myfile = new gio.File.File(file);
writeln("despues de new gio.File.File(file);");
//myfile.enumerateChildrenAsync(string attributes, GFileQueryInfoFlags flags, int ioPriority, Cancellable cancellable, GAsyncReadyCallback callback, void* userData);
//"standard::*", FileQueryInfoFlags.NOFOLLOW_SYMLINKS, Priority.DEFAULT, null
myfile.enumerateChildrenAsync("standard::*",
GFileQueryInfoFlags.NOFOLLOW_SYMLINKS, GPriority.DEFAULT, null,
(&this.enumChildrenCallBack).funcptr, cast(void*)0);
writeln("despues de myfile.enumerateChildrenAsync");
});
add (vbox);
showAll();
}
extern (C) void enumChildrenCallBack(GObject* source, GAsyncResult* res, void* userData)
{
writeln("enumChildrenCallBack");
gio.File.File file = new gio.File.File(cast(GFile*)source);
writeln("despues de new gio.File.File(cast(GFile*)source);");
Task task = new Task(cast(GTask*)res);
writeln("despues de new Task(cast(GTask*)res);");
try {
FileEnumerator enumerator = file.enumerateChildrenFinish (task);
FileInfo info;
while ((info = enumerator.nextFile(null)) !is null) {
writefln ("%s\n", info.getName ());
}
} catch (GException e) {
writefln("Error: ");
}
}
}
Thanks.