public PakPackageStreamSource(PakPackage package)
 {
     _package = package;
     _stream = package.OpenFile(package.PackageFile);
     _folders = new Dictionary<string, HashSet<string>>();
     _files = new Dictionary<string, HashSet<string>>();
     foreach (var entry in package.GetEntries())
     {
         var split = entry.FullName.Split('/');
         var joined = "";
         for (var i = 0; i < split.Length; i++)
         {
             var sub = split[i];
             var name = joined.Length == 0 ? sub : joined + '/' + sub;
             if (i == split.Length - 1)
             {
                 // File name
                 if (!_files.ContainsKey(joined)) _files.Add(joined, new HashSet<string>());
                 _files[joined].Add(name);
             }
             else
             {
                 // Folder name
                 if (!_folders.ContainsKey(joined)) _folders.Add(joined, new HashSet<string>());
                 if (!_folders[joined].Contains(sub)) _folders[joined].Add(name);
             }
             joined = joined.Length == 0 ? sub : joined + '/' + sub;
         }
     }
 }
Exemple #2
0
 public PakPackageStreamSource(PakPackage package)
 {
     _package = package;
     _stream  = package.OpenFile(package.PackageFile);
     _folders = new Dictionary <string, HashSet <string> >();
     _files   = new Dictionary <string, HashSet <string> >();
     foreach (var entry in package.GetEntries())
     {
         var split  = entry.FullName.Split('/');
         var joined = "";
         for (var i = 0; i < split.Length; i++)
         {
             var sub  = split[i];
             var name = joined.Length == 0 ? sub : joined + '/' + sub;
             if (i == split.Length - 1)
             {
                 // File name
                 if (!_files.ContainsKey(joined))
                 {
                     _files.Add(joined, new HashSet <string>());
                 }
                 _files[joined].Add(name);
             }
             else
             {
                 // Folder name
                 if (!_folders.ContainsKey(joined))
                 {
                     _folders.Add(joined, new HashSet <string>());
                 }
                 if (!_folders[joined].Contains(sub))
                 {
                     _folders[joined].Add(name);
                 }
             }
             joined = joined.Length == 0 ? sub : joined + '/' + sub;
         }
     }
 }
Exemple #3
0
 private PakEntry GetEntry(string path)
 {
     path = path.ToLowerInvariant();
     return(_package.GetEntries().FirstOrDefault(x => x.FullName == path) as PakEntry);
 }