Exemplo n.º 1
0
        /// <summary>
        /// Create a new UnshieldReader from an existing cabinet, index, and file descriptor
        /// </summary>
        public static Reader Create(InstallShieldCabinet cabinet, int index, FileDescriptor fileDescriptor)
        {
            var reader = new Reader
            {
                Cabinet        = cabinet,
                Index          = (uint)index,
                FileDescriptor = fileDescriptor,
            };

            for (; ;)
            {
                if (!reader.OpenVolume(fileDescriptor.Volume))
                {
                    Console.Error.WriteLine($"Failed to open volume {fileDescriptor.Volume}");
                    return(null);
                }

                // Start with the correct volume for IS5 cabinets
                if (reader.Cabinet.HeaderList.MajorVersion <= 5 && index > (int)reader.VolumeHeader.LastFileIndex)
                {
                    fileDescriptor.Volume++;
                    continue;
                }

                break;
            }

            return(reader);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Open a file as an InstallShield CAB, forcing a version
        /// </summary>
        public static InstallShieldCabinet OpenForceVersion(string filename, int version)
        {
            var cabinet = new InstallShieldCabinet();

            if (!cabinet.CreateFilenamePattern(filename))
            {
                Console.Error.WriteLine("Failed to create filename pattern");
                return(null);
            }

            if (!cabinet.ReadHeaders(version))
            {
                Console.Error.WriteLine("Failed to read header files");
                return(null);
            }

            return(cabinet);
        }