GtkSharp/sample/gnomevfs/TestDirectory.cs
Jeroen Zwartepoorte 55aed28266 2004-11-02 Jeroen Zwartepoorte <jeroen@xs4all.nl>
* gnomevfs/AsyncDirectoryLoadCallback.cs:
	* gnomevfs/AsyncDirectoryLoadCallbackNative.cs:
	* gnomevfs/Directory.cs: Implement asynchronous directory loading.
	* gnomevfs/FileInfo.cs: Clear the FileInfoNative struct in the
	destructor.
	* gnomevfs/Makefile.am: Add new callback files.
	* sample/gnomevfs/TestDirectory.cs: Add async test.

svn path=/trunk/gtk-sharp/; revision=35571
2004-11-02 19:17:05 +00:00

53 lines
1.2 KiB
C#

using GLib;
using Gnome.Vfs;
using System;
using System.Text;
namespace Test.Gnome.Vfs {
public class TestInfo {
private static MainLoop loop;
static void Main (string[] args)
{
if (args.Length != 1) {
Console.WriteLine ("Usage: TestDirectory <uri>");
return;
}
Gnome.Vfs.Vfs.Initialize ();
FileInfo[] entries = Gnome.Vfs.Directory.GetEntries (args[0]);
Console.WriteLine ("Directory {0} contains {1} entries:", args[0], entries.Length);
foreach (FileInfo info in entries) {
//Console.WriteLine (info.Name);
}
Gnome.Vfs.Directory.GetEntries (args[0], FileInfoOptions.Default,
20, (int)Gnome.Vfs.Async.Priority.Default,
new AsyncDirectoryLoadCallback (OnDirectoryLoad));
loop = new MainLoop ();
loop.Run ();
Gnome.Vfs.Vfs.Shutdown ();
}
private static void OnDirectoryLoad (Result result, FileInfo[] entries, uint entries_read)
{
Console.WriteLine ("DirectoryLoad: {0}", result);
if (result != Result.Ok && result != Result.ErrorEof) {
loop.Quit ();
return;
}
Console.WriteLine ("read {0} entries", entries_read);
foreach (FileInfo info in entries) {
//Console.WriteLine (info.Name);
}
if (result == Result.ErrorEof)
loop.Quit ();
}
}
}