Esempio n. 1
0
        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 = context.GetOption(
                "maxFolderSize", null);

            if (maxFolderSizeOption != null)
            {
                long maxFolderSize = Convert.ToInt64(
                    maxFolderSizeOption, CultureInfo.InvariantCulture);
                if (maxFolderSize > 0 && maxFolderSize < ccab.cbFolderThresh)
                {
                    ccab.cbFolderThresh = (int)maxFolderSize;
                }
            }

            maxCabBytes = ccab.cb;
            ccab.szCab  = 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);
            CabNumbers[ccab.szCab] = 0;
            currentArchiveName     = ccab.szCab;
            totalArchives          = 1;
            CabStream = null;

            Erf.Clear();
            fciHandle = NativeMethods.FCI.Create(
                ErfHandle.AddrOfPinnedObject(),
                fciFilePlacedHandler,
                fciAllocMemHandler,
                fciFreeMemHandler,
                fciOpenStreamHandler,
                fciReadStreamHandler,
                fciWriteStreamHandler,
                fciCloseStreamHandler,
                fciSeekStreamHandler,
                fciDeleteFileHandler,
                fciGetTempFileHandler,
                ccab,
                IntPtr.Zero);
            CheckError(false);
        }
Esempio n. 2
0
        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             = context.GetArchiveName(nextCcab.iCab);
            CabNumbers[nextCcab.szCab] = (short)nextCcab.iCab;
            NextCabinetName            = nextCcab.szCab;

            Marshal.StructureToPtr(nextCcab, pccab, false);
            return(1);
        }