Ejemplo n.º 1
0
        public override FileReference[] Unpack(FileReference input, bool recur, bool decomp)
        {
            string            head         = ReadString(input.Stream, 8);
            int               indexPointer = ReadInt32(input.Stream);
            int               indexNumber  = ReadInt32(input.Stream);
            int               useless      = ReadInt32(input.Stream);
            string            dir          = ReadString(input.Stream, indexPointer - 0x14);
            CompressionMethod decompressor = new LZ77CNX(); //Should be changed to go through a global list of compression methods

            List <FileIndex> indices = new List <FileIndex>();

            for (int x = 0; x < indexNumber; x++)
            {
                indices.Add(new FileIndex(ReadString(input.Stream, 12), ReadInt32(input.Stream), ReadInt32(input.Stream)));
            }

            List <FileReference> output = new List <FileReference>();
            FileReference        master = new FileReference(new MemoryStream(), Path.GetFileNameWithoutExtension(input.FileName) + ".fld_index", "");

            for (int x = 0; x < indices.Count; x++)
            {
                FileIndex    index   = indices[x];
                MemoryStream current = new MemoryStream();
                for (int y = 0; y < index.FileSize; y++)
                {
                    current.WriteByte((byte)input.Stream.ReadByte());
                }
                FileReference outputFile = new FileReference(current, index.FileName.Trim(), Path.GetFileNameWithoutExtension(input.FileName) + "/" + dir);
                if (recur && Verify(current))
                {
                    output.AddRange(Unpack(outputFile, recur, decomp));
                }
                else if (decomp)
                {
                    output.Add(decompressor.Decompress(outputFile));
                }
                else
                {
                    output.Add(outputFile);
                }
                WriteInt32(master.Stream, index.FileName.Length);
                WriteString(master.Stream, index.FileName);
            }

            output.Add(master);
            return(output.ToArray <FileReference>());
        }
Ejemplo n.º 2
0
        public override FileReference[] Unpack(FileReference input, bool recur, bool decomp)
        {
            int indexNumber = ReadInt16(input.Stream);
            CompressionMethod decompressor = new LZ77CNX(); //Should be changed to go through a global list of compression methods

            List <FileIndex> indices = new List <FileIndex>();

            for (int x = 0; x < indexNumber; x++)
            {
                indices.Add(new FileIndex("track" + (x + 1) + ".cnx", ReadInt32(input.Stream), ReadInt32(input.Stream)));
                if (x != indexNumber - 1)
                {
                    input.Stream.ReadByte();                    //Stupid spacer
                }
            }

            List <FileReference> output = new List <FileReference>();

            for (int x = 0; x < indices.Count; x++)
            {
                FileIndex    index   = indices[x];
                MemoryStream current = new MemoryStream();
                for (int y = 0; y < index.FileSize; y++)
                {
                    current.WriteByte((byte)input.Stream.ReadByte());
                }
                FileReference outputFile = new FileReference(current, index.FileName.Trim(), "");
                if (decomp)
                {
                    output.Add(decompressor.Decompress(outputFile));
                }
                else
                {
                    output.Add(outputFile);
                }
            }

            return(output.ToArray <FileReference>());
        }