File: TestSync.cs

package info (click to toggle)
gtk-sharp2 2.8.3-2
  • links: PTS
  • area: main
  • in suites: etch, etch-m68k
  • size: 21,208 kB
  • ctags: 5,843
  • sloc: xml: 245,420; cs: 24,183; sh: 8,547; ansic: 2,739; makefile: 1,582; perl: 1,177
file content (44 lines) | stat: -rw-r--r-- 1,206 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
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 <uri>");
				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 ();
		}
	}
}