예제 #1
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();
        }
예제 #2
0
 public Repository()
 {
     this.repositoryFiles = new List <Repository.RepositoryFile>();
     this.rootDirectory   = new Repository.RepoDirectory();
 }