コード例 #1
0
        private static unsafe bool Read(TFileStream *pStream, ref ulong byteOffset, void *pwBuffer, uint dwBytesToRead)
        {
            Debug.Assert(dwBytesToRead < int.MaxValue, "Unsupported case; must read < 2GiB worth of data per chunk.");

            if (pStream == null)
            {
                return(false);
            }

            FileStream fs;

            if (!_handlesToStreams.TryGetValue(pStream->hFile, out fs))
            {
                return(false);
            }

            byte[] tmpBuf = new byte[dwBytesToRead];
            if (byteOffset != 0)
            {
                long pos = unchecked ((long)byteOffset);
                fs.Seek(pos, SeekOrigin.Begin);
            }

            fs.Read(tmpBuf, 0, unchecked ((int)dwBytesToRead));
            IntPtr dest = new IntPtr(pwBuffer);

            Marshal.Copy(tmpBuf, 0, dest, unchecked ((int)dwBytesToRead));
            byteOffset = (ulong)fs.Position;

            return(true);
        }
コード例 #2
0
        private static unsafe bool GetSize(TFileStream *pStream, ref ulong FileSize)
        {
            if (pStream == null)
            {
                return(false);
            }

            FileStream fs;

            if (!_handlesToStreams.TryGetValue(pStream->hFile, out fs))
            {
                return(false);
            }

            FileSize = (ulong)fs.Length;
            return(true);
        }
コード例 #3
0
        private static unsafe bool GetPos(TFileStream *pStream, ref ulong byteOffset)
        {
            if (pStream == null)
            {
                return(false);
            }

            FileStream fs;

            if (!_handlesToStreams.TryGetValue(pStream->hFile, out fs))
            {
                return(false);
            }

            long pos = fs.Position;

            byteOffset = (ulong)pos;

            return(true);
        }
コード例 #4
0
 private static unsafe bool SetSize(TFileStream *pStream, ulong FileSize)
 {
     // Not supported in v1
     return(false);
 }
コード例 #5
0
 private static unsafe bool Write(TFileStream *pStream, ref ulong pByteOffset, void *pvBuffer, uint dwBytesToWrite)
 {
     // Not supported in v1
     return(false);
 }