From 33dbe7485e3063e9716c2fd55a18a5ac10cf9a2d Mon Sep 17 00:00:00 2001 From: Jeroen Zwartepoorte Date: Mon, 1 Nov 2004 20:03:30 +0000 Subject: [PATCH] 2004-11-01 Jeroen Zwartepoorte * gnomevfs/Directory.cs: Bind gnome_vfs_directory_list_load as a static FileInfo[] GetEntries (uri) method. * gnomevfs/FileInfo.cs: Add internal FileInfoNative constructor to create a FileInfo class based on an existing FileInfoNative struct. * gnomevfs/Makefile.am: * sample/gnomevfs/Makefile.am: * sample/gnomevfs/TestDirectory.cs: svn path=/trunk/gtk-sharp/; revision=35532 --- ChangeLog | 10 +++++++ gnomevfs/Directory.cs | 48 ++++++++++++++++++++++++++++++++ gnomevfs/FileInfo.cs | 6 ++++ gnomevfs/Makefile.am | 19 +++++++++---- sample/gnomevfs/Makefile.am | 5 ++++ sample/gnomevfs/TestDirectory.cs | 24 ++++++++++++++++ 6 files changed, 106 insertions(+), 6 deletions(-) create mode 100644 gnomevfs/Directory.cs create mode 100644 sample/gnomevfs/TestDirectory.cs diff --git a/ChangeLog b/ChangeLog index 24c333cfc..5d1826203 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,13 @@ +2004-11-01 Jeroen Zwartepoorte + + * gnomevfs/Directory.cs: Bind gnome_vfs_directory_list_load as a static + FileInfo[] GetEntries (uri) method. + * gnomevfs/FileInfo.cs: Add internal FileInfoNative constructor to + create a FileInfo class based on an existing FileInfoNative struct. + * gnomevfs/Makefile.am: + * sample/gnomevfs/Makefile.am: + * sample/gnomevfs/TestDirectory.cs: + 2004-10-30 Todd Berman * gtk/ComboBox.custom: diff --git a/gnomevfs/Directory.cs b/gnomevfs/Directory.cs new file mode 100644 index 000000000..3540a0eb2 --- /dev/null +++ b/gnomevfs/Directory.cs @@ -0,0 +1,48 @@ +// +// Directory.cs: Bindings for gnome-vfs directory functions calls. +// +// Author: +// Jeroen Zwartepoorte +// +// (C) Copyright Jeroen Zwartepoorte 2004 +// + +using System; +using System.IO; +using System.Runtime.InteropServices; + +namespace Gnome.Vfs { + public class Directory { + [DllImport ("gnomevfs-2")] + private static extern Result gnome_vfs_directory_list_load (out IntPtr list, string uri, FileInfoOptions options); + + public static FileInfo[] GetEntries (Uri uri) + { + return GetEntries (uri.ToString ()); + } + + public static FileInfo[] GetEntries (Uri uri, FileInfoOptions options) + { + return GetEntries (uri.ToString (), options); + } + + public static FileInfo[] GetEntries (string text_uri) + { + return GetEntries (text_uri, FileInfoOptions.Default); + } + + public static FileInfo[] GetEntries (string text_uri, FileInfoOptions options) + { + IntPtr raw_ret; + Result result = gnome_vfs_directory_list_load (out raw_ret, text_uri, options); + Vfs.ThrowException (text_uri, result); + + GLib.List list = new GLib.List (raw_ret, typeof (FileInfo.FileInfoNative)); + FileInfo[] entries = new FileInfo [list.Count]; + for (int i = 0; i < list.Count; i++) + entries[i] = new FileInfo ((FileInfo.FileInfoNative) list [i]); + + return entries; + } + } +} diff --git a/gnomevfs/FileInfo.cs b/gnomevfs/FileInfo.cs index 816b49fb5..368d15aed 100644 --- a/gnomevfs/FileInfo.cs +++ b/gnomevfs/FileInfo.cs @@ -53,6 +53,12 @@ namespace Gnome.Vfs { [DllImport ("gnomevfs-2")] extern static void gnome_vfs_file_info_unref (ref FileInfoNative info); + internal FileInfo (FileInfoNative info) + { + this.info = info; + uri = null; + } + public FileInfo (string uri) : this (uri, FileInfoOptions.Default) {} public FileInfo (string uri, FileInfoOptions options) : this (new Uri (uri), options) {} diff --git a/gnomevfs/Makefile.am b/gnomevfs/Makefile.am index b0c59710a..1e245f2d4 100644 --- a/gnomevfs/Makefile.am +++ b/gnomevfs/Makefile.am @@ -1,5 +1,15 @@ SUBDIRS = . +if ENABLE_GNOMEVFS +TARGET = $(ASSEMBLY) $(ASSEMBLY).config +APIS = $(API) $(ADDITIONAL_API) +pkgconfigdir = $(libdir)/pkgconfig +pkgconfig_DATA = gnome-vfs-sharp-2.0.pc +else +TARGET = +APIS = +endif + API = gnomevfs-api.xml ADDITIONAL_API = gnomevfs-symbols.xml RAW_API = gnomevfs-api.raw @@ -8,11 +18,10 @@ METADATA = Gnomevfs.metadata ASSEMBLY_NAME = gnome-vfs-sharp references = /r:../glib/glib-sharp.dll -TARGET = $(ASSEMBLY) ASSEMBLY = $(ASSEMBLY_NAME).dll gapidir = $(datadir)/gapi-2.0 -noinst_DATA = $(ASSEMBLY) $(ASSEMBLY).config -gapi_DATA = $(API) $(ADDITIONAL_API) +noinst_DATA = $(TARGET) +gapi_DATA = $(APIS) CLEANFILES = $(ASSEMBLY) generated-stamp generated/*.cs $(API) glue/generated.c gtk-sharp.snk DISTCLEANFILES = $(ASSEMBLY).config AssemblyInfo.cs gnome-vfs-sharp.pc @@ -24,6 +33,7 @@ sources = \ AsyncReadCallbackNative.cs \ AsyncWriteCallback.cs \ AsyncWriteCallbackNative.cs \ + Directory.cs \ FileInfo.cs \ Handle.cs \ MimeType.cs \ @@ -71,9 +81,6 @@ gtk-sharp.snk: $(top_srcdir)/gtk-sharp.snk $(ASSEMBLY): $(build_sources) generated-stamp gtk-sharp.snk $(CSC) /unsafe /out:$(ASSEMBLY) /target:library $(references) $(build_sources) $(GENERATED_SOURCES) -pkgconfigdir = $(libdir)/pkgconfig -pkgconfig_DATA = gnome-vfs-sharp-2.0.pc - install-data-local: @if test -n '$(TARGET)'; then \ echo "$(GACUTIL) /i $(ASSEMBLY) /f $(GACUTIL_FLAGS)"; \ diff --git a/sample/gnomevfs/Makefile.am b/sample/gnomevfs/Makefile.am index e00bdf34a..eb0a77d99 100644 --- a/sample/gnomevfs/Makefile.am +++ b/sample/gnomevfs/Makefile.am @@ -1,6 +1,7 @@ TARGETS = \ TestAsync.exe \ TestAsyncStream.exe \ + TestDirectory.exe \ TestInfo.exe \ TestMime.exe \ TestMonitor.exe \ @@ -21,6 +22,7 @@ CLEANFILES = $(TARGETS) EXTRA_DIST = \ TestAsync.cs \ TestAsyncStream.cs \ + TestDirectory.cs \ TestInfo.cs \ TestMime.cs \ TestMonitor.cs \ @@ -38,6 +40,9 @@ TestAsync.exe: $(srcdir)/TestAsync.cs $(assemblies) TestAsyncStream.exe: $(srcdir)/TestAsyncStream.cs $(assemblies) $(CSC) /out:TestAsyncStream.exe $(references) $(srcdir)/TestAsyncStream.cs +TestDirectory.exe: $(srcdir)/TestDirectory.cs $(assemblies) + $(CSC) /out:TestDirectory.exe $(references) $(srcdir)/TestDirectory.cs + TestInfo.exe: $(srcdir)/TestInfo.cs $(assemblies) $(CSC) /out:TestInfo.exe $(references) $(srcdir)/TestInfo.cs diff --git a/sample/gnomevfs/TestDirectory.cs b/sample/gnomevfs/TestDirectory.cs new file mode 100644 index 000000000..257376c4d --- /dev/null +++ b/sample/gnomevfs/TestDirectory.cs @@ -0,0 +1,24 @@ +using Gnome.Vfs; +using System; +using System.Text; + +namespace Test.Gnome.Vfs { + public class TestInfo { + static void Main (string[] args) + { + if (args.Length != 1) { + Console.WriteLine ("Usage: TestDirectory "); + return; + } + + Gnome.Vfs.Vfs.Initialize (); + + FileInfo[] entries = Gnome.Vfs.Directory.GetEntries (args[0]); + + foreach (FileInfo info in entries) + Console.WriteLine (info.ToString ()); + + Gnome.Vfs.Vfs.Shutdown (); + } + } +}