/// <summary> /// Reads bytes from a file. /// </summary> /// <param name="hf">The file handle from which to read.</param> /// <param name="buffer">The buffer where read bytes are placed.</param> /// <param name="cb">Size of the read buffer.</param> /// <param name="err">Error return value.</param> /// <param name="pUserData">User data object.</param> /// <returns>Returns the number of bytes read.</returns> /// <remarks>The File Compression Interface (FCI) calls this function to read from a file.</remarks> protected virtual int FileRead(IntPtr hf, byte[] buffer, int cb, ref int err, IntPtr pUserData) { Trace.WriteLine(string.Format("FileRead {0}", hf)); int bytesRead = CabIO.FileRead(hf, buffer, cb, ref err, ((GCHandle)pUserData).Target); Trace.WriteLine(string.Format("Returning {0}", bytesRead)); return(bytesRead); }
/// <summary> /// Reads bytes from a file. /// </summary> /// <param name="hf">The file handle from which to read.</param> /// <param name="buffer">The buffer where read bytes are placed.</param> /// <param name="cb">Size of the read buffer.</param> /// <returns>Returns the number of bytes read.</returns> /// <remarks>The File Decompression Interface (FDI) calls this function to read from a file.</remarks> protected virtual int FileRead(IntPtr hf, byte[] buffer, int cb) { Trace.WriteLine(string.Format("FileRead {0}", hf)); int err = 0; try { return(CabIO.FileRead(hf, buffer, cb, ref err, userData)); } finally { erf.ErrorType = err; } }