mirror of
https://github.com/Ryujinx/GtkSharp.git
synced 2024-12-24 00:55:29 +00:00
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
This commit is contained in:
parent
eb4abd9536
commit
55aed28266
10
ChangeLog
10
ChangeLog
|
@ -1,3 +1,13 @@
|
|||
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.
|
||||
|
||||
2004-11-01 Jeroen Zwartepoorte <jeroen@xs4all.nl>
|
||||
|
||||
* gnomevfs/Directory.cs: New Create and Delete methods. Free the
|
||||
|
|
14
gnomevfs/AsyncDirectoryLoadCallback.cs
Normal file
14
gnomevfs/AsyncDirectoryLoadCallback.cs
Normal file
|
@ -0,0 +1,14 @@
|
|||
//
|
||||
// VfsAsyncDirectoryLoadCallback.cs: GnomeVFSAsyncDirectoryLoadCallback delegate.
|
||||
//
|
||||
// Author:
|
||||
// Jeroen Zwartepoorte <jeroen@xs4all.nl>
|
||||
//
|
||||
// (C) Copyright Jeroen Zwartepoorte 2004
|
||||
//
|
||||
|
||||
using System;
|
||||
|
||||
namespace Gnome.Vfs {
|
||||
public delegate void AsyncDirectoryLoadCallback (Result result, FileInfo[] infos, uint entries_read);
|
||||
}
|
37
gnomevfs/AsyncDirectoryLoadCallbackNative.cs
Normal file
37
gnomevfs/AsyncDirectoryLoadCallbackNative.cs
Normal file
|
@ -0,0 +1,37 @@
|
|||
//
|
||||
// VfsAsyncDirectoryLoadCallbackNative.cs: Utility class for accessing gnome-vfs methods.
|
||||
//
|
||||
// Author:
|
||||
// Jeroen Zwartepoorte <jeroen@xs4all.nl>
|
||||
//
|
||||
// (C) Copyright Jeroen Zwartepoorte 2004
|
||||
//
|
||||
|
||||
using System;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace Gnome.Vfs {
|
||||
internal delegate void AsyncDirectoryLoadCallbackNative (IntPtr handle, Result result, IntPtr list, uint entries_read, IntPtr data);
|
||||
|
||||
internal class AsyncDirectoryLoadCallbackWrapper : GLib.DelegateWrapper {
|
||||
|
||||
public void NativeCallback (IntPtr handle, Result result, IntPtr list, uint entries_read, IntPtr data)
|
||||
{
|
||||
GLib.List infos = new GLib.List (list, typeof (FileInfo.FileInfoNative));
|
||||
FileInfo[] entries = new FileInfo [infos.Count];
|
||||
for (int i = 0; i < infos.Count; i++)
|
||||
entries[i] = new FileInfo ((FileInfo.FileInfoNative) infos [i]);
|
||||
|
||||
_managed (result, entries, entries_read);
|
||||
}
|
||||
|
||||
internal AsyncDirectoryLoadCallbackNative NativeDelegate;
|
||||
protected AsyncDirectoryLoadCallback _managed;
|
||||
|
||||
public AsyncDirectoryLoadCallbackWrapper (AsyncDirectoryLoadCallback managed, object o) : base (o)
|
||||
{
|
||||
NativeDelegate = new AsyncDirectoryLoadCallbackNative (NativeCallback);
|
||||
_managed = managed;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -49,6 +49,19 @@ namespace Gnome.Vfs {
|
|||
return entries;
|
||||
}
|
||||
|
||||
[DllImport ("gnomevfs-2")]
|
||||
private static extern void gnome_vfs_async_load_directory (out IntPtr handle, string uri, FileInfoOptions options, uint items_per_notification, int priority, AsyncDirectoryLoadCallbackNative native, IntPtr data);
|
||||
|
||||
public static void GetEntries (string uri, FileInfoOptions options,
|
||||
uint itemsPerNotification, int priority,
|
||||
AsyncDirectoryLoadCallback callback)
|
||||
{
|
||||
IntPtr handle = IntPtr.Zero;
|
||||
AsyncDirectoryLoadCallbackWrapper wrapper = new AsyncDirectoryLoadCallbackWrapper (callback, null);
|
||||
gnome_vfs_async_load_directory (out handle, uri, options, itemsPerNotification,
|
||||
priority, wrapper.NativeDelegate, IntPtr.Zero);
|
||||
}
|
||||
|
||||
[DllImport ("gnomevfs-2")]
|
||||
private static extern Result gnome_vfs_make_directory (string uri, uint perm);
|
||||
|
||||
|
|
|
@ -43,10 +43,10 @@ namespace Gnome.Vfs {
|
|||
private FileInfoNative info;
|
||||
|
||||
[DllImport ("gnomevfs-2")]
|
||||
extern static FileInfoNative gnome_vfs_file_info_new ();
|
||||
private static extern FileInfoNative gnome_vfs_file_info_new ();
|
||||
|
||||
[DllImport ("gnomevfs-2")]
|
||||
extern static void gnome_vfs_file_info_copy (ref FileInfoNative dest, ref FileInfoNative src);
|
||||
private static extern void gnome_vfs_file_info_copy (ref FileInfoNative dest, ref FileInfoNative src);
|
||||
|
||||
[DllImport ("gnomevfs-2")]
|
||||
private static extern Result gnome_vfs_get_file_info_uri (IntPtr uri, ref FileInfoNative info, FileInfoOptions options);
|
||||
|
@ -70,6 +70,14 @@ namespace Gnome.Vfs {
|
|||
Vfs.ThrowException (uri, result);
|
||||
}
|
||||
|
||||
[DllImport ("gnomevfs-2")]
|
||||
private static extern void gnome_vfs_file_info_clear (ref FileInfoNative info);
|
||||
|
||||
~FileInfo ()
|
||||
{
|
||||
gnome_vfs_file_info_clear (ref info);
|
||||
}
|
||||
|
||||
public string Name {
|
||||
get {
|
||||
if (info.name != IntPtr.Zero)
|
||||
|
|
|
@ -20,6 +20,8 @@ sources = \
|
|||
Async.cs \
|
||||
AsyncCallback.cs \
|
||||
AsyncCallbackNative.cs \
|
||||
AsyncDirectoryLoadCallback.cs \
|
||||
AsyncDirectoryLoadCallbackNative.cs \
|
||||
AsyncReadCallback.cs \
|
||||
AsyncReadCallbackNative.cs \
|
||||
AsyncWriteCallback.cs \
|
||||
|
|
|
@ -1,9 +1,12 @@
|
|||
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) {
|
||||
|
@ -15,10 +18,36 @@ namespace Test.Gnome.Vfs {
|
|||
|
||||
FileInfo[] entries = Gnome.Vfs.Directory.GetEntries (args[0]);
|
||||
|
||||
foreach (FileInfo info in entries)
|
||||
Console.WriteLine (info.ToString ());
|
||||
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 ();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue