Ejemplo n.º 1
0
        protected void ExtractSvo(string SvoPath)
        {
            //try
            //{
            using (var _SvoStream = File.OpenRead(SvoPath))
            {
                Stream SvoStream  = _SvoStream;
                int    Compressed = TalesCompression.DetectVersion(SvoStream.Slice().ReadBytes(16), SvoStream.Length);
                if (Compressed >= 0)
                {
                    SvoStream = TalesCompression.DecompressStream(SvoStream);
                }

                if (SvoStream.SliceWithLength().ReadString(7) == "TO8SCEL")
                {
                    var TO8SCEL = new TO8SCEL(SvoStream);

                    foreach (var Entry in TO8SCEL)
                    {
                        Console.WriteLine("{0} ... Start: {1}, End: {2}, Length: {3}", Entry.Index, Entry.EntryStruct.Offset, Entry.EntryStruct.Offset + Entry.EntryStruct.LengthCompressed, Entry.EntryStruct.LengthCompressed);
                    }
                }
                else
                {
                    var FPS4 = new FPS4(SvoStream);

                    Console.WriteLine("{0}", FPS4);

                    foreach (var Entry in FPS4)
                    {
                        Console.WriteLine("{0} ... Start: {1}, End: {2}, Length: {3}", Entry.Name, Entry.EntryStruct.Offset, Entry.EntryStruct.Offset + Entry.EntryStruct.LengthReal, Entry.EntryStruct.LengthReal);
                    }
                }
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="DatPath"></param>
        /// <param name="DavPath"></param>
        /// <param name="OutputDirectory"></param>
        protected void ExtractSvo2(string DatPath, string DavPath, string OutputDirectory = null)
        {
            if (DavPath == null)
            {
                DavPath = DatPath;
            }

            if (OutputDirectory == null)
            {
                OutputDirectory = DatPath + ".d";
            }

            Console.WriteLine("Loading {0}...", DatPath);
            //try
            //{
            using (var _Stream1 = File.OpenRead(DatPath))
                using (var Stream2 = File.OpenRead(DavPath))
                {
                    var Stream1 = (Stream)_Stream1;
                    try { Directory.CreateDirectory(OutputDirectory); }
                    catch { }

                    int Compressed = TalesCompression.DetectVersion(Stream1.Slice().ReadBytes(16), Stream1.Length);
                    if (Compressed >= 0)
                    {
                        Stream1 = TalesCompression.DecompressStream(Stream1);
                    }

                    if (Stream1.SliceWithLength().ReadString(7) == "TO8SCEL")
                    {
                        var TO8SCEL = new TO8SCEL(Stream1);

                        foreach (var Entry in TO8SCEL)
                        {
                            _ExtractFile(OutputDirectory + "/" + Entry.Index, () => Entry.UncompressedStream, (int)(uint)Entry.EntryStruct.Offset, (int)(uint)Entry.EntryStruct.LengthCompressed);
                        }
                    }
                    else
                    {
                        var FPS4 = new FPS4(Stream1, Stream2);

                        Console.WriteLine("{0}", FPS4);

                        foreach (var Entry in FPS4)
                        {
                            _ExtractFile(OutputDirectory + "/" + Entry.Name, () => Entry.Open(), (int)(uint)Entry.EntryStruct.Offset, (int)(uint)Entry.EntryStruct.LengthReal);
                        }
                    }
                }
            //}
            //catch (Exception Exception)
            //{
            //	Console.Error.WriteLine("{0}", Exception);
            //}
        }
Ejemplo n.º 3
0
 public void DecompressRecompressStreamIfRequired(Stream CompressedStream, Action <Stream> Action, int RecompressVersion = -1, bool RecompressJustWhenModified = true)
 {
     if (TalesCompression.DetectVersion(CompressedStream.Slice()) == -1)
     {
         Action(CompressedStream);
     }
     else
     {
         using (var UncompressedStream = new DecompressRecompressStream(CompressedStream, RecompressVersion, RecompressJustWhenModified))
         {
             Action(UncompressedStream);
         }
     }
 }
Ejemplo n.º 4
0
        private Stream DecompressIfCompressedStream(Stream FileStream)
        {
            var MagicData = FileStream.Slice().ReadBytesUpTo(0x100);

            // Decompress if compressed
            try
            {
                if (TalesCompression.DetectVersion(MagicData, FileStream.Length) != -1)
                {
                    return(TalesCompression.DecompressStream(FileStream));
                }
            }
            catch
            {
            }

            return(FileStream);
        }