internal MSCompressedFile(MSCabinet parentCabinet, IntPtr pNativeFile) { //NOTE: we don't need to explicitly clean the nativeFile up. It is cleaned up by the parent cabinet. _parentCabinet = parentCabinet; _pNativeFile = pNativeFile; _nativeFile = (NativeMethods.mscabd_file)Marshal.PtrToStructure(_pNativeFile, typeof(NativeMethods.mscabd_file)); }
/// <summary> /// Appends specified cabinet to this one, forming or extending a cabinet set. /// </summary> /// <param name="nextCabinet">The cab to append to this one.</param> public void Append(MSCabinet nextCabinet) { var result = NativeMethods.mspack_invoke_mscab_decompressor_append(_pDecompressor, _pNativeCabinet, nextCabinet._pNativeCabinet); if (result != NativeMethods.MSPACK_ERR.MSPACK_ERR_OK) { throw new Exception(string.Format("Error '{0}' appending cab '{1}' to {2}.", result, nextCabinet._cabinetFilename, _cabinetFilename)); } // after a successul append remarshal over the nativeCabinet struct5ure as it now represents the combined state. _nativeCabinet = (NativeMethods.mscabd_cabinet)Marshal.PtrToStructure(_pNativeCabinet, typeof(NativeMethods.mscabd_cabinet)); nextCabinet._nativeCabinet = (NativeMethods.mscabd_cabinet)Marshal.PtrToStructure(nextCabinet._pNativeCabinet, typeof(NativeMethods.mscabd_cabinet)); }
private static void ExplodeCab(string cabinetFilename) { Console.WriteLine("Files in " + cabinetFilename + ":"); try { using (var cab = new LibMSPackN.MSCabinet(cabinetFilename)) { var outDir = OutDir(cabinetFilename); ExplodeCab(cab, outDir); } } catch (Exception e) { Console.WriteLine("ERROR! " + e.Message); } Console.WriteLine(""); Console.WriteLine(""); }