private void CreateFci(long maxArchiveSize)
 {
     NativeMethods.FCI.CCAB cCAB = new NativeMethods.FCI.CCAB();
     checked
     {
         if (maxArchiveSize > 0 && maxArchiveSize < cCAB.cb)
         {
             cCAB.cb = Math.Max(32768, (int)maxArchiveSize);
         }
         object option = context.GetOption("maxFolderSize", null);
         if (option != null)
         {
             long num = Convert.ToInt64(option, CultureInfo.InvariantCulture);
             if (num > 0 && num < cCAB.cbFolderThresh)
             {
                 cCAB.cbFolderThresh = (int)num;
             }
         }
         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(-32768, 32768);
         base.CabNumbers[cCAB.szCab] = 0;
         currentArchiveName          = cCAB.szCab;
         totalArchives  = 1;
         base.CabStream = null;
         base.Erf.Clear();
         fciHandle = NativeMethods.FCI.Create(base.ErfHandle.AddrOfPinnedObject(), fciFilePlacedHandler, fciAllocMemHandler, fciFreeMemHandler, fciOpenStreamHandler, fciReadStreamHandler, fciWriteStreamHandler, fciCloseStreamHandler, fciSeekStreamHandler, fciDeleteFileHandler, fciGetTempFileHandler, cCAB, IntPtr.Zero);
         CheckError(extracting: false);
     }
 }
Example #2
0
        private void CreateFci(long maxArchiveSize)
        {
            var ccab = new NativeMethods.FCI.CCAB();

            if (maxArchiveSize > 0 && maxArchiveSize < ccab.cb)
            {
                ccab.cb = Math.Max(
                    NativeMethods.FCI.MIN_DISK, (int)maxArchiveSize);
            }

            var maxFolderSizeOption = _context.GetOption(
                "maxFolderSize", null);

            if (maxFolderSizeOption != null)
            {
                var 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);
        }
 private int CabGetNextCabinet(IntPtr pccab, uint prevCabSize, IntPtr pv)
 {
     NativeMethods.FCI.CCAB cCAB = new NativeMethods.FCI.CCAB();
     Marshal.PtrToStructure(pccab, cCAB);
     cCAB.szDisk = string.Empty;
     cCAB.szCab  = context.GetArchiveName(cCAB.iCab);
     base.CabNumbers[cCAB.szCab] = checked ((short)cCAB.iCab);
     base.NextCabinetName        = cCAB.szCab;
     Marshal.StructureToPtr(cCAB, pccab, fDeleteOld: false);
     return(1);
 }
Example #4
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  = this.context.GetArchiveName(nextCcab.iCab);
            this.CabNumbers[nextCcab.szCab] = (short)nextCcab.iCab;
            this.NextCabinetName            = nextCcab.szCab;

            Marshal.StructureToPtr(nextCcab, pccab, false);
            return(1);
        }
Example #5
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 = this.context.GetArchiveName(nextCcab.iCab);
            this.CabNumbers[nextCcab.szCab] = (short) nextCcab.iCab;
            this.NextCabinetName = nextCcab.szCab;

            Marshal.StructureToPtr(nextCcab, pccab, false);
            return 1;
        }
Example #6
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 = 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);
        }