public Resin SelectResin(String home) { home = Util.Canonicalize(home); Resin result = null; foreach (Resin resin in _resinList) { if (home.Equals(resin.Home)) { result = resin; } } if (result == null) { result = new Resin(home); AddResin(result); } return(result); }
public void FindResin() { DriveInfo[] drives = DriveInfo.GetDrives(); foreach (DriveInfo drive in drives) { if (DriveType.Fixed != drive.DriveType && DriveType.Ram != drive.DriveType) { continue; } DirectoryInfo root = drive.RootDirectory; DirectoryInfo[] directories = root.GetDirectories(); foreach (DirectoryInfo directory in directories) { if (directory.Name.StartsWith("resin", StringComparison.CurrentCultureIgnoreCase) && Util.IsResinHome(directory.FullName)) { Resin resin = new Resin(Util.Canonicalize(directory.FullName)); if (!HasResin(resin)) { AddResin(resin); } } else if (directory.Name.Contains("appservers")) { DirectoryInfo[] appserverDirectories = directory.GetDirectories(); foreach (DirectoryInfo appserverDir in appserverDirectories) { if (Util.IsResinHome(appserverDir.FullName)) { String home = Util.Canonicalize(appserverDir.FullName); Resin resin = new Resin(home); if (!HasResin(resin)) { AddResin(resin); } } } } } } String currentResin = Util.GetCurrentResinFromRegistry(); Resin resinInRegistry = null; if (currentResin != null) { currentResin = Util.Canonicalize(currentResin); resinInRegistry = new Resin(currentResin); if (!HasResin(resinInRegistry)) { AddResin(resinInRegistry); } } RegistryKey services = Registry.LocalMachine.OpenSubKey(Setup.REG_SERVICES); foreach (String name in services.GetSubKeyNames()) { RegistryKey key = services.OpenSubKey(name); try { Object imagePathObj = key.GetValue("ImagePath"); if (imagePathObj == null && !"".Equals(imagePathObj)) { continue; } String imagePath = (String)imagePathObj; String lowerCaseImagePath = imagePath.ToLower(); if (imagePath.IndexOf("resin.exe") != -1) { ResinArgs resinArgs = new ResinArgs(imagePath); Resin resin = null; if (resinArgs.ResinHome != null) { resin = new Resin(resinArgs.ResinHome); } else if (resinArgs.Exe != null) { String exe = resinArgs.Exe; String home = exe.Substring(0, exe.Length - 10); if (Util.IsResinHome(home)) { resin = new Resin(home); } } if (resin != null && !HasResin(resin)) { AddResin(resin); } } } catch (Exception e) { LogStartupError(e.Message, e); } finally { key.Close(); } } services.Close(); String resinHome = Util.GetResinHome(null, System.Reflection.Assembly.GetExecutingAssembly().Location); foreach (Resin resin in _resinList) { if (resin.Home.Equals(resinHome)) { Resin = resin; return; } } if (Resin == null && resinInRegistry != null) { Resin = resinInRegistry; } if (Resin == null && resinHome != null) { Resin = new Resin(resinHome); AddResin(Resin); } if (Resin == null && _resinList.Count > 0) { Resin = _resinList[_resinList.Count - 1]; } }
public static void FindApache(ArrayList homes) { String apacheHome = null; apacheHome = FindApacheInRegistry(Registry.LocalMachine, REG_APACHE_2_2); if (apacheHome != null) { homes.Add(Util.GetCanonicalPath(apacheHome)); } apacheHome = FindApacheInRegistry(Registry.CurrentUser, REG_APACHE_2_2); if (apacheHome != null) { homes.Add(Util.GetCanonicalPath(apacheHome)); } apacheHome = FindApacheInRegistry(Registry.LocalMachine, REG_APACHE_2); if (apacheHome != null) { homes.Add(Util.GetCanonicalPath(apacheHome)); } apacheHome = FindApacheInRegistry(Registry.CurrentUser, REG_APACHE_2); if (apacheHome != null) { homes.Add(Util.GetCanonicalPath(apacheHome)); } String dir = Environment.GetFolderPath(Environment.SpecialFolder.ProgramFiles); FindApacheInDir(dir, homes); dir = dir + " (x86)"; if (Directory.Exists(dir)) { FindApacheInDir(dir, homes); } DriveInfo[] drives = DriveInfo.GetDrives(); foreach (DriveInfo drive in drives) { if (DriveType.Fixed != drive.DriveType && DriveType.Ram != drive.DriveType) { continue; } DirectoryInfo root = drive.RootDirectory; DirectoryInfo[] directories = root.GetDirectories(); foreach (DirectoryInfo directory in directories) { if (directory.Name.Contains("appservers")) { DirectoryInfo[] appserverDirectories = directory.GetDirectories(); foreach (DirectoryInfo appserverDir in appserverDirectories) { if (IsValidApacheHome(appserverDir.FullName)) { String home = Util.Canonicalize(appserverDir.FullName); if (!homes.Contains(home)) { homes.Add(home); } } } } } } }