|
using System;
using System.IO;
using Microsoft.VisualStudio.OLE.Interop;
namespace WinHelpLib
{
class IStreamEx : Stream
{
IStream iStream;
long lSize = 0;
public IStreamEx(IStream iStr)
{
iStream = iStr;
Microsoft.VisualStudio.OLE.Interop.STATSTG[] stInfo = new Microsoft.VisualStudio.OLE.Interop.STATSTG[1];
iStream.Stat(stInfo, (uint)STATFLAG.STATFLAG_NONAME);
lSize = Convert.ToInt32(stInfo[0].cbSize.QuadPart);
}
public override bool CanRead
{
get { return true; }
}
public override bool CanSeek
{
get { return false; }
}
public override bool CanWrite
{ get { return false; }
}
public override long Length
{
get { return lSize; }
}
public override long Position
{
get {
ULARGE_INTEGER[] nlip = new ULARGE_INTEGER[1];
nlip[0] = new ULARGE_INTEGER();
LARGE_INTEGER li = new LARGE_INTEGER();
li.QuadPart = 0;
iStream.Seek(li, (uint)STREAM_SEEK.STREAM_SEEK_CUR, nlip);
return Convert.ToInt32(nlip[0]);
}
set {
LARGE_INTEGER li = new LARGE_INTEGER();
li.QuadPart = value;
iStream.Seek(li, (uint)STREAM_SEEK.STREAM_SEEK_SET, null);
}
}
public override int Read(byte[] buffer, int offset, int count)
{
uint cb = Convert.ToUInt32(count);
uint uiRead = 0;
byte[] inBuffer = new byte[count];
iStream.Read(inBuffer, cb, out uiRead);
inBuffer.CopyTo(buffer, offset);
return Convert.ToInt32(uiRead);
}
public override void Write(byte[] buffer, int offset, int count)
{
throw new NotImplementedException();
}
public override void SetLength(long value)
{
throw new NotImplementedException();
}
public override long Seek(long offset, SeekOrigin origin)
{
throw new NotImplementedException();
}
public override void Flush()
{
throw new NotImplementedException();
}
}
}
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.