Exemple #1
0
        static void RebuildLinksForFile(Decima.HZD.PrefetchList prefetchList, string fileName, CoreBinary coreBinary)
        {
            // Convert the old links to a dictionary
            var oldLinks  = new Dictionary <int, int[]>();
            int linkIndex = 0;

            for (int i = 0; i < prefetchList.Files.Count; i++)
            {
                int count = prefetchList.Links[linkIndex];

                var indices = prefetchList.Links
                              .Skip(linkIndex + 1)
                              .Take(count)
                              .ToArray();

                oldLinks.Add(i, indices);
                linkIndex += count + 1;
            }

            // Regenerate links for this specific file (don't forget to remove duplicates (Distinct()!!!))
            int getFileIndex(string path)
            {
                return(prefetchList.Files.IndexOf(prefetchList.Files.Single(x => x.Path.Value.Equals(path))));
            }

            oldLinks[getFileIndex(fileName)] = coreBinary.GetAllReferences()
                                               .Where(x => x.Type == BaseRef.Types.ExternalCoreUUID)
                                               .Select(x => getFileIndex(x.ExternalFile.Value))
                                               .Distinct()
                                               .ToArray();

            // Dictionary of links -> linear array
            prefetchList.Links.Clear();

            for (int i = 0; i < prefetchList.Files.Count; i++)
            {
                var indices = oldLinks[i];
                prefetchList.Links.Add(indices.Count());

                foreach (int index in indices)
                {
                    prefetchList.Links.Add(index);
                }
            }
        }
Exemple #2
0
 static void RebuildLinksForFile(Decima.HZD.PrefetchList prefetchList, string fileName, string physicalFilePath)
 {
     RebuildLinksForFile(prefetchList, fileName, CoreBinary.FromFile(physicalFilePath));
 }
Exemple #3
0
        static void RebuildSizesForFile(Decima.HZD.PrefetchList prefetchList, string fileName, string physicalFilePath)
        {
            int index = prefetchList.Files.IndexOf(prefetchList.Files.Single(x => x.Path.Value.Equals(fileName)));

            prefetchList.Sizes[index] = (int)(new FileInfo(physicalFilePath).Length);
        }