internal CabUnpacker(CabEngine cabEngine) : base(cabEngine) { this.fdiAllocMemHandler = this.CabAllocMem; this.fdiFreeMemHandler = this.CabFreeMem; this.fdiOpenStreamHandler = this.CabOpenStream; this.fdiReadStreamHandler = this.CabReadStream; this.fdiWriteStreamHandler = this.CabWriteStream; this.fdiCloseStreamHandler = this.CabCloseStream; this.fdiSeekStreamHandler = this.CabSeekStream; this.fdiHandle = NativeMethods.FDI.Create( this.fdiAllocMemHandler, this.fdiFreeMemHandler, this.fdiOpenStreamHandler, this.fdiReadStreamHandler, this.fdiWriteStreamHandler, this.fdiCloseStreamHandler, this.fdiSeekStreamHandler, NativeMethods.FDI.CPU_80386, this.ErfHandle.AddrOfPinnedObject()); if (this.Erf.Error) { int error = this.Erf.Oper; int errorCode = this.Erf.Type; this.ErfHandle.Free(); throw new CabException( error, errorCode, CabException.GetErrorMessage(error, errorCode, true)); } }
private bool IsCabinet(Stream cabStream, out short id, out int cabFolderCount, out int fileCount) { int streamHandle = this.StreamHandles.AllocHandle(cabStream); try { this.Erf.Clear(); NativeMethods.FDI.CABINFO fdici; bool isCabinet = 0 != NativeMethods.FDI.IsCabinet(this.fdiHandle, streamHandle, out fdici); if (this.Erf.Error) { if (((NativeMethods.FDI.ERROR) this.Erf.Oper) == NativeMethods.FDI.ERROR.UNKNOWN_CABINET_VERSION) { isCabinet = false; } else { throw new CabException( this.Erf.Oper, this.Erf.Type, CabException.GetErrorMessage(this.Erf.Oper, this.Erf.Type, true)); } } id = fdici.setID; cabFolderCount = (int)fdici.cFolders; fileCount = (int)fdici.cFiles; return(isCabinet); } finally { this.StreamHandles.FreeHandle(streamHandle); } }
internal void CheckError(bool extracting) { if (this.Erf.Error) { throw new CabException( this.Erf.Oper, this.Erf.Type, CabException.GetErrorMessage(this.Erf.Oper, this.Erf.Type, extracting)); } }