Ejemplo n.º 1
0
        public LZX(string file)
        {
            File = new FileStream(file, FileMode.Open, FileAccess.ReadWrite, FileShare.None);
            io   = new EndianStream(File, false);

            // Read it to make sure its a PkZip file
            io.Seek((int)io.Length - 0x16, SeekOrigin.Begin);
            if (io.ReadInt32() != 0x06054B50)
            {
                throw new Exception("This is not a PkZip File!");
            }

            // Lets read the structure
            io.Seek((int)io.Length - 0x16, SeekOrigin.Begin);
            ZipEndLocator el = new ZipEndLocator(io);

            // Now that we have this info lets read our directory entries
            entries = new List <ZipDirEntry>();

            io.Seek(el.DirectoryOffset, SeekOrigin.Begin);
            for (int i = 0; i < el.EntriesInDirectory; i++)
            {
                entries.Add(new ZipDirEntry(io));
            }
        }
Ejemplo n.º 2
0
        public LZX(string file)
        {
            File = new FileStream(file, FileMode.Open, FileAccess.ReadWrite, FileShare.None);
            io = new EndianStream(File, false);

            // Read it to make sure its a PkZip file
            io.Seek((int)io.Length - 0x16, SeekOrigin.Begin);
            if (io.ReadInt32() != 0x06054B50)
                throw new Exception("This is not a PkZip File!");

            // Lets read the structure
            io.Seek((int)io.Length - 0x16, SeekOrigin.Begin);
            ZipEndLocator el = new ZipEndLocator(io);

            // Now that we have this info lets read our directory entries
            entries = new List<ZipDirEntry>();

            io.Seek(el.DirectoryOffset, SeekOrigin.Begin);
            for (int i = 0; i < el.EntriesInDirectory; i++)
            {
                entries.Add(new ZipDirEntry(io));
            }
        }
Ejemplo n.º 3
0
        public void Extract(string newFileName)
        {
            // Move to the record
            stream.Seek(headerOffset, SeekOrigin.Begin);

            // Read the record
            ZipFileRecord record = new ZipFileRecord(stream);

            // Decompress our data
            byte[] buffer = record.DecompressData();

            // Create and write our file
            FileStream fs = new FileStream(newFileName, FileMode.Create,
                                           FileAccess.Write);

            fs.Write(buffer, 0, buffer.Length);
            fs.Close();
        }