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); }
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); }
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); }
private static unsafe bool SetSize(TFileStream *pStream, ulong FileSize) { // Not supported in v1 return(false); }
private static unsafe bool Write(TFileStream *pStream, ref ulong pByteOffset, void *pvBuffer, uint dwBytesToWrite) { // Not supported in v1 return(false); }