From 2d8853461e72f5776fad783c5f76caa04ac855e7 Mon Sep 17 00:00:00 2001 From: Jeroen Zwartepoorte Date: Tue, 21 Dec 2004 12:52:49 +0000 Subject: [PATCH] 2004-12-21 Jeroen Zwartepoorte * gnomevfs/Async.cs: * gnomevfs/Directory.cs: * gnomevfs/Sync.cs: * gnomevfs/Vfs.cs: Make the constructors private so they don't show up in monodoc (these classes aren't meant to be instantiated). svn path=/trunk/gtk-sharp/; revision=38025 --- ChangeLog | 8 ++ doc/ChangeLog | 5 + doc/en/Gnome.Vfs.xml | 16 +++ doc/en/Gnome.Vfs/Async.xml | 181 ++++++++++++++++++++++----------- doc/en/Gnome.Vfs/Directory.xml | 13 +-- doc/en/Gnome.Vfs/Sync.xml | 13 +-- doc/en/Gnome.Vfs/Vfs.xml | 13 +-- gnomevfs/Async.cs | 2 + gnomevfs/Directory.cs | 2 + gnomevfs/Sync.cs | 2 + gnomevfs/Vfs.cs | 2 + 11 files changed, 164 insertions(+), 93 deletions(-) create mode 100644 doc/en/Gnome.Vfs.xml diff --git a/ChangeLog b/ChangeLog index e481f567a..2a7732fcb 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +2004-12-21 Jeroen Zwartepoorte + + * gnomevfs/Async.cs: + * gnomevfs/Directory.cs: + * gnomevfs/Sync.cs: + * gnomevfs/Vfs.cs: Make the constructors private so they don't show up + in monodoc (these classes aren't meant to be instantiated). + 2004-12-21 Jeroen Zwartepoorte * gnomevfs/Gnomevfs.metadata: Hide the auto-generated ModuleCallback diff --git a/doc/ChangeLog b/doc/ChangeLog index 3a11077ad..346fde62f 100644 --- a/doc/ChangeLog +++ b/doc/ChangeLog @@ -1,3 +1,8 @@ +2004-12-21 Jeroen Zwartepoorte + + * en/Gnome.Vfs.xml: + * en/Gnome.Vfs/*.xml: Start documenting Gnome.Vfs. + 2004-12-21 Jeroen Zwartepoorte * en/Gnome.Vfs/*.xml : updater run for recent changes. Remove obsolete diff --git a/doc/en/Gnome.Vfs.xml b/doc/en/Gnome.Vfs.xml new file mode 100644 index 000000000..f25b50591 --- /dev/null +++ b/doc/en/Gnome.Vfs.xml @@ -0,0 +1,16 @@ + + + Library for dealing with various virtual file systems. + + + GnomeVFS is a filesystem abstraction library allowing applications plugable transparent access to a variety of "real" filesystems, from WebDAV to digital cameras, to the local filesystem. It also contains a number of other convenient file utilities such as a comphrehensive MIME database / Application registry, and a copy engine. Use of GnomeVFS ensures that an application or component will be usable by Nautilus or other GnomeVFS applications for handling the display of data from various URIs, as well. + + + From a user's perspective GnomeVFS enabled applications provide consistent access to their data, whether it be stored on remote servers or on their local harddisk, or even a peripheral device such as a Rio or a digital camera. Rather than having to work around the distinction between storage you can work off of and storage you can only "download" from or "upload" to, GnomeVFS allows users to store their documents and data wherever it is most convenient. + + + Besides providing transparent access to data methods that you might otherwise have to implement, GnomeVFS provides a number of convenience libraries for processing URIs, detecting the MIME type of files, and even figuring out which applications or components to launch to view a file or what icon to use. Writing a GnomeVFS module may also be an appropriate solution to some data access problems as it allows the developer to implement a relatively small number of functions to gain general filesystem semantics (and of course, writing a GnomeVFS module benefits other applications too!). + + + + diff --git a/doc/en/Gnome.Vfs/Async.xml b/doc/en/Gnome.Vfs/Async.xml index c59936f12..2882303a5 100644 --- a/doc/en/Gnome.Vfs/Async.xml +++ b/doc/en/Gnome.Vfs/Async.xml @@ -9,8 +9,76 @@ Gtk# is thread aware, but not thread safe; See the Gtk# Thread Programming for details. - To be added - To be added + Asynchronous File Operations; POSIX-style file operations that run outside your main loop. + + + public class TestAsync { + private static MainLoop loop; + private static Handle handle; + + static void Main (string[] args) + { + if (args.Length != 1) { + Console.WriteLine ("Usage: TestAsync <uri>"); + return; + } + + Gnome.Vfs.Vfs.Initialize (); + + Gnome.Vfs.Uri uri = new Gnome.Vfs.Uri (args[0]); + handle = Async.Open (uri, OpenMode.Read, + (int)Async.Priority.Default, + new Gnome.Vfs.AsyncCallback (OnOpen)); + + loop = new MainLoop (); + loop.Run (); + + Gnome.Vfs.Vfs.Shutdown (); + } + + + private static void OnOpen (Handle handle, Result result) + { + Console.WriteLine ("Uri opened: {0}", result); + if (result != Result.Ok) { + loop.Quit (); + return; + } + + byte[] buffer = new byte[1024]; + Async.Read (handle, out buffer[0], (uint)buffer.Length, + new AsyncReadCallback (OnRead)); + } + + private static void OnRead (Handle handle, Result result, byte[] buffer, + ulong bytes_requested, ulong bytes_read) + { + Console.WriteLine ("Read: {0}", result); + if (result != Result.Ok && result != Result.ErrorEof) { + loop.Quit (); + return; + } + + UTF8Encoding utf8 = new UTF8Encoding (); + Console.WriteLine ("read ({0} bytes) : '{1}'", bytes_read, + utf8.GetString (buffer, 0, (int)bytes_read)); + + if (bytes_read != 0) + Async.Read (handle, out buffer[0], (uint)buffer.Length, + new AsyncReadCallback (OnRead)); + else + Async.Close (handle, new Gnome.Vfs.AsyncCallback (OnClose)); + } + + private static void OnClose (Handle handle, Result result) + { + Console.WriteLine ("Close: {0}", result); + loop.Quit (); + } + } + + + The members of this class are all static methods and use the class to reference asynchronous operations in progress. System.Object @@ -28,8 +96,9 @@ - To be added - a + Cancel an asynchronous operation and close all its callbacks. Its possible to still receive another call or two on the callback. + + of the async operation to be cancelled To be added @@ -44,9 +113,9 @@ - To be added - a - a + Close a handle opened with . When the close has completed, will be called with the of the operation. + a to close + a to be called when the operation is complete To be added @@ -65,13 +134,13 @@ - To be added - a - a - a - a - a - a + Create a file at uri according to mode , with permissions . When the create has been completed will be called with the . + the URI to create a file at. + mode to leave the file opened in after creation (or to leave the file closed after creation). + Whether the file should be created in "exclusive" mode: i.e. if this flag is nonzero, operation will fail if a file with the same name already exists. + Bitmap representing the permissions for the newly created file (Unix style). + a value from to (normally should be ) indicating the priority to assign this job in allocating threads from the thread pool. + a to be called when the operation is complete. a To be added @@ -91,13 +160,13 @@ - To be added - a - a - a - a - a - a + Create a file at according to mode , with permissions . When the create has been completed will be called with the . + the to create a file at. + mode to leave the file opened in after creation (or to leave the file closed after creation). + Whether the file should be created in "exclusive" mode: i.e. if this flag is nonzero, operation will fail if a file with the same name already exists. + Bitmap representing the permissions for the newly created file (Unix style). + a value from to (normally should be ) indicating the priority to assign this job in allocating threads from the thread pool. + a to be called when the operation is complete. a To be added @@ -115,11 +184,13 @@ - To be added - a - a - a - a + Open uri according to mode . Once the file has been successfully opened, will be called with the . + + of the URI to open. + + . + a value from to (normally should be ) indicating the priority to assign this job in allocating threads from the thread pool. + a to be called when the operation is complete. a To be added @@ -137,11 +208,13 @@ - To be added - a - a - a - a + Open according to mode . Once the file has been successfully opened, will be called with the . + + to open. + + . + a value from to (normally should be ) indicating the priority to assign this job in allocating threads from the thread pool. + a to be called when the operation is complete. a To be added @@ -159,11 +232,12 @@ - To be added - a - a - a - a + Read number of bytes from the file pointed to by into byte array buffer. When the operation is complete, will be called with the of the operation. + + for the file to be read. + allocated array of to read into. Needs to be passed as "out buffer[0]". + number of bytes to read. + a to be called when the operation is complete. To be added @@ -180,11 +254,13 @@ - To be added - a - a - a - a + Set the current position for reading/writing through . When the operation is complete, will be called with the of the operation. + + for which the current position must be changed. + + value representing the starting position. + number of bytes to skip from the position specified by (a positive value means to move forward; a negative one to move backwards). + a to be called when the operation is complete. To be added @@ -201,22 +277,13 @@ - To be added - a - a - a - a - To be added - - - - - Constructor - - - - To be added - a + Write number of bytes from buffer byte array into the file pointed to be . When the operation is complete, will be called with the of the operation. + + for the file to be written. + + array containing data to be written. Needs to be passed as "out buffer[0]". + number of bytes to write. + a to be called when the operation is complete. To be added diff --git a/doc/en/Gnome.Vfs/Directory.xml b/doc/en/Gnome.Vfs/Directory.xml index abeec7d1a..43ddee139 100644 --- a/doc/en/Gnome.Vfs/Directory.xml +++ b/doc/en/Gnome.Vfs/Directory.xml @@ -200,16 +200,5 @@ To be added - - - Constructor - - - - To be added - a - To be added - - - \ No newline at end of file + diff --git a/doc/en/Gnome.Vfs/Sync.xml b/doc/en/Gnome.Vfs/Sync.xml index 339a4f5ab..d681209d8 100644 --- a/doc/en/Gnome.Vfs/Sync.xml +++ b/doc/en/Gnome.Vfs/Sync.xml @@ -252,16 +252,5 @@ To be added - - - Constructor - - - - To be added - a - To be added - - - \ No newline at end of file + diff --git a/doc/en/Gnome.Vfs/Vfs.xml b/doc/en/Gnome.Vfs/Vfs.xml index d0aa9f3ac..f41d0e439 100644 --- a/doc/en/Gnome.Vfs/Vfs.xml +++ b/doc/en/Gnome.Vfs/Vfs.xml @@ -213,17 +213,6 @@ To be added - - - Constructor - - - - To be added - a - To be added - - Property @@ -238,4 +227,4 @@ - \ No newline at end of file + diff --git a/gnomevfs/Async.cs b/gnomevfs/Async.cs index 5e5624afd..1b151b47f 100644 --- a/gnomevfs/Async.cs +++ b/gnomevfs/Async.cs @@ -29,6 +29,8 @@ namespace Gnome.Vfs { Default = 0, Max = 10 } + + private Async () {} [DllImport ("gnomevfs-2")] private static extern void gnome_vfs_async_cancel (IntPtr handle); diff --git a/gnomevfs/Directory.cs b/gnomevfs/Directory.cs index 147d25e16..42a80ba15 100644 --- a/gnomevfs/Directory.cs +++ b/gnomevfs/Directory.cs @@ -24,6 +24,8 @@ using System.Runtime.InteropServices; namespace Gnome.Vfs { public class Directory { + private Directory () {} + public static FileInfo[] GetEntries (Uri uri) { return GetEntries (uri.ToString ()); diff --git a/gnomevfs/Sync.cs b/gnomevfs/Sync.cs index 4db90c2f7..945181351 100644 --- a/gnomevfs/Sync.cs +++ b/gnomevfs/Sync.cs @@ -24,6 +24,8 @@ using System.Runtime.InteropServices; namespace Gnome.Vfs { public class Sync { + private Sync () {} + [DllImport ("gnomevfs-2")] private static extern Result gnome_vfs_close (IntPtr handle); diff --git a/gnomevfs/Vfs.cs b/gnomevfs/Vfs.cs index 33811cfdd..7f5d1ef91 100644 --- a/gnomevfs/Vfs.cs +++ b/gnomevfs/Vfs.cs @@ -24,6 +24,8 @@ using System.Runtime.InteropServices; namespace Gnome.Vfs { public class Vfs { + private Vfs () {} + [DllImport ("gnomevfs-2")] static extern bool gnome_vfs_init ();