CarotDav_decompile/Rei.Com/ComStreamAdapterStream.cs

103 lines
2.2 KiB
C#

// Decompiled with JetBrains decompiler
// Type: Rei.Com.ComStreamAdapterStream
// Assembly: Rei.Com, Version=1.13.2.9255, Culture=neutral, PublicKeyToken=null
// MVID: 608BC623-FF3D-4118-BA82-AC691A688790
// Assembly location: F:\Eigene Dateien\Dropbox\portable Collection\Progs\CarotDAV\Rei.Com.dll
using System;
using System.IO;
using System.Runtime.InteropServices;
using System.Runtime.InteropServices.ComTypes;
namespace Rei.Com
{
public class ComStreamAdapterStream : Stream
{
private IStream pStream;
private System.Runtime.InteropServices.ComTypes.STATSTG pStat;
public ComStreamAdapterStream(IStream istream)
{
this.pStream = istream;
this.pStat = new System.Runtime.InteropServices.ComTypes.STATSTG();
this.pStream.Stat(out this.pStat, 0);
}
public override bool CanRead
{
get
{
return true;
}
}
public override bool CanSeek
{
get
{
return true;
}
}
public override bool CanWrite
{
get
{
return true;
}
}
public override void Flush()
{
throw new NotImplementedException();
}
public override long Length
{
get
{
return this.pStat.cbSize;
}
}
public override long Position
{
get
{
throw new NotImplementedException();
}
set
{
throw new NotImplementedException();
}
}
public override int Read(byte[] buffer, int offset, int count)
{
IntPtr num = Marshal.AllocHGlobal(4);
byte[] pv = new byte[checked (count - 1 + 1)];
this.pStream.Read(pv, count, num);
int length = Marshal.ReadInt32(num, 0);
Array.Copy((Array) pv, 0, (Array) buffer, offset, length);
return length;
}
public override long Seek(long offset, SeekOrigin origin)
{
IntPtr num = Marshal.AllocHGlobal(4);
this.pStream.Seek(offset, (int) origin, num);
return Marshal.ReadInt64(num, 0);
}
public override void SetLength(long value)
{
this.pStream.SetSize(value);
}
public override void Write(byte[] buffer, int offset, int count)
{
this.pStream.Write(buffer, count, IntPtr.Zero);
}
}
}