public PackageFileStream(IntPtr filePtr) { _filePtr = filePtr; if (!HLLib.hlFileCreateStream(filePtr, out _streamPtr)) { throw new Exception("Unable to create stream."); } if (!HLLib.hlStreamOpen(_streamPtr, (uint)HLLib.HLFileMode.HL_MODE_READ)) { throw new Exception("Unable to open stream."); } _size = (long)HLLib.hlStreamGetStreamSizeEx(_streamPtr); }
private static string ReadTextFromHLLibStream(IntPtr Stream) { HLLib.HLFileMode mode = HLLib.HLFileMode.HL_MODE_READ; ErrorCheck(HLLib.hlStreamOpen(Stream, (uint)mode)); StringBuilder str = new StringBuilder(); char ch; while (HLLib.hlStreamReadChar(Stream, out ch)) { str.Append(ch); } HLLib.hlStreamClose(Stream); return(str.ToString()); }