diff --git a/sample/gnomevfs/Makefile.am b/sample/gnomevfs/Makefile.am deleted file mode 100644 index 83b7b727d..000000000 --- a/sample/gnomevfs/Makefile.am +++ /dev/null @@ -1,90 +0,0 @@ -if ENABLE_GNOMEVFS -TARGETS = \ - TestAsync.exe \ - TestAsyncStream.exe \ - TestCallback.exe \ - TestDirectory.exe \ - TestInfo.exe \ - TestMime.exe \ - TestMonitor.exe \ - TestSync.exe \ - TestSyncCreate.exe \ - TestSyncStream.exe \ - TestSyncWrite.exe \ - TestUnlink.exe \ - TestVolumes.exe - -if ENABLE_MONOGETOPTIONS -EXTRA_TARGETS = TestXfer.exe -else -EXTRA_TARGETS = -endif - -else -TARGETS = -EXTRA_TARGETS = -endif - -assemblies=../../glib/glib-sharp.dll ../../gnomevfs/gnome-vfs-sharp.dll -references = $(addprefix /r:, $(assemblies)) - -noinst_SCRIPTS = $(TARGETS) $(EXTRA_TARGETS) -CLEANFILES = $(TARGETS) $(EXTRA_TARGETS) - -EXTRA_DIST = \ - TestAsync.cs \ - TestAsyncStream.cs \ - TestCallback.cs \ - TestDirectory.cs \ - TestInfo.cs \ - TestMime.cs \ - TestMonitor.cs \ - TestSync.cs \ - TestSyncCreate.cs \ - TestSyncStream.cs \ - TestSyncWrite.cs \ - TestUnlink.cs \ - TestVolumes.cs \ - TestXfer.cs - -TestAsync.exe: $(srcdir)/TestAsync.cs $(assemblies) - $(CSC) /out:TestAsync.exe $(references) $(srcdir)/TestAsync.cs - -TestAsyncStream.exe: $(srcdir)/TestAsyncStream.cs $(assemblies) - $(CSC) /out:TestAsyncStream.exe $(references) $(srcdir)/TestAsyncStream.cs - -TestCallback.exe: $(srcdir)/TestCallback.cs $(assemblies) - $(CSC) /out:TestCallback.exe $(references) $(srcdir)/TestCallback.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 - -TestMime.exe: $(srcdir)/TestMime.cs $(assemblies) - $(CSC) /out:TestMime.exe $(references) $(srcdir)/TestMime.cs - -TestMonitor.exe: $(srcdir)/TestMonitor.cs $(assemblies) - $(CSC) /out:TestMonitor.exe $(references) $(srcdir)/TestMonitor.cs - -TestSyncStream.exe: $(srcdir)/TestSyncStream.cs $(assemblies) - $(CSC) /out:TestSyncStream.exe $(references) $(srcdir)/TestSyncStream.cs - -TestSync.exe: $(srcdir)/TestSync.cs $(assemblies) - $(CSC) /out:TestSync.exe $(references) $(srcdir)/TestSync.cs - -TestSyncCreate.exe: $(srcdir)/TestSyncCreate.cs $(assemblies) - $(CSC) /out:TestSyncCreate.exe $(references) $(srcdir)/TestSyncCreate.cs - -TestSyncWrite.exe: $(srcdir)/TestSyncWrite.cs $(assemblies) - $(CSC) /out:TestSyncWrite.exe $(references) $(srcdir)/TestSyncWrite.cs - -TestUnlink.exe: $(srcdir)/TestUnlink.cs $(assemblies) - $(CSC) /out:TestUnlink.exe $(references) $(srcdir)/TestUnlink.cs - -TestVolumes.exe: $(srcdir)/TestVolumes.cs $(assemblies) - $(CSC) /out:TestVolumes.exe $(references) $(srcdir)/TestVolumes.cs - -TestXfer.exe: $(srcdir)/TestXfer.cs $(assemblies) - $(CSC) /out:TestXfer.exe $(references) -r:Mono.GetOptions.dll $(srcdir)/TestXfer.cs diff --git a/sample/gnomevfs/TestAsync.cs b/sample/gnomevfs/TestAsync.cs deleted file mode 100644 index b3574fc06..000000000 --- a/sample/gnomevfs/TestAsync.cs +++ /dev/null @@ -1,72 +0,0 @@ -using GLib; -using Gnome.Vfs; -using System; -using System.Text; -using System.Threading; - -namespace TestGnomeVfs { - public class TestAsync { - private static MainLoop loop; - private static Handle handle; - - static void Main (string[] args) - { - if (args.Length != 1) { - Console.WriteLine ("Usage: TestAsync "); - 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 (); - } - } -} diff --git a/sample/gnomevfs/TestAsyncStream.cs b/sample/gnomevfs/TestAsyncStream.cs deleted file mode 100644 index e9f5147c9..000000000 --- a/sample/gnomevfs/TestAsyncStream.cs +++ /dev/null @@ -1,54 +0,0 @@ -using GLib; -using Gnome.Vfs; -using System; -using System.IO; -using System.Text; - -namespace TestGnomeVfs { - public class TestAsyncStream { - private static MainLoop loop; - private static byte[] buffer; - - static void Main (string[] args) - { - if (args.Length != 1) { - Console.WriteLine ("Usage: TestAsyncStream "); - return; - } - - Gnome.Vfs.Vfs.Initialize (); - - VfsStream stream = new VfsStream (args[0], FileMode.Open, true); - - UTF8Encoding utf8 = new UTF8Encoding (); - buffer = new byte[1024]; - int read; - while ((read = stream.Read (buffer, 0, buffer.Length)) != 0) { - Console.WriteLine ("read ({0} bytes) : '{1}'", - read, utf8.GetString (buffer, 0, read)); - } - - long offset = stream.Seek (0, SeekOrigin.Begin); - Console.WriteLine ("Offset after seek is {0}", offset); - - buffer = new byte[1024]; - IAsyncResult result = stream.BeginRead (buffer, 0, buffer.Length, - new System.AsyncCallback (OnReadComplete), - stream); - - loop = new MainLoop (); - loop.Run (); - - Gnome.Vfs.Vfs.Shutdown (); - } - - private static void OnReadComplete (IAsyncResult result) - { - VfsStreamAsyncResult asyncResult = result as VfsStreamAsyncResult; - Console.WriteLine ("Read completed: {0}, {1}", asyncResult.IsCompleted, asyncResult.NBytes); - UTF8Encoding utf8 = new UTF8Encoding (); - Console.WriteLine (utf8.GetString (buffer, 0, buffer.Length)); - loop.Quit (); - } - } -} diff --git a/sample/gnomevfs/TestCallback.cs b/sample/gnomevfs/TestCallback.cs deleted file mode 100644 index f8e8a7704..000000000 --- a/sample/gnomevfs/TestCallback.cs +++ /dev/null @@ -1,73 +0,0 @@ -using GLib; -using Gnome.Vfs; -using System; -using System.Text; - -namespace TestGnomeVfs { - public class TestCallback { - private static MainLoop loop; - - static void Main (string[] args) - { - if (args.Length != 1) { - Console.WriteLine ("Usage: TestCallback "); - return; - } - - Gnome.Vfs.Vfs.Initialize (); - - Gnome.Vfs.Uri uri = new Gnome.Vfs.Uri (args[0]); - Handle handle; - - // Test 1: Attempt to access a URI requiring authentication w/o a callback registered. - try { - handle = Sync.Open (uri, OpenMode.Read); - Sync.Close (handle); - Console.WriteLine ("Uri '{0}' doesn't require authentication", uri); - return; - } catch (VfsException ex) { - if (ex.Result != Result.ErrorAccessDenied) - throw ex; - } - - // Test 2: Attempt an open that requires authentication. - ModuleCallbackFullAuthentication cb = new ModuleCallbackFullAuthentication (); - cb.Callback += new ModuleCallbackHandler (OnAuthenticate); - cb.SetDefault (); - - handle = Sync.Open (uri, OpenMode.Read); - Sync.Close (handle); - - // Test 3: This call should not require any new authentication. - Console.WriteLine ("File info: \n{0}", uri.GetFileInfo ()); - - // Test 4: Attempt a call to the parent uri. - FileInfo[] entries = Directory.GetEntries (uri.Parent); - Console.WriteLine ("Directory '{0}' has {1} entries", uri.Parent, entries.Length); - - // Test 5: Pop the authentication callback and try again. - cb.Pop (); - try { - handle = Sync.Open (uri, OpenMode.Read); - } catch (VfsException ex) { - if (ex.Result != Result.ErrorAccessDenied) - throw ex; - } - - Gnome.Vfs.Vfs.Shutdown (); - } - - private static void OnAuthenticate (ModuleCallback cb) - { - ModuleCallbackFullAuthentication fcb = cb as ModuleCallbackFullAuthentication; - Console.Write ("Enter your username ({0}): ", fcb.Username); - string username = Console.ReadLine (); - Console.Write ("Enter your password : "); - string passwd = Console.ReadLine (); - - if (username.Length > 0) - fcb.Username = username; - fcb.Password = passwd; - } - } -} diff --git a/sample/gnomevfs/TestDirectory.cs b/sample/gnomevfs/TestDirectory.cs deleted file mode 100644 index 462115271..000000000 --- a/sample/gnomevfs/TestDirectory.cs +++ /dev/null @@ -1,53 +0,0 @@ -using GLib; -using Gnome.Vfs; -using System; -using System.Text; - -namespace TestGnomeVfs { - public class TestInfo { - private static MainLoop loop; - - 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]); - - 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 (); - } - } -} diff --git a/sample/gnomevfs/TestInfo.cs b/sample/gnomevfs/TestInfo.cs deleted file mode 100644 index 74b29d05e..000000000 --- a/sample/gnomevfs/TestInfo.cs +++ /dev/null @@ -1,27 +0,0 @@ -using Gnome.Vfs; -using System; -using System.Text; - -namespace TestGnomeVfs { - public class TestInfo { - static void Main (string[] args) - { - if (args.Length != 1) { - Console.WriteLine ("Usage: TestInfo "); - return; - } - - Gnome.Vfs.Vfs.Initialize (); - - Gnome.Vfs.Uri uri = new Gnome.Vfs.Uri (args[0]); - - FileInfoOptions options = FileInfoOptions.GetMimeType | - FileInfoOptions.FollowLinks | - FileInfoOptions.GetAccessRights; - FileInfo info = uri.GetFileInfo (options); - Console.WriteLine (info.ToString ()); - - Gnome.Vfs.Vfs.Shutdown (); - } - } -} diff --git a/sample/gnomevfs/TestMime.cs b/sample/gnomevfs/TestMime.cs deleted file mode 100644 index a36f07e4c..000000000 --- a/sample/gnomevfs/TestMime.cs +++ /dev/null @@ -1,25 +0,0 @@ -using Gnome.Vfs; -using System; -using System.Reflection; -using System.Runtime.CompilerServices; - -namespace TestGnomeVfs { - public class TestMime { - static void Main (string[] args) - { - if (args.Length != 1) { - Console.WriteLine ("Usage: TestSync "); - return; - } - - Gnome.Vfs.Vfs.Initialize (); - - Gnome.Vfs.Uri uri = new Gnome.Vfs.Uri (args[0]); - - MimeType mimetype = uri.MimeType; - Console.WriteLine ("Uri `{0}' looks like ", uri, mimetype.Name); - - Gnome.Vfs.Vfs.Shutdown (); - } - } -} diff --git a/sample/gnomevfs/TestMonitor.cs b/sample/gnomevfs/TestMonitor.cs deleted file mode 100644 index 2d7371c96..000000000 --- a/sample/gnomevfs/TestMonitor.cs +++ /dev/null @@ -1,51 +0,0 @@ -using GLib; -using Gnome.Vfs; -using System; -using System.Text; - -namespace TestGnomeVfs { - public class TestMonitor { - static void Main (string[] args) - { - if (args.Length != 1) { - Console.WriteLine ("Usage: TestMonitor "); - return; - } - - Gnome.Vfs.Vfs.Initialize (); - - Monitor monitor = new Monitor (); - monitor.Changed += OnChanged; - monitor.Deleted += OnDeleted; - monitor.Created += OnCreated; - monitor.MetadataChanged += OnMetadataChanged; - - monitor.Add (args[0], MonitorType.Directory); - monitor.Add ("/tmp", MonitorType.Directory); - - new MainLoop ().Run (); - - Gnome.Vfs.Vfs.Shutdown (); - } - - public static void OnChanged (string monitor, string uri) - { - Console.WriteLine ("Uri changed: {0}", uri); - } - - public static void OnDeleted (string monitor, string uri) - { - Console.WriteLine ("Uri deleted: {0}", uri); - } - - public static void OnCreated (string monitor, string uri) - { - Console.WriteLine ("Uri created: {0}", uri); - } - - public static void OnMetadataChanged (string monitor, string uri) - { - Console.WriteLine ("Uri metadata changed: {0}", uri); - } - } -} diff --git a/sample/gnomevfs/TestSync.cs b/sample/gnomevfs/TestSync.cs deleted file mode 100644 index ef5a6cef4..000000000 --- a/sample/gnomevfs/TestSync.cs +++ /dev/null @@ -1,44 +0,0 @@ -using Gnome.Vfs; -using System; -using System.Text; - -namespace TestGnomeVfs { - public class TestSync { - static void Main (string[] args) - { - if (args.Length != 1) { - Console.WriteLine ("Usage: TestSync "); - return; - } - - Gnome.Vfs.Vfs.Initialize (); - - Gnome.Vfs.Uri uri = new Gnome.Vfs.Uri (args[0]); - Handle handle = Sync.Open (uri, OpenMode.Read); - - UTF8Encoding utf8 = new UTF8Encoding (); - byte[] buffer = new byte[1024]; - Result result = Result.Ok; - while (result == Result.Ok) { - ulong bytesRead; - result = Sync.Read (handle, out buffer[0], - (ulong)buffer.Length, out bytesRead); - Console.WriteLine ("result read '{0}' = {1}", uri, result); - if (bytesRead == 0) - break; - Console.WriteLine ("read ({0} bytes) : '{1}'", - bytesRead, utf8.GetString (buffer, 0, (int)bytesRead)); - } - - string test; - result = Sync.FileControl (handle, "file:test", out test); - Console.WriteLine ("result filecontrol '{0}' = {1}", uri, result); - Console.WriteLine ("result file:test = {0}", test); - - result = Sync.Close (handle); - Console.WriteLine ("result close '{0}' = {1}", uri, result); - - Gnome.Vfs.Vfs.Shutdown (); - } - } -} diff --git a/sample/gnomevfs/TestSyncCreate.cs b/sample/gnomevfs/TestSyncCreate.cs deleted file mode 100644 index 7560fbcba..000000000 --- a/sample/gnomevfs/TestSyncCreate.cs +++ /dev/null @@ -1,47 +0,0 @@ -using Gnome.Vfs; -using System; -using System.Text; - -namespace TestGnomeVfs { - public class TestSyncCreate { - static void Main (string[] args) - { - if (args.Length != 1) { - Console.WriteLine ("Usage: TestSyncCreate "); - return; - } - - Gnome.Vfs.Vfs.Initialize (); - - Gnome.Vfs.Uri uri = new Gnome.Vfs.Uri (args[0]); - - FilePermissions perms = FilePermissions.UserRead | - FilePermissions.UserWrite | - FilePermissions.GroupRead | - FilePermissions.OtherRead; - Console.WriteLine (perms); - Handle handle = Sync.Create (uri, OpenMode.Write, false, perms); - - UTF8Encoding utf8 = new UTF8Encoding (); - Result result = Result.Ok; - Console.WriteLine ("Enter text and end with Ctrl-D"); - while (result == Result.Ok) { - string line = Console.ReadLine (); - if (line == null) - break; - byte[] buffer = utf8.GetBytes (line); - - ulong bytesWritten; - result = Sync.Write (handle, out buffer[0], - (ulong)buffer.Length, out bytesWritten); - Console.WriteLine ("result write '{0}' = {1}", uri, result); - Console.WriteLine ("{0} bytes written", bytesWritten); - } - - result = Sync.Close (handle); - Console.WriteLine ("result close '{0}' = {1}", uri, result); - - Gnome.Vfs.Vfs.Shutdown (); - } - } -} diff --git a/sample/gnomevfs/TestSyncStream.cs b/sample/gnomevfs/TestSyncStream.cs deleted file mode 100644 index ec4906ce6..000000000 --- a/sample/gnomevfs/TestSyncStream.cs +++ /dev/null @@ -1,36 +0,0 @@ -using GLib; -using Gnome.Vfs; -using System; -using System.IO; -using System.Text; - -namespace TestGnomeVfs { - public class TestSyncStream { - private static MainLoop loop; - - static void Main (string[] args) - { - if (args.Length != 1) { - Console.WriteLine ("Usage: TestSyncStream "); - return; - } - - Gnome.Vfs.Vfs.Initialize (); - - VfsStream stream = new VfsStream (args[0], FileMode.Open); - - UTF8Encoding utf8 = new UTF8Encoding (); - byte[] buffer = new byte[1024]; - int read; - while ((read = stream.Read (buffer, 0, buffer.Length)) != 0) { - Console.WriteLine ("read ({0} bytes) : '{1}'", - read, utf8.GetString (buffer, 0, read)); - } - - long offset = stream.Seek (0, SeekOrigin.Begin); - Console.WriteLine ("Offset after seek is {0}", offset); - - Gnome.Vfs.Vfs.Shutdown (); - } - } -} diff --git a/sample/gnomevfs/TestSyncWrite.cs b/sample/gnomevfs/TestSyncWrite.cs deleted file mode 100644 index 3d2921be3..000000000 --- a/sample/gnomevfs/TestSyncWrite.cs +++ /dev/null @@ -1,42 +0,0 @@ -using Gnome.Vfs; -using System; -using System.Text; - -namespace TestGnomeVfs { - public class TestSyncWrite { - static void Main (string[] args) - { - if (args.Length != 1) { - Console.WriteLine ("Usage: TestSyncWrite "); - return; - } - - Gnome.Vfs.Vfs.Initialize (); - - Gnome.Vfs.Uri uri = new Gnome.Vfs.Uri (args[0]); - - Handle handle = Sync.Open (uri, OpenMode.Write); - - UTF8Encoding utf8 = new UTF8Encoding (); - Result result = Result.Ok; - Console.WriteLine ("Enter text and end with Ctrl-D"); - while (result == Result.Ok) { - string line = Console.ReadLine (); - if (line == null) - break; - byte[] buffer = utf8.GetBytes (line); - - ulong bytesWritten; - result = Sync.Write (handle, out buffer[0], - (ulong)buffer.Length, out bytesWritten); - Console.WriteLine ("result write '{0}' = {1}", uri, result); - Console.WriteLine ("{0} bytes written", bytesWritten); - } - - result = Sync.Close (handle); - Console.WriteLine ("result close '{0}' = {1}", uri, result); - - Gnome.Vfs.Vfs.Shutdown (); - } - } -} diff --git a/sample/gnomevfs/TestUnlink.cs b/sample/gnomevfs/TestUnlink.cs deleted file mode 100644 index 67cccbf49..000000000 --- a/sample/gnomevfs/TestUnlink.cs +++ /dev/null @@ -1,23 +0,0 @@ -using Gnome.Vfs; -using System; - -namespace TestGnomeVfs { - public class TestUnlink { - static void Main (string[] args) - { - if (args.Length != 1) { - Console.WriteLine ("Usage: TestUnlink "); - return; - } - - Gnome.Vfs.Vfs.Initialize (); - - Gnome.Vfs.Uri uri = new Gnome.Vfs.Uri (args[0]); - Result result = uri.Unlink (); - - Console.WriteLine ("result unlink ('{0}') = {1}", uri, result); - - Gnome.Vfs.Vfs.Shutdown (); - } - } -} diff --git a/sample/gnomevfs/TestVolumes.cs b/sample/gnomevfs/TestVolumes.cs deleted file mode 100644 index 1a3abe4f5..000000000 --- a/sample/gnomevfs/TestVolumes.cs +++ /dev/null @@ -1,93 +0,0 @@ -using Gnome.Vfs; -using System; - -namespace TestGnomeVfs { - public class TestVolumes { - public TestVolumes () - { - Gnome.Vfs.Vfs.Initialize (); - - VolumeMonitor monitor = VolumeMonitor.Get (); - monitor.DriveConnected += new DriveConnectedHandler (OnDriveConnected); - monitor.DriveDisconnected += new DriveDisconnectedHandler (OnDriveDisconnected); - monitor.VolumeMounted += new VolumeMountedHandler (OnVolumeMounted); - monitor.VolumeUnmounted += new VolumeUnmountedHandler (OnVolumeUnmounted); - - Volume[] vols = monitor.MountedVolumes; - Console.WriteLine ("Mounted volumes:"); - foreach (Volume v in vols) - PrintVolume (v); - - Drive[] drives = monitor.ConnectedDrives; - Console.WriteLine ("\nConnected drives:"); - foreach (Drive d in drives) - PrintDrive (d); - - Console.WriteLine ("\nWaiting for volume events..."); - GLib.MainLoop loop = new GLib.MainLoop (); - loop.Run (); - - Gnome.Vfs.Vfs.Shutdown (); - } - - public void PrintDrive (Drive d) - { - Console.WriteLine ("Drive:"); - Console.WriteLine (" ActivationUri: {0}", d.ActivationUri); - Console.WriteLine (" DevicePath: {0}", d.DevicePath); - Console.WriteLine (" DeviceType: {0}", d.DeviceType); - Console.WriteLine (" DisplayName: {0}", d.DisplayName); - Console.WriteLine (" Icon: {0}", d.Icon); - Console.WriteLine (" Id: {0}", d.Id); - Console.WriteLine (" IsConnected: {0}", d.IsConnected); - Console.WriteLine (" IsMounted: {0}", d.IsMounted); - Console.WriteLine (" IsUserVisible: {0}", d.IsUserVisible); - } - - public void PrintVolume (Volume v) - { - Console.WriteLine ("Volume:"); - Console.WriteLine (" ActivationUri: {0}", v.ActivationUri); - Console.WriteLine (" DevicePath: {0}", v.DevicePath); - Console.WriteLine (" DeviceType: {0}", v.DeviceType); - Console.WriteLine (" DisplayName: {0}", v.DisplayName); - Console.WriteLine (" FilesystemType: {0}", v.FilesystemType); - Console.WriteLine (" HandlesTrash: {0}", v.HandlesTrash); - Console.WriteLine (" Icon: {0}", v.Icon); - Console.WriteLine (" Id: {0}", v.Id); - Console.WriteLine (" IsMounted: {0}", v.IsMounted); - Console.WriteLine (" IsReadOnly: {0}", v.IsReadOnly); - Console.WriteLine (" IsUserVisible: {0}", v.IsUserVisible); - Console.WriteLine (" VolumeType: {0}", v.VolumeType); - } - - static void Main (string[] args) - { - new TestVolumes (); - } - - public void OnDriveConnected (object o, DriveConnectedArgs args) - { - Console.WriteLine ("Drive connected:"); - PrintDrive (args.Drive); - } - - public void OnDriveDisconnected (object o, DriveDisconnectedArgs args) - { - Console.WriteLine ("Drive disconnected:"); - PrintDrive (args.Drive); - } - - public void OnVolumeMounted (object o, VolumeMountedArgs args) - { - Console.WriteLine ("Volume mounted:"); - PrintVolume (args.Volume); - } - - public void OnVolumeUnmounted (object o, VolumeUnmountedArgs args) - { - Console.WriteLine ("Volume unmounted:"); - PrintVolume (args.Volume); - } - } -} diff --git a/sample/gnomevfs/TestXfer.cs b/sample/gnomevfs/TestXfer.cs deleted file mode 100644 index d5239cdb2..000000000 --- a/sample/gnomevfs/TestXfer.cs +++ /dev/null @@ -1,164 +0,0 @@ -using Gnome.Vfs; -using Mono.GetOptions; -using System; -using System.Reflection; -using System.Runtime.CompilerServices; - -[assembly: AssemblyTitle("TestXfer")] -[assembly: AssemblyDescription("Test case for the Gnome.Vfs.Xfer class")] -[assembly: AssemblyCopyright("(C) 2004 Jeroen Zwartepoorte")] -[assembly: Mono.About("Distributed under the GPL")] -[assembly: Mono.UsageComplement(" ")] -[assembly: Mono.Author("Jeroen Zwartepoorte")] -[assembly: AssemblyVersion("1.0.*")] - -namespace TestGnomeVfs { - class TestXferOptions : Options { - [Option("Copy directories recursively", 'r')] - public bool recursive = false; - - [Option("Follow symlinks", 'L', "follow-symlinks")] - public bool followSymlinks = false; - - [Option("Follow symlinks recursively", 'Z', "recursive-symlinks")] - public bool recursiveSymlinks = false; - - [Option("Replace files automatically", 'R')] - public bool replace = false; - - [Option("Delete source files", 'd', "delete-source")] - public bool deleteSource = false; - - public TestXferOptions () - { - ParsingMode = OptionsParsingMode.Both; - } - - public override WhatToDoNext DoHelp () - { - base.DoHelp(); - return WhatToDoNext.AbandonProgram; - } - - [Option("Show usage syntax", 'u', "usage")] - public override WhatToDoNext DoUsage() - { - base.DoUsage(); - return WhatToDoNext.AbandonProgram; - } - } - - public class TestXfer { - static void Main (string[] args) - { - TestXferOptions opt = new TestXferOptions (); - opt.ProcessArgs (args); - - if (opt.RemainingArguments.Length < 2) { - opt.DoUsage (); - return; - } - - XferOptions options = XferOptions.Default; - XferOverwriteMode overwriteMode = XferOverwriteMode.Query; - if (opt.recursive) { - Console.WriteLine ("Warning: Recursive xfer of directories."); - options |= XferOptions.Recursive; - } - if (opt.followSymlinks) { - Console.WriteLine ("Warning: Following symlinks."); - options |= XferOptions.FollowLinks; - } - if (opt.recursiveSymlinks) { - Console.WriteLine ("Warning: Following symlinks recursively."); - options |= XferOptions.FollowLinksRecursive; - } - if (opt.replace) { - Console.WriteLine ("Warning: Using replace overwrite mode."); - overwriteMode = XferOverwriteMode.Replace; - } - if (opt.deleteSource) { - Console.WriteLine ("Warning: Removing source files."); - options |= XferOptions.Removesource; - } - - Gnome.Vfs.Vfs.Initialize (); - - Gnome.Vfs.Uri source = new Gnome.Vfs.Uri (opt.RemainingArguments[0]); - Console.WriteLine ("Source: `{0}'", source); - Gnome.Vfs.Uri target = new Gnome.Vfs.Uri (opt.RemainingArguments[1]); - Console.WriteLine ("Target: `{0}'", target); - - Result result = Xfer.XferUri (source, target, options, - XferErrorMode.Query, - overwriteMode, - new XferProgressCallback (OnProgress)); - Console.WriteLine ("Result: {0}", Gnome.Vfs.Vfs.ResultToString (result)); - - Gnome.Vfs.Vfs.Shutdown (); - } - - public static int OnProgress (XferProgressInfo info) - { - switch (info.Status) { - case XferProgressStatus.Vfserror: - Console.WriteLine ("Vfs error: {0}", - Gnome.Vfs.Vfs.ResultToString (info.VfsStatus)); - break; - case XferProgressStatus.Overwrite: - Console.WriteLine ("Overwriting `{0}' with `{1}'", - info.TargetName, info.SourceName); - break; - case XferProgressStatus.Ok: - Console.WriteLine ("Status: Ok"); - switch (info.Phase) { - case XferPhase.PhaseInitial: - Console.WriteLine ("Initial phase"); - return 1; - case XferPhase.PhaseCollecting: - Console.WriteLine ("Collecting file list"); - return 1; - case XferPhase.PhaseReadytogo: - Console.WriteLine ("Ready to go!"); - return 1; - case XferPhase.PhaseOpensource: - Console.WriteLine ("Opening source"); - return 1; - case XferPhase.PhaseOpentarget: - Console.WriteLine ("Opening target"); - return 1; - case XferPhase.PhaseCopying: - Console.WriteLine ("Transferring `{0}' to `{1}' " + - "(file {2}/{3}, byte {4}/{5} in file, " + - "{6}/{7} total", info.SourceName, - info.TargetName, info.FileIndex, - info.FilesTotal, (long)info.BytesCopied, - (long)info.FileSize, info.TotalBytesCopied, - info.BytesTotal); - break; - case XferPhase.PhaseClosesource: - Console.WriteLine ("Closing source"); - return 1; - case XferPhase.PhaseClosetarget: - Console.WriteLine ("Closing target"); - return 1; - case XferPhase.PhaseFilecompleted: - Console.WriteLine ("Done with `{0}' -> `{1}', going next", - info.SourceName, info.TargetName); - return 1; - case XferPhase.PhaseCompleted: - Console.WriteLine ("All done."); - return 1; - default: - Console.WriteLine ("Unexpected phase: {0}", info.Phase); - return 1; // Keep going anyway. - } - break; - case XferProgressStatus.Duplicate: - break; - } - - return 0; - } - } -}