Esempio n. 1
0
            public RepositoryFile(Stream stream)
            {
                this.Stream = stream;
                byte[] buffer1 = new byte[256];
                stream.Read(buffer1, 0, 256);
                long offset = BitConverter.ToInt64(buffer1, 12);

                this.files = new Dictionary <ulong, Repository.RepositoryFileInfo>(BitConverter.ToInt32(buffer1, 24));
                byte[] buffer2 = new byte[12];
                while (offset != 0L)
                {
                    stream.Seek(offset, SeekOrigin.Begin);
                    stream.Read(buffer2, 0, buffer2.Length);
                    int    num1     = BitConverter.ToInt32(buffer2, 0);
                    long   num4     = BitConverter.ToInt64(buffer2, 4);
                    byte[] numArray = new byte[num1 * 34];
                    stream.Read(numArray, 0, numArray.Length);
                    for (int num2 = 0; num2 < num1; ++num2)
                    {
                        Repository.RepositoryFileInfo repositoryFileInfo = new Repository.RepositoryFileInfo(numArray, num2);
                        repositoryFileInfo.File             = this;
                        this.files[repositoryFileInfo.Hash] = repositoryFileInfo;
                    }
                    offset = num4;
                }
            }
Esempio n. 2
0
            public RepositoryFile(System.IO.Stream stream)
            {
                this.Stream = stream;
                byte[] buffer = new byte[0x100];
                stream.Read(buffer, 0, 0x100);
                long offset   = BitConverter.ToInt64(buffer, 12);
                int  capacity = BitConverter.ToInt32(buffer, 0x18);

                this.files = new Dictionary <ulong, Repository.RepositoryFileInfo>(capacity);
                byte[] buffer2 = new byte[12];
                while (offset != 0L)
                {
                    stream.Seek(offset, SeekOrigin.Begin);
                    stream.Read(buffer2, 0, buffer2.Length);
                    int    num3    = BitConverter.ToInt32(buffer2, 0);
                    long   num4    = BitConverter.ToInt64(buffer2, 4);
                    byte[] buffer3 = new byte[num3 * 0x22];
                    stream.Read(buffer3, 0, buffer3.Length);
                    for (int i = 0; i < num3; i++)
                    {
                        Repository.RepositoryFileInfo info = new Repository.RepositoryFileInfo(buffer3, i)
                        {
                            File = this
                        };
                        this.files[info.Hash] = info;
                    }
                    offset = num4;
                }
            }
Esempio n. 3
0
 public Repository.RepositoryFileInfo GetFileInfo(ulong hash, string name)
 {
     if (!this.files.ContainsKey(hash))
     {
         return((Repository.RepositoryFileInfo)null);
     }
     Repository.RepositoryFileInfo repositoryFileInfo = this.files[hash];
     repositoryFileInfo.Name = name;
     return(repositoryFileInfo);
 }
Esempio n. 4
0
 public Stream GetFile(string name)
 {
     Repository.RepositoryFileInfo fileInfo = this.GetFileInfo(name);
     if (fileInfo != null)
     {
         return(fileInfo.File.GetFile(fileInfo));
     }
     else
     {
         return((Stream)null);
     }
 }
Esempio n. 5
0
        public Repository.RepositoryFileInfo GetFileInfo(string name)
        {
            ulong hash = Repository.Hasher.Hash(name, 3735928559U);

            foreach (Repository.RepositoryFile repositoryFile in this.repositoryFiles)
            {
                Repository.RepositoryFileInfo fileInfo = repositoryFile.GetFileInfo(hash, name);
                if (fileInfo != null)
                {
                    return(fileInfo);
                }
            }
            return((Repository.RepositoryFileInfo)null);
        }
Esempio n. 6
0
            public Stream GetFile(Repository.RepositoryFileInfo info)
            {
                byte[] buffer1 = new byte[info.UncompressedSize];
                switch (info.CompressionMethod)
                {
                case (ushort)0:
                    this.Stream.Seek(info.Offset + (long)info.HeaderSize, SeekOrigin.Begin);
                    this.Stream.Read(buffer1, 0, buffer1.Length);
                    break;

                case (ushort)1:
                    this.Stream.Seek(info.Offset + (long)info.HeaderSize, SeekOrigin.Begin);
                    byte[] buffer2 = new byte[info.CompressedSize];
                    this.Stream.Read(buffer2, 0, buffer2.Length);
                    Inflater inflater = new Inflater();
                    inflater.SetInput(buffer2);
                    inflater.Inflate(buffer1);
                    break;
                }
                return((Stream) new MemoryStream(buffer1));
            }
Esempio n. 7
0
        public void ExtractFile(Repository.RepositoryFileInfo info)
        {
            Stream file  = info.File.GetFile(info);
            string path1 = (info.Name == null ? string.Format("{0}/{1:X}.bin", (object)this.extractBasePath, (object)info.Hash) : this.extractBasePath + info.Name).Replace('/', '\\');

            Repository.RepoDirectory repoDirectory1 = this.rootDirectory;
            string[] strArray = info.Name.Split(new char[1]
            {
                '/'
            });
            string path2 = this.extractBasePath + "\\";

            for (int index = 1; index < strArray.Length - 1; ++index)
            {
                if (repoDirectory1.SubDirectories.ContainsKey(strArray[index]))
                {
                    repoDirectory1 = repoDirectory1.SubDirectories[strArray[index]];
                }
                else
                {
                    Repository.RepoDirectory repoDirectory2 = new Repository.RepoDirectory();
                    repoDirectory2.Name = strArray[index];
                    repoDirectory1.SubDirectories[strArray[index]] = repoDirectory2;
                    repoDirectory1 = repoDirectory2;
                }
                path2 = path2 + strArray[index] + "\\";
            }
            if (!repoDirectory1.Files.Contains(strArray[strArray.Length - 1]))
            {
                repoDirectory1.Files.Add(strArray[strArray.Length - 1]);
            }
            Directory.CreateDirectory(path2);
            Stream stream = (Stream)File.Open(path1, FileMode.Create, FileAccess.Write);

            byte[] buffer = new byte[file.Length];
            file.Read(buffer, 0, buffer.Length);
            stream.Write(buffer, 0, buffer.Length);
            file.Close();
            stream.Close();
        }
Esempio n. 8
0
            public System.IO.Stream GetFile(Repository.RepositoryFileInfo info)
            {
                byte[] buffer = new byte[info.UncompressedSize];
                switch (info.CompressionMethod)
                {
                case 0:
                    this.Stream.Seek(info.Offset + info.HeaderSize, SeekOrigin.Begin);
                    this.Stream.Read(buffer, 0, buffer.Length);
                    break;

                case 1:
                {
                    this.Stream.Seek(info.Offset + info.HeaderSize, SeekOrigin.Begin);
                    byte[] buffer2 = new byte[info.CompressedSize];
                    this.Stream.Read(buffer2, 0, buffer2.Length);
                    Inflater inflater = new Inflater();
                    inflater.SetInput(buffer2);
                    inflater.Inflate(buffer);
                    break;
                }
                }
                return(new MemoryStream(buffer));
            }