protected static void AddDllAndExeToList(List <InstallationPaths> pathList, InstallationPaths latestDllAndExe)
 {
     if (latestDllAndExe.ChromeDllPath != null && latestDllAndExe.ChromeExePath != null)
     {
         pathList.Add(latestDllAndExe);
     }
 }
コード例 #2
0
 protected static void AddDllAndExeToList(List <InstallationPaths> pathList, InstallationPaths latestDllAndExe)
 {
     if (latestDllAndExe.ChromeDllPath == null || latestDllAndExe.ChromeExePath == null)
     {
         return;
     }
     pathList.Add(latestDllAndExe);
 }
        protected static InstallationPaths GetLatestDllAndExe(DirectoryInfo versionsFolder, string dllName, string exeName)
        {
            if (!versionsFolder.Exists)
            {
                return(new InstallationPaths());
            }

            InstallationPaths paths = new InstallationPaths();

            List <DirectoryInfo> chromeVersions = new List <DirectoryInfo>(versionsFolder.EnumerateDirectories());

            chromeVersions = chromeVersions.OrderByDescending(dirInfo => GetUnixTime(dirInfo.LastWriteTime)).ToList();

            foreach (DirectoryInfo chromeVersion in chromeVersions)
            {
                if (chromeVersion.Name.Contains("."))
                {
                    foreach (FileInfo file in chromeVersion.EnumerateFiles())
                    {
                        if (file.Name.Equals(dllName))
                        {
                            paths.ChromeDllPath = file.FullName;
                            break;
                        }
                    }
                }
            }

            FileInfo chromeExe = new FileInfo(Path.Combine(versionsFolder.FullName, exeName));

            if (chromeExe.Exists && paths.ChromeDllPath != null)               // Every installation path also has to have a chrome.exe, otherwise the entire patcher won't work
            {
                paths.ChromeExePath = chromeExe.FullName;
                return(paths);
            }

            return(new InstallationPaths());
        }