hlStreamRead() 공개 정적인 메소드

public static hlStreamRead ( IntPtr pStream, IntPtr lpData, uint uiBytes ) : uint
pStream IntPtr
lpData IntPtr
uiBytes uint
리턴 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));
        }