private Version GetRVersionFromBinary(IFileSystem fs, string basePath) { string rDllPath = Path.Combine(BinPath, "R.dll"); IFileVersionInfo fvi = fs.GetVersionInfo(rDllPath); int minor, revision; GetRVersionPartsFromFileMinorVersion(fvi.FileMinorPart, out minor, out revision); return(new Version(fvi.FileMajorPart, minor, revision)); }
public Version GetRVersion(string basePath) { string rDllPath = Path.Combine(basePath, @"bin\x64\R.dll"); IFileVersionInfo fvi = _fileSystem.GetVersionInfo(rDllPath); int minor, revision; GetRVersionPartsFromFileMinorVersion(fvi.FileMinorPart, out minor, out revision); return(new Version(fvi.FileMajorPart, minor, revision)); }
public Domain(IFileSystem fileSystem, IFileVersionInfo fileVersionInfo) { _fileSystem = fileSystem; _fileVersionInfo = fileVersionInfo; }
/// <summary> /// Tries to determine R installation information. If user-specified path /// is supplied, it is used. If not, registry is used. If nothing is found /// in the registry, makes attempt to find compatible 64-bit installation /// of MRO, RRO or R (in this order) in Program Files folder /// </summary> /// <param name="basePath">Path as specified by the user settings</param> /// <returns></returns> public static RInstallData GetInstallationData( string basePath, ISupportedRVersionRange svl, ICoreShell coreShell = null) { string path = GetRInstallPath(basePath, svl, coreShell); // If nothing is found, look into the file system if (string.IsNullOrEmpty(path)) { foreach (var f in rFolders) { path = TryFindRInProgramFiles(f, svl); if (!string.IsNullOrEmpty(path)) { break; } } } // Still nothing? Fail, caller will typically display an error message. if (string.IsNullOrEmpty(path)) { return(new RInstallData() { Status = RInstallStatus.PathNotSpecified }); } // Now verify if files do exist and are of the correct version. // There may be cases when R was not fully uninstalled or when // version claimed in the registry is not what is really in files. RInstallData data = new RInstallData() { Status = RInstallStatus.OK, Path = path }; // Normalize path so it points to R root and not to bin or bin\x64 path = NormalizeRPath(path); try { string rDirectory = Path.Combine(path, @"bin\x64"); data.BinPath = rDirectory; string rDllPath = Path.Combine(rDirectory, "R.dll"); string rGraphAppPath = Path.Combine(rDirectory, "Rgraphapp.dll"); string rTermPath = Path.Combine(rDirectory, "RTerm.exe"); string rScriptPath = Path.Combine(rDirectory, "RScript.exe"); string rGuiPath = Path.Combine(rDirectory, "RGui.exe"); if (FileSystem.FileExists(rDllPath) && FileSystem.FileExists(rTermPath) && FileSystem.FileExists(rScriptPath) && FileSystem.FileExists(rGraphAppPath) && FileSystem.FileExists(rGuiPath)) { IFileVersionInfo fvi = FileSystem.GetVersionInfo(rDllPath); int minor, revision; GetRVersionPartsFromFileMinorVersion(fvi.FileMinorPart, out minor, out revision); data.Version = new Version(fvi.FileMajorPart, minor, revision); if (!svl.IsCompatibleVersion(data.Version)) { data.Status = RInstallStatus.UnsupportedVersion; } } else { data.Status = RInstallStatus.NoRBinaries; } } catch (ArgumentException aex) { data.Status = RInstallStatus.ExceptionAccessingPath; data.Exception = aex; } catch (IOException ioex) { data.Status = RInstallStatus.ExceptionAccessingPath; data.Exception = ioex; } return(data); }