Ejemplo n.º 1
0
        private int CabListNotify(NativeMethods.FDI.NOTIFICATIONTYPE notificationType, NativeMethods.FDI.NOTIFICATION notification)
        {
            switch (notificationType)
            {
            case NativeMethods.FDI.NOTIFICATIONTYPE.CABINET_INFO:
            {
                string nextCab = Marshal.PtrToStringAnsi(notification.psz1);
                this.NextCabinetName = (nextCab.Length != 0 ? nextCab : null);
                return(0);         // Continue
            }

            case NativeMethods.FDI.NOTIFICATIONTYPE.PARTIAL_FILE:
            {
                // This notification can occur when examining the contents of a non-first cab file.
                return(0);         // Continue
            }

            case NativeMethods.FDI.NOTIFICATIONTYPE.COPY_FILE:
            {
                //bool execute = (notification.attribs & (ushort) FileAttributes.Device) != 0;  // _A_EXEC

                string name = CabUnpacker.GetFileName(notification);

                if (this.filter == null || this.filter(name))
                {
                    if (this.fileList != null)
                    {
                        FileAttributes attributes = (FileAttributes)notification.attribs &
                                                    (FileAttributes.Archive | FileAttributes.Hidden | FileAttributes.ReadOnly | FileAttributes.System);
                        if (attributes == (FileAttributes)0)
                        {
                            attributes = FileAttributes.Normal;
                        }
                        DateTime lastWriteTime;
                        CompressionEngine.DosDateAndTimeToDateTime(notification.date, notification.time, out lastWriteTime);
                        long length = notification.cb;

                        CabFileInfo fileInfo = new CabFileInfo(
                            name,
                            notification.iFolder,
                            notification.iCabinet,
                            attributes,
                            lastWriteTime,
                            length);
                        this.fileList.Add(fileInfo);
                        this.currentFileNumber   = this.fileList.Count - 1;
                        this.fileBytesProcessed += notification.cb;
                    }
                }

                this.totalFiles++;
                this.totalFileBytes += notification.cb;
                return(0);         // Continue
            }
            }
            return(0);
        }
Ejemplo n.º 2
0
        private int CabListNotify(NativeMethods.FDI.NOTIFICATIONTYPE notificationType, NativeMethods.FDI.NOTIFICATION notification)
        {
            switch (notificationType)
            {
                case NativeMethods.FDI.NOTIFICATIONTYPE.CABINET_INFO:
                    {
                        string nextCab = Marshal.PtrToStringAnsi(notification.psz1);
                        this.NextCabinetName = (nextCab.Length != 0 ? nextCab : null);
                        return 0;  // Continue
                    }
                case NativeMethods.FDI.NOTIFICATIONTYPE.PARTIAL_FILE:
                    {
                        // This notification can occur when examining the contents of a non-first cab file.
                        return 0;  // Continue
                    }
                case NativeMethods.FDI.NOTIFICATIONTYPE.COPY_FILE:
                    {
                        //bool execute = (notification.attribs & (ushort) FileAttributes.Device) != 0;  // _A_EXEC

                        string name = CabUnpacker.GetFileName(notification);

                        if (this.filter == null || this.filter(name))
                        {
                            if (this.fileList != null)
                            {
                                FileAttributes attributes = (FileAttributes) notification.attribs &
                                    (FileAttributes.Archive | FileAttributes.Hidden | FileAttributes.ReadOnly | FileAttributes.System);
                                if (attributes == (FileAttributes) 0)
                                {
                                    attributes = FileAttributes.Normal;
                                }
                                DateTime lastWriteTime;
                                CompressionEngine.DosDateAndTimeToDateTime(notification.date, notification.time, out lastWriteTime);
                                long length = notification.cb;

                                CabFileInfo fileInfo = new CabFileInfo(
                                    name,
                                    notification.iFolder,
                                    notification.iCabinet,
                                    attributes,
                                    lastWriteTime,
                                    length);
                                this.fileList.Add(fileInfo);
                                this.currentFileNumber = this.fileList.Count - 1;
                                this.fileBytesProcessed += notification.cb;
                            }
                        }

                        this.totalFiles++;
                        this.totalFileBytes += notification.cb;
                        return 0;  // Continue
                    }
            }
            return 0;
        }