hlStreamRead() public static method

public static hlStreamRead ( IntPtr pStream, IntPtr lpData, uint uiBytes ) : uint
pStream IntPtr
lpData IntPtr
uiBytes uint
return uint
コード例 #1
0
        public override int Read(byte[] buffer, int offset, int count)
        {
            IntPtr dataPtr = Marshal.AllocHGlobal((int)(_size > count ? count : _size));

            HLLib.hlStreamRead(_streamPtr, dataPtr, (uint)(_size > count ? count : _size));

            unsafe
            {
                var source = (byte *)dataPtr;
                fixed(byte *dest = buffer)
                {
                    for (int i = offset; i < (_size - offset > count ? count : _size - offset); i++)
                    {
                        dest[i] = source[i];
                    }
                }
            }

            Marshal.FreeHGlobal(dataPtr);
            return((int)(_size - offset > count ? count : _size - offset));
        }