private static string ExtractAndCheck(FirefoxProfile profile, string noFocusSoName, string libraryPath32Bit, string libraryPath64Bit) { //// 1. Extract x86/x_ignore_nofocus.so to profile.getLibsDir32bit //// 2. Extract amd64/x_ignore_nofocus.so to profile.getLibsDir64bit //// 3. Create a new LD_LIB_PATH string to contain: //// profile.getLibsDir32bit + ":" + profile.getLibsDir64bit List <string> pathsSet = new List <string>(); pathsSet.Add(libraryPath32Bit); pathsSet.Add(libraryPath64Bit); StringBuilder builtPath = new StringBuilder(); foreach (string path in pathsSet) { string outSoPath = Path.Combine(profile.ProfileDirectory, path); string file = Path.Combine(outSoPath, noFocusSoName); string resourceName = string.Format(CultureInfo.InvariantCulture, "WebDriver.FirefoxNoFocus.{0}.dll", path); if (ResourceUtilities.IsValidResourceName(resourceName)) { using (Stream libraryStream = ResourceUtilities.GetResourceStream(noFocusSoName, resourceName)) { Directory.CreateDirectory(outSoPath); using (FileStream outputStream = File.Create(file)) { byte[] buffer = new byte[1000]; int bytesRead = libraryStream.Read(buffer, 0, buffer.Length); while (bytesRead > 0) { outputStream.Write(buffer, 0, bytesRead); bytesRead = libraryStream.Read(buffer, 0, buffer.Length); } } } } if (!File.Exists(file)) { throw new WebDriverException("Could not locate " + path + ": " + "native events will not work."); } builtPath.Append(outSoPath).Append(Path.PathSeparator); } return(builtPath.ToString()); }
private static string ExtractAndCheck(FirefoxProfile profile, string noFocusSoName, string libraryPath32Bit, string libraryPath64Bit) { List <string> list = new List <string>(); list.Add(libraryPath32Bit); list.Add(libraryPath64Bit); StringBuilder stringBuilder = new StringBuilder(); foreach (string current in list) { string text = Path.Combine(profile.ProfileDirectory, current); string path = Path.Combine(text, noFocusSoName); string resourceId = string.Format(CultureInfo.InvariantCulture, "WebDriver.FirefoxNoFocus.{0}.dll", new object[] { current }); if (ResourceUtilities.IsValidResourceName(resourceId)) { using (Stream resourceStream = ResourceUtilities.GetResourceStream(noFocusSoName, resourceId)) { Directory.CreateDirectory(text); using (FileStream fileStream = File.Create(path)) { byte[] array = new byte[1000]; for (int i = resourceStream.Read(array, 0, array.Length); i > 0; i = resourceStream.Read(array, 0, array.Length)) { fileStream.Write(array, 0, i); } } } } if (!File.Exists(path)) { throw new WebDriverException("Could not locate " + current + ": native events will not work."); } stringBuilder.Append(text).Append(Path.PathSeparator); } return(stringBuilder.ToString()); }