From 5290f4c520d3c5da9cabd292aedd63a606cfcc3d Mon Sep 17 00:00:00 2001 From: Stephane Delcroix Date: Fri, 13 Nov 2009 16:20:04 +0100 Subject: [PATCH 1/3] gio: Wrap IOStream in GIOStream too --- gio/GioStream.cs | 26 ++++++++++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) diff --git a/gio/GioStream.cs b/gio/GioStream.cs index 03d1696f1..259d9d5f3 100644 --- a/gio/GioStream.cs +++ b/gio/GioStream.cs @@ -63,6 +63,14 @@ namespace GLib can_seek = stream is Seekable && (stream as Seekable).CanSeek; } + public GioStream (IOStream stream) + { + this.stream = stream; + can_read = true; + can_write = true; + can_seek = stream is Seekable && (stream as Seekable).CanSeek; + } + public override bool CanSeek { get { return can_seek; } } @@ -90,6 +98,10 @@ namespace GLib FileInfo info = (stream as FileOutputStream).QueryInfo ("standard::size", null); return info.Size; } + if (stream is FileIOStream) { + FileInfo info = (stream as FileIOStream).QueryInfo ("standard::size", null); + return info.Size; + } throw new NotImplementedException (String.Format ("not implemented for {0} streams", stream.GetType())); } } @@ -127,7 +139,11 @@ namespace GLib throw new NotSupportedException ("The stream does not support reading"); if (is_disposed) throw new ObjectDisposedException ("The stream is closed"); - InputStream input_stream = stream as InputStream; + InputStream input_stream = null; + if (stream is InputStream) + input_stream = stream as InputStream; + else if (stream is IOStream) + input_stream = (stream as IOStream).InputStream; if (input_stream == null) throw new System.Exception ("this shouldn't happen"); @@ -155,7 +171,11 @@ namespace GLib throw new NotSupportedException ("The stream does not support writing"); if (is_disposed) throw new ObjectDisposedException ("The stream is closed"); - OutputStream output_stream = stream as OutputStream; + OutputStream output_stream = null; + if (stream is OutputStream) + output_stream = stream as OutputStream; + else if (stream is IOStream) + output_stream = (stream as IOStream).OutputStream; if (output_stream == null) throw new System.Exception ("this shouldn't happen"); if (offset == 0) { @@ -209,6 +229,8 @@ namespace GLib (stream as InputStream).Close (null); if (stream is OutputStream) (stream as OutputStream).Close (null); + if (stream is IOStream) + (stream as IOStream).Close (null); is_disposed = true; } } From f6009bbde14a3f26d4b86289863283c2eb7e71f1 Mon Sep 17 00:00:00 2001 From: Gabriel Burt Date: Mon, 18 Jan 2010 09:36:53 +0100 Subject: [PATCH 2/3] gio: Implement GioStream.SetLength --- gio/GioStream.cs | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/gio/GioStream.cs b/gio/GioStream.cs index 259d9d5f3..631549244 100644 --- a/gio/GioStream.cs +++ b/gio/GioStream.cs @@ -218,9 +218,16 @@ namespace GLib { if (!CanSeek || !CanWrite) throw new NotSupportedException ("This stream doesn't support seeking"); + + var seekable = stream as Seekable; + + if (!seekable.CanTruncate ()) + throw new NotSupportedException ("This stream doesn't support truncating"); + if (is_disposed) throw new ObjectDisposedException ("The stream is closed"); - throw new NotImplementedException (); + + seekable.Truncate (value, null); } public override void Close () From bcf42187a82f1be02d4c23fbc219e0a0399b1411 Mon Sep 17 00:00:00 2001 From: Alex Launi Date: Sun, 17 Jul 2011 17:28:51 +0200 Subject: [PATCH 3/3] gio: Fix return type of GMount.GuessContentType* --- gio/Gio.metadata | 2 ++ 1 file changed, 2 insertions(+) diff --git a/gio/Gio.metadata b/gio/Gio.metadata index b80aa5712..59a390dc1 100644 --- a/gio/Gio.metadata +++ b/gio/Gio.metadata @@ -30,6 +30,8 @@ 1 1 GetCanUnmount + 1 + 1 GetCanSeek GetPosition 1