public void Seek(long dlibMove, STREAM_SEEK dwOrigin, IntPtr plibNewPosition)
            {
                SeekOrigin seekOrigin;

                switch (dwOrigin)
                {
                case STREAM_SEEK.STREAM_SEEK_SET:
                    seekOrigin = SeekOrigin.Begin;
                    break;

                case STREAM_SEEK.STREAM_SEEK_CUR:
                    seekOrigin = SeekOrigin.Current;
                    break;

                case STREAM_SEEK.STREAM_SEEK_END:
                    seekOrigin = SeekOrigin.End;
                    break;

                default:
                    throw new ArgumentOutOfRangeException(nameof(dwOrigin));
                }
                long newPosition = UnderlyingStream.Seek(dlibMove, seekOrigin);

                if (plibNewPosition != IntPtr.Zero)
                {
                    Marshal.WriteInt64(plibNewPosition, 0, newPosition);
                }
            }
Exemplo n.º 2
0
            int IStream.Seek(long dlibMove, STREAM_SEEK dwOrigin, IntPtr plibNewPosition)
            {
                SeekOrigin origin;

                switch (dwOrigin)
                {
                case STREAM_SEEK.STREAM_SEEK_SET:
                    origin = SeekOrigin.Begin;
                    break;

                case STREAM_SEEK.STREAM_SEEK_CUR:
                    origin = SeekOrigin.Current;
                    break;

                case STREAM_SEEK.STREAM_SEEK_END:
                    origin = SeekOrigin.End;
                    break;

                default:
                    return(STG_E_INVALIDFUNCTION);
                }

                if (plibNewPosition != IntPtr.Zero)
                {
                    Marshal.WriteInt64(plibNewPosition, stream.Seek(dlibMove, origin));
                }
                return(S_OK);
            }
        public static void Seek(this IStream stream, long dlibMove, STREAM_SEEK dwOrigin, out long plibNewPosition)
        {
            var plibNewPositionPtr = Marshal.AllocCoTaskMem(8);

            try
            {
                stream.Seek(dlibMove, dwOrigin, plibNewPositionPtr);
                plibNewPosition = Marshal.ReadInt64(plibNewPositionPtr, 0);
            }
            finally
            {
                Marshal.FreeCoTaskMem(plibNewPositionPtr);
            }
        }
Exemplo n.º 4
0
    public unsafe void Seek(long dlibMove, STREAM_SEEK dwOrigin, ulong *plibNewPosition = default)
    {
        var seekOrigin = dwOrigin switch
        {
            STREAM_SEEK.STREAM_SEEK_SET => SeekOrigin.Begin,
            STREAM_SEEK.STREAM_SEEK_CUR => SeekOrigin.Current,
            STREAM_SEEK.STREAM_SEEK_END => SeekOrigin.End,
            _ => throw new ArgumentOutOfRangeException(nameof(dwOrigin))
        };

        var newPosition = _baseStream.Seek(dlibMove, seekOrigin);

        if (plibNewPosition is not null)
        {
            Marshal.WriteInt64(new IntPtr(plibNewPosition), newPosition);
        }
    }
Exemplo n.º 5
0
        internal static int Seek(this IStream stream, long dlibMove, STREAM_SEEK dwOrigin)
        {
            IntPtr plibNewPosition = default(IntPtr);

            return(stream.Seek(dlibMove, (int)dwOrigin, plibNewPosition));
        }
            int IStream.Seek(long dlibMove, STREAM_SEEK dwOrigin, IntPtr plibNewPosition)
            {
                SeekOrigin origin;
                switch (dwOrigin)
                {
                    case STREAM_SEEK.STREAM_SEEK_SET:
                        origin = SeekOrigin.Begin;
                        break;
                    case STREAM_SEEK.STREAM_SEEK_CUR:
                        origin = SeekOrigin.Current;
                        break;
                    case STREAM_SEEK.STREAM_SEEK_END:
                        origin = SeekOrigin.End;
                        break;
                    default:
                        return STG_E_INVALIDFUNCTION;
                }

                if (plibNewPosition != IntPtr.Zero)
                    Marshal.WriteInt64(plibNewPosition, stream.Seek(dlibMove, origin));
                return S_OK;
            }
 public static void Seek(this IStream stream, long dlibMove, STREAM_SEEK dwOrigin)
 {
     stream.Seek(dlibMove, dwOrigin, IntPtr.Zero);
 }