コード例 #1
0
ファイル: V8Unpack20.cs プロジェクト: viktortat/V8Commit
        public void Parse(FileV8Reader fileV8Reader, V8FileSystem fileSystem, string output, int threads = 1)
        {
            foreach (var reference in fileSystem.References)
            {
                fileV8Reader.Seek(reference.RefToData, SeekOrigin.Begin);
                string path = output + reference.FileHeader.FileName;

                using (MemoryStream memStream = new MemoryStream())
                {
                    using (MemoryStream memReader = new MemoryStream(fileV8Reader.ReadBytes(fileV8Reader.ReadBlockHeader())))
                    {
                        if (reference.IsInFlated)
                        {
                            using (DeflateStream deflateStream = new DeflateStream(memReader, CompressionMode.Decompress))
                            {
                                deflateStream.CopyTo(memStream);
                            }
                        }
                        else
                        {
                            memReader.CopyTo(memStream);
                        }
                    }

                    if (fileV8Reader.IsV8FileSystem(memStream))
                    {
                        if (!Directory.Exists(path))
                        {
                            Directory.CreateDirectory(path);
                        }

                        memStream.Seek(0, SeekOrigin.Begin);
                        using (FileV8Reader tmpV8Reader = new FileV8Reader(new BinaryReader(memStream, Encoding.Default, true)))
                        {
                            reference.Folder = tmpV8Reader.ReadV8FileSystem(false);
                            Parse(tmpV8Reader, reference.Folder, path + "\\");
                        }
                    }
                    else
                    {
                        using (FileStream fileStream = File.Create(path))
                        {
                            memStream.Seek(0, SeekOrigin.Begin);
                            memStream.CopyTo(fileStream);
                        }
                    }
                }
            }
        }
コード例 #2
0
ファイル: V8Commit20.cs プロジェクト: viktortat/V8Commit
        private FileV8Tree GetDescriptionTree(FileV8Reader fileV8Reader, V8FileSystem fileSystem, string folderName, string fileName)
        {
            if (String.IsNullOrEmpty(folderName))
            {
                var file = fileV8Reader.FindFileSystemReferenceByFileHeaderName(fileSystem.References, fileName);
                if (file == null)
                {
                    RaiseFileNotExistsException(fileName);
                }

                using (MemoryStream stream = new MemoryStream())
                {
                    fileV8Reader.ReadV8FileRawData(stream, file);
                    return(fileV8Reader.ParseV8File(stream, fileName));
                }
            }
            else
            {
                var folder = fileV8Reader.FindFileSystemReferenceByFileHeaderName(fileSystem.References, folderName);
                if (folder == null)
                {
                    RaiseFileNotExistsException(folderName);
                }

                using (MemoryStream stream = new MemoryStream())
                {
                    fileV8Reader.ReadV8FileRawData(stream, folder);
                    if (fileV8Reader.IsV8FileSystem(stream))
                    {
                        stream.Seek(0, SeekOrigin.Begin);
                        using (FileV8Reader tmpV8Reader = new FileV8Reader(new BinaryReader(stream, Encoding.Default, true)))
                        {
                            folder.Folder = tmpV8Reader.ReadV8FileSystem(false);
                            return(GetDescriptionTree(tmpV8Reader, folder.Folder, String.Empty, fileName));
                        }
                    }
                    else
                    {
                        RaiseItIsNotV8FolderException(folderName);
                    }
                }
            }

            return(null);
        }