mirror of
https://github.com/Ryujinx/GtkSharp.git
synced 2025-01-11 13:55:40 +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>
|
2004-11-01 Jeroen Zwartepoorte <jeroen@xs4all.nl>
|
||||||
|
|
||||||
* gnomevfs/Directory.cs: New Create and Delete methods. Free the
|
* 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;
|
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")]
|
[DllImport ("gnomevfs-2")]
|
||||||
private static extern Result gnome_vfs_make_directory (string uri, uint perm);
|
private static extern Result gnome_vfs_make_directory (string uri, uint perm);
|
||||||
|
|
||||||
|
|
|
@ -43,10 +43,10 @@ namespace Gnome.Vfs {
|
||||||
private FileInfoNative info;
|
private FileInfoNative info;
|
||||||
|
|
||||||
[DllImport ("gnomevfs-2")]
|
[DllImport ("gnomevfs-2")]
|
||||||
extern static FileInfoNative gnome_vfs_file_info_new ();
|
private static extern FileInfoNative gnome_vfs_file_info_new ();
|
||||||
|
|
||||||
[DllImport ("gnomevfs-2")]
|
[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")]
|
[DllImport ("gnomevfs-2")]
|
||||||
private static extern Result gnome_vfs_get_file_info_uri (IntPtr uri, ref FileInfoNative info, FileInfoOptions options);
|
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);
|
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 {
|
public string Name {
|
||||||
get {
|
get {
|
||||||
if (info.name != IntPtr.Zero)
|
if (info.name != IntPtr.Zero)
|
||||||
|
|
|
@ -16,25 +16,27 @@ gapi_DATA = $(API) $(ADDITIONAL_API)
|
||||||
CLEANFILES = $(ASSEMBLY) generated-stamp generated/*.cs $(API) glue/generated.c gtk-sharp.snk
|
CLEANFILES = $(ASSEMBLY) generated-stamp generated/*.cs $(API) glue/generated.c gtk-sharp.snk
|
||||||
DISTCLEANFILES = $(ASSEMBLY).config AssemblyInfo.cs gnome-vfs-sharp.pc
|
DISTCLEANFILES = $(ASSEMBLY).config AssemblyInfo.cs gnome-vfs-sharp.pc
|
||||||
|
|
||||||
sources = \
|
sources = \
|
||||||
Async.cs \
|
Async.cs \
|
||||||
AsyncCallback.cs \
|
AsyncCallback.cs \
|
||||||
AsyncCallbackNative.cs \
|
AsyncCallbackNative.cs \
|
||||||
AsyncReadCallback.cs \
|
AsyncDirectoryLoadCallback.cs \
|
||||||
AsyncReadCallbackNative.cs \
|
AsyncDirectoryLoadCallbackNative.cs \
|
||||||
AsyncWriteCallback.cs \
|
AsyncReadCallback.cs \
|
||||||
AsyncWriteCallbackNative.cs \
|
AsyncReadCallbackNative.cs \
|
||||||
Directory.cs \
|
AsyncWriteCallback.cs \
|
||||||
FileInfo.cs \
|
AsyncWriteCallbackNative.cs \
|
||||||
Handle.cs \
|
Directory.cs \
|
||||||
MimeType.cs \
|
FileInfo.cs \
|
||||||
Monitor.cs \
|
Handle.cs \
|
||||||
Sync.cs \
|
MimeType.cs \
|
||||||
Vfs.cs \
|
Monitor.cs \
|
||||||
VfsStream.cs \
|
Sync.cs \
|
||||||
VfsStreamAsyncResult.cs \
|
Vfs.cs \
|
||||||
Xfer.cs \
|
VfsStream.cs \
|
||||||
XferProgressCallback.cs \
|
VfsStreamAsyncResult.cs \
|
||||||
|
Xfer.cs \
|
||||||
|
XferProgressCallback.cs \
|
||||||
XferProgressCallbackNative.cs
|
XferProgressCallbackNative.cs
|
||||||
|
|
||||||
build_sources = $(addprefix $(srcdir)/, $(sources)) AssemblyInfo.cs
|
build_sources = $(addprefix $(srcdir)/, $(sources)) AssemblyInfo.cs
|
||||||
|
|
|
@ -1,9 +1,12 @@
|
||||||
|
using GLib;
|
||||||
using Gnome.Vfs;
|
using Gnome.Vfs;
|
||||||
using System;
|
using System;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
|
|
||||||
namespace Test.Gnome.Vfs {
|
namespace Test.Gnome.Vfs {
|
||||||
public class TestInfo {
|
public class TestInfo {
|
||||||
|
private static MainLoop loop;
|
||||||
|
|
||||||
static void Main (string[] args)
|
static void Main (string[] args)
|
||||||
{
|
{
|
||||||
if (args.Length != 1) {
|
if (args.Length != 1) {
|
||||||
|
@ -15,10 +18,36 @@ namespace Test.Gnome.Vfs {
|
||||||
|
|
||||||
FileInfo[] entries = Gnome.Vfs.Directory.GetEntries (args[0]);
|
FileInfo[] entries = Gnome.Vfs.Directory.GetEntries (args[0]);
|
||||||
|
|
||||||
foreach (FileInfo info in entries)
|
Console.WriteLine ("Directory {0} contains {1} entries:", args[0], entries.Length);
|
||||||
Console.WriteLine (info.ToString ());
|
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 ();
|
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