private void CreateFci(long maxArchiveSize) { NativeMethods.FCI.CCAB ccab = new NativeMethods.FCI.CCAB(); if (maxArchiveSize > 0 && maxArchiveSize < ccab.cb) { ccab.cb = Math.Max( NativeMethods.FCI.MIN_DISK, (int)maxArchiveSize); } object maxFolderSizeOption = this.context.GetOption( "maxFolderSize", null); if (maxFolderSizeOption != null) { long maxFolderSize = Convert.ToInt64( maxFolderSizeOption, CultureInfo.InvariantCulture); if (maxFolderSize > 0 && maxFolderSize < ccab.cbFolderThresh) { ccab.cbFolderThresh = (int)maxFolderSize; } } this.maxCabBytes = ccab.cb; ccab.szCab = this.context.GetArchiveName(0); if (ccab.szCab == null) { throw new FileNotFoundException( "Cabinet name not provided by stream context."); } ccab.setID = (short)new Random().Next( Int16.MinValue, Int16.MaxValue + 1); this.CabNumbers[ccab.szCab] = 0; this.currentArchiveName = ccab.szCab; this.totalArchives = 1; this.CabStream = null; this.Erf.Clear(); this.fciHandle = NativeMethods.FCI.Create( this.ErfHandle.AddrOfPinnedObject(), this.fciFilePlacedHandler, this.fciAllocMemHandler, this.fciFreeMemHandler, this.fciOpenStreamHandler, this.fciReadStreamHandler, this.fciWriteStreamHandler, this.fciCloseStreamHandler, this.fciSeekStreamHandler, this.fciDeleteFileHandler, this.fciGetTempFileHandler, ccab, IntPtr.Zero); this.CheckError(false); }
private int CabGetNextCabinet(IntPtr pccab, uint prevCabSize, IntPtr pv) { NativeMethods.FCI.CCAB nextCcab = new NativeMethods.FCI.CCAB(); Marshal.PtrToStructure(pccab, nextCcab); nextCcab.szDisk = String.Empty; nextCcab.szCab = this.context.GetArchiveName(nextCcab.iCab); this.CabNumbers[nextCcab.szCab] = (short)nextCcab.iCab; this.NextCabinetName = nextCcab.szCab; Marshal.StructureToPtr(nextCcab, pccab, false); return(1); }