/// <summary> /// Create a notification /// </summary> /// <param name="osType"></param> /// <param name="args"></param> /// <returns></returns> public static INotificationService Make(int osType, params string[] args) { OsType os = (OsType)osType; INotificationService service; switch (os) { case OsType.Ios: if (args.Length < 2) { return(null); } service = new IOSNotificationService(args[0], args[1]); break; case OsType.Android: if (args.Length < 4) { return(null); } service = new AndroidNotificationService(args[2], args[3]); break; default: service = null; break; } return(service); }
public void SetUp() { if ('/' == DSC) { OS = OsType.Unix; path1 = "/foo/test.txt"; path2 = "/etc"; path3 = "init.d"; } else if ('\\' == DSC) { OS = OsType.Windows; path1 = "c:\\foo\\test.txt"; //path2 = Environment.GetEnvironmentVariable("SYSTEMROOT"); path2 = "C:\\WINDOWS"; path3 = "system32"; } else { OS = OsType.Mac; //FIXME: For Mac. figure this out when we need it path1 = "foo:test.txt"; path2 = "foo"; path3 = "bar"; } }
private void Window_Initialized(object sender, EventArgs e) { Log.InfoFormat("SCP Driver Installer {0} [Built: {1}]", Assembly.GetExecutingAssembly().GetName().Version, AssemblyHelper.LinkerTimestamp); _installer = Difx.Instance; _installer.OnLogEvent += Logger; var info = OsInfoHelper.OsInfo; _valid = OsInfoHelper.OsParse(info); Log.InfoFormat("{0} detected", info); // get all local USB devices foreach (var usbDevice in WdiWrapper.Instance.UsbDeviceList) { BluetoothStackPanel.Children.Add(new CheckBox { Content = usbDevice }); DualShock3StackPanel.Children.Add(new CheckBox { Content = usbDevice }); DualShock4StackPanel.Children.Add(new CheckBox { Content = usbDevice }); } }
internal static IntPtr LoadLibrary(string dllLoc, OsType type, out ILibraryLoader loader) { switch (type) { case OsType.Windows32: case OsType.Windows64: loader = new WindowsLibraryLoader(); return(loader.LoadLibrary(dllLoc)); case OsType.Linux32: case OsType.Linux64: case OsType.Armv6HardFloat: case OsType.Armv7HardFloat: loader = new LinuxLibraryLoader(); return(loader.LoadLibrary(dllLoc)); case OsType.MacOs32: case OsType.MacOs64: loader = new MacOsLibraryLoader(); return(loader.LoadLibrary(dllLoc)); case OsType.RoboRio: loader = new RoboRioLibraryLoader(); return(loader.LoadLibrary(dllLoc)); case OsType.Android: loader = new AndroidLibraryLoader(); return(loader.LoadLibrary(dllLoc)); default: loader = null; return(IntPtr.Zero); } }
public void SetUp() { if ('/' == DSC) { OS = OsType.Unix; } else if ('\\' == DSC) { OS = OsType.Windows; } else { OS = OsType.Mac; //FIXME: For Mac. figure this out when we need it } files = new string [] { //resx files ".\\foo.resx", @"bar\foo.resx", "foo.fr.resx", @"dir\abc.en.resx", "foo.bar.resx", //non-resx "sample.txt", @"bar\sample.txt", "sample.it.png", @"dir\sample.en.png", "sample.inv.txt" }; Engine engine = new Engine(Consts.BinPath); project = engine.CreateNewProject(); }
internal static void GetLibraryName(OsType type, out string embeddedResourceLocation, out string extractLocation) { switch (type) { case OsType.Windows32: embeddedResourceLocation = "NetworkTables.NativeLibraries.x86.ntcore.dll"; //extractLocation = "ntcore.dll"; break; case OsType.Windows64: embeddedResourceLocation = "NetworkTables.NativeLibraries.amd64.ntcore.dll"; //extractLocation = "ntcore.dll"; break; case OsType.Linux32: embeddedResourceLocation = "NetworkTables.NativeLibraries.x86.libntcore.so"; //extractLocation = "libntcore.so"; break; case OsType.Linux64: embeddedResourceLocation = "NetworkTables.NativeLibraries.amd64.libntcore.so"; //extractLocation = "libntcore.so"; break; case OsType.MacOs32: embeddedResourceLocation = "NetworkTables.NativeLibraries.x86.libntcore.dylib"; //extractLocation = "libntcore.dylib"; break; case OsType.MacOs64: embeddedResourceLocation = "NetworkTables.NativeLibraries.amd64.libntcore.dylib"; //extractLocation = "libntcore.dylib"; break; case OsType.RoboRio: embeddedResourceLocation = "NetworkTables.NativeLibraries.roborio.libntcore.so"; //extractLocation = "libntcore.so"; break; case OsType.Armv6HardFloat: embeddedResourceLocation = "NetworkTables.NativeLibraries.armv6.libntcore.so"; //extractLocation = "libntcore.so"; break; // Android is only Arm Android. Don't currently have a way to detect otherwise. case OsType.Android: embeddedResourceLocation = "NetworkTables.NativeLibraries.android.libntcore.so"; //extractLocation = "libntcore.so"; break; case OsType.Armv7HardFloat: embeddedResourceLocation = "NetworkTables.NativeLibraries.armv7.libntcore.so"; //extractLocation = "libntcore.so"; break; default: throw new ArgumentOutOfRangeException(nameof(type), type, null); } extractLocation = Path.GetTempFileName(); }
internal static IWindowBlurController GetWindowControllerForOs(OsType osType) { switch (osType) { case OsType.WindowsVista: return(new WindowsVistaWindowBlurController()); case OsType.Windows7: return(new Windows7WindowBlurController()); case OsType.Windows8: return(new Windows8WindowBlurController()); case OsType.Windows81: return(new Windows81WindowBlurController()); case OsType.Windows10: return(new Windows10WindowBlurController()); case OsType.Other: return(new OsNotSupportedWindowBlurController()); default: return(new OsNotSupportedWindowBlurController()); } }
public AppInfo(Guid id, OsType osType, string pushToken, string authDeviceId) { Id = id; OsType = osType; PushToken = pushToken; AuthDeviceId = authDeviceId; Mute = false; }
internal static bool CheckOsValid(OsType type) { #if ARMSTANDALONE switch (type) { case OsType.Windows32: return false; case OsType.Windows64: return false; case OsType.Linux32: return false; case OsType.Linux64: return false; case OsType.MacOs32: return false; case OsType.MacOs64: return false; case OsType.Armv6HardFloat: Console.WriteLine("Raspberry Pi 1 does work, however the library will not be often updated and will probably be out of date."); return true; case OsType.Armv7HardFloat: return true; case OsType.Android: return true; //The ArmV7 binary is not working currently for android. Need to get that working. case OsType.RoboRio: return true; default: return false; } #else switch (type) { case OsType.Windows32: return true; case OsType.Windows64: return true; case OsType.Linux32: return true; case OsType.Linux64: return true; case OsType.MacOs32: return true; case OsType.MacOs64: return true; case OsType.Armv6HardFloat: return false; case OsType.Armv7HardFloat: return false; case OsType.Android: return false; //The ArmV7 binary is not working currently for android. Need to get that working. case OsType.RoboRio: return true; default: return false; } #endif }
public Service(string name, OsType osType, float hdd, float ram, float cpu, Guid?id = null) { Name = name; Os = osType; Hdd = hdd; Ram = ram; Cpu = cpu; Id = id ?? Guid.NewGuid(); }
public void SetUp () { if ('/' == DSC) { OS = OsType.Unix; } else if ('\\' == DSC) { OS = OsType.Windows; } else { OS = OsType.Mac; //FIXME: For Mac. figure this out when we need it } }
public Software(string name, string code, OsType osType, string manufacturer, string website, int yearOfFounding, int price, string description) { Name = name; Code = code; OsType = osType; Manufacturer = manufacturer; Website = website; YearOfFounding = yearOfFounding; Price = price; Description = description; }
public static bool AuthenticateDeviceVersionSupplier(string version, OsType osType) { if (osType == OsType.Android) { return(Convert.ToDouble(version) < Convert.ToDouble(Settings.GetSetting(Settings.Keys.SUPPLIER_MIN_ANDROID_VERSION))); } else { return(Convert.ToDouble(version) < Convert.ToDouble(Settings.GetSetting(Settings.Keys.SUPPLIER_MIN_IOS_VERSION))); } }
public AzureVm(string name, string resourceGroupName, string subscriptionName, string computerName, OsType osType, string privateIp, VmStatus status, List <AzureVmTag> azureVmTags) { Name = name; SubscriptionName = subscriptionName; ResourceGroupName = resourceGroupName; ComputerName = computerName; OsType = osType; PrivateIp = privateIp; Status = status; AzureVmTags = azureVmTags; }
internal static string ToSerializedValue(this OsType value) { switch (value) { case OsType.Windows: return("Windows"); case OsType.Linux: return("Linux"); } return(null); }
public Server(string name, OsType osType, float hddFull, float ramFull) { Name = name; Os = osType; HddFull = hddFull; RamFull = ramFull; _hddFree = HddFull; _ramFree = RamFull; _cpuFree = 100; IsFree = true; }
/// <summary> /// Try to load a native library directly from a path /// </summary> /// <param name="libraryName"></param> /// <returns></returns> public bool TryLoadNativeLibraryPath(string libraryName) { OsType osType = OsType; if (osType == OsType.None) { throw new InvalidOperationException( "OS type is unknown. Must use the overload to manually load the file"); } ILibraryLoader loader; switch (osType) { case OsType.Windows32: case OsType.Windows64: loader = new WindowsLibraryLoader(); libraryName = $"{libraryName}.dll"; break; case OsType.Linux32: case OsType.Linux64: loader = new LinuxLibraryLoader(); libraryName = $"lib{libraryName}.so"; break; case OsType.MacOs32: case OsType.MacOs64: loader = new MacOsLibraryLoader(); libraryName = $"lib{libraryName}.dylib"; break; case OsType.LinuxAarch64: case OsType.LinuxRaspbian: case OsType.roboRIO: loader = new EmbeddedLibraryLoader(); libraryName = $"lib{libraryName}.so"; break; default: throw new InvalidOperationException("Unknown OS type?"); } bool wasLoaded = loader.TryLoadLibrary(libraryName); if (wasLoaded) { LibraryLoader = loader; LibraryLocation = libraryName; } return(wasLoaded); }
public void GetReady () { if ('/' == DSC) { OS = OsType.Unix; } else if ('\\' == DSC) { OS = OsType.Windows; } else { OS = OsType.Mac; } _codeProvider = new VBCodeProvider (); _tempDir = CreateTempDirectory (); }
public void TestRoboRioMapsToNativeAssemblySymbols() { OsType type = NativeLibraryLoader.GetOsType(); //Only run the roboRIO symbol test on windows. if (type != OsType.Windows32 && type != OsType.Windows64) { Assert.Pass(); } var roboRIOSymbols = GetRequestedNativeSymbols(); var pathToSolution = FindRootSolutionDirectory(); var ps = Path.DirectorySeparatorChar; Assert.That(pathToSolution, Is.Not.Null); var dirToNetworkTablesLib = $"{pathToSolution}{ps}src{ps}FRC.NetworkTables.Core.DesktopLibraries"; // Start the child process. Process p = new Process(); p.StartInfo.UseShellExecute = false; p.StartInfo.RedirectStandardOutput = true; p.StartInfo.CreateNoWindow = true; p.StartInfo.FileName = $"{dirToNetworkTablesLib}\\Libraries\\frcnm.exe"; Console.WriteLine(p.StartInfo.FileName); p.StartInfo.Arguments = $"{dirToNetworkTablesLib}\\Libraries\\Linux\\arm\\libntcore.so"; p.Start(); string output = p.StandardOutput.ReadToEnd(); p.WaitForExit(); bool found = true; string[] nativeSymbols = output.Split('\r'); foreach (var halSymbol in roboRIOSymbols) { bool foundSymbol = nativeSymbols.Any(nativeSymbol => nativeSymbol.EndsWith(halSymbol)); if (!foundSymbol) { found = false; Console.WriteLine(halSymbol); } } Assert.That(found); }
private static void ResolveOsType() { if (IntPtr.Size == 8) { m_OsType = OsType.Win64; } else if (IntPtr.Size == 4) { m_OsType = OsType.Win32; } else { throw new NotSupportedException(CANNOT_RESOLVE_OS_TYPE_MESSAGE); } }
public Subject(string name, string code, Course course, string description, int numOfStudents, int minNumOfClassesPerTerm, int numOfClasses, bool projector, bool table, bool smartTable, OsType osType, List <Software> softwares) { Code = code; Name = name; Course = course; Description = description; NumOfStudents = numOfStudents; MinNumOfClassesPerTerm = minNumOfClassesPerTerm; NumOfClasses = numOfClasses; Projector = projector; Table = table; SmartTable = smartTable; OsType = osType; Softwares = softwares; }
public void SetUp() { if ('/' == DSC) { OS = OsType.Unix; } else if ('\\' == DSC) { OS = OsType.Windows; } else { OS = OsType.Mac; //FIXME: For Mac. figure this out when we need it } }
private DriverClientParameters( OsType osType, [Parameter(Value = typeof(DriverRuntimeParameters.JobId))] string jobId, [Parameter(Value = typeof(DriverRuntimeParameters.JobSubmissionDirectory))] string jobSubmissionDirectory, [Parameter(Value = typeof(DriverRuntimeParameters.DriverCpuCores))] int driverCpuCores, [Parameter(Value = typeof(DriverRuntimeParameters.DriverMemory))] int driverMemory, [Parameter(Value = typeof(DriverRuntimeParameters.GlobalAssemblies))] ISet <string> globalAssemblies, [Parameter(Value = typeof(DriverRuntimeParameters.LocalAssemblies))] ISet <string> localAssemblies, [Parameter(Value = typeof(DriverRuntimeParameters.GlobalFiles))] ISet <string> globalFiles, [Parameter(Value = typeof(DriverRuntimeParameters.LocalFiles))] ISet <string> localFiles, [Parameter(Value = typeof(DriverRuntimeParameters.EnableDriverRestart))] bool enableDriverRestart, [Parameter(Value = typeof(DriverRuntimeParameters.TcpPortRangeBegin))] int tcpPortRangeBegin, [Parameter(Value = typeof(DriverRuntimeParameters.TcpPortRangeCount))] int tcpPortRangeCount, [Parameter(Value = typeof(DriverRuntimeParameters.TcpPortRangeTryCount))] int tcpPortRangeTryCount, [Parameter(Value = typeof(DriverRuntimeParameters.RestartEvaluatorRecoverySeconds))] int restartEvaluatorRecoverySeconds) { Proto = new DriverClientConfiguration() { Jobid = jobId, DriverJobSubmissionDirectory = jobSubmissionDirectory, CpuCores = (uint)driverCpuCores, MemoryMb = (uint)driverMemory, DriverRestartEnable = enableDriverRestart, DriverRestartEvaluatorRecoverySeconds = (uint)restartEvaluatorRecoverySeconds, TcpPortRangeBegin = (uint)tcpPortRangeBegin, TcpPortRangeCount = (uint)tcpPortRangeCount, TcpPortRangeTryCount = (uint)tcpPortRangeTryCount }; Proto.GlobalLibraries.Add(globalAssemblies); Proto.GlobalFiles.Add(globalFiles); Proto.LocalLibraries.Add(localAssemblies); Proto.LocalFiles.Add(localFiles); switch (osType.Type) { case OsType.Os.Windows: Proto.OperatingSystem = DriverClientConfiguration.Types.OS.Windows; break; case OsType.Os.Linux: Proto.OperatingSystem = DriverClientConfiguration.Types.OS.Linux; break; default: throw new IllegalStateException("Unknown operating system type " + osType.Type); } }
/// <summary> /// Loads a native library using the specified file. The OS is determined automatically /// </summary> /// <typeparam name="T">The type containing the native resource, if it is embedded.</typeparam> /// <param name="location">The file location. Can be either an embedded resource, or a direct file location</param> /// <param name="directLoad">True to load the file directly from disk, otherwise false to extract from embedded</param> /// <param name="extractLocation">The location to extract to if the file is embedded. On null, it extracts to a temp file</param> public void LoadNativeLibrary <T>(string location, bool directLoad = false, string?extractLocation = null) { if (location == null) { throw new ArgumentNullException(nameof(location), "Library location cannot be null"); } OsType osType = OsType; if (osType == OsType.None) { throw new InvalidOperationException( "OS type is unknown. Must use the overload to manually load the file"); } if (!m_nativeLibraryName.ContainsKey(osType) && !directLoad) { throw new InvalidOperationException("OS Type not contained in dictionary"); } switch (osType) { case OsType.Windows32: case OsType.Windows64: LibraryLoader = new WindowsLibraryLoader(); break; case OsType.Linux32: case OsType.Linux64: LibraryLoader = new LinuxLibraryLoader(); break; case OsType.MacOs32: case OsType.MacOs64: LibraryLoader = new MacOsLibraryLoader(); break; case OsType.LinuxAarch64: case OsType.LinuxRaspbian: case OsType.roboRIO: LibraryLoader = new EmbeddedLibraryLoader(); break; } LoadNativeLibrary <T>(LibraryLoader, location, directLoad, extractLocation); }
public override int GetHashCode() { int hash = 1; if (OsType != 0) { hash ^= OsType.GetHashCode(); } if (url_ != null) { hash ^= Url.GetHashCode(); } if (_unknownFields != null) { hash ^= _unknownFields.GetHashCode(); } return(hash); }
public override int GetHashCode() { int hash = 1; if (OsType != global::Google.Ads.GoogleAds.V4.Enums.AppUrlOperatingSystemTypeEnum.Types.AppUrlOperatingSystemType.Unspecified) { hash ^= OsType.GetHashCode(); } if (url_ != null) { hash ^= Url.GetHashCode(); } if (_unknownFields != null) { hash ^= _unknownFields.GetHashCode(); } return(hash); }
public void SetAppInfo(OsType osType, string pushToken, string authDeviceId) { if (AppInfos.Any(p => p.PushToken == pushToken && p.OsType == osType)) { return; } var appInfo = AppInfos.SingleOrDefault(p => p.AuthDeviceId == authDeviceId); if (appInfo != null) { appInfo.PushToken = pushToken; appInfo.OsType = osType; } else { AppInfos.Add(new AppInfo(Guid.NewGuid(), osType, pushToken, authDeviceId)); } }
public void GetReady() { if ('/' == DSC) { OS = OsType.Unix; } else if ('\\' == DSC) { OS = OsType.Windows; } else { OS = OsType.Mac; } _codeProvider = new VBCodeProvider(); _tempDir = CreateTempDirectory(); }
internal static bool CheckOsValid(OsType type) { switch (type) { case OsType.Windows32: return true; case OsType.Windows64: return false; case OsType.Linux32: return true; case OsType.Linux64: return false; case OsType.RoboRio: return false; default: return false; } }
void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) { writer.WriteStartObject(); writer.WritePropertyName("osType"); writer.WriteStringValue(OsType.ToSerialString()); writer.WritePropertyName("osState"); writer.WriteStringValue(OsState.ToSerialString()); if (Snapshot != null) { writer.WritePropertyName("snapshot"); writer.WriteObjectValue(Snapshot); } if (ManagedDisk != null) { writer.WritePropertyName("managedDisk"); writer.WriteObjectValue(ManagedDisk); } if (BlobUri != null) { writer.WritePropertyName("blobUri"); writer.WriteStringValue(BlobUri); } if (Caching != null) { writer.WritePropertyName("caching"); writer.WriteStringValue(Caching.Value.ToSerialString()); } if (DiskSizeGB != null) { writer.WritePropertyName("diskSizeGB"); writer.WriteNumberValue(DiskSizeGB.Value); } if (StorageAccountType != null) { writer.WritePropertyName("storageAccountType"); writer.WriteStringValue(StorageAccountType.Value.ToString()); } if (DiskEncryptionSet != null) { writer.WritePropertyName("diskEncryptionSet"); writer.WriteObjectValue(DiskEncryptionSet); } writer.WriteEndObject(); }
void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) { writer.WriteStartObject(); writer.WritePropertyName("osType"); writer.WriteStringValue(OsType.ToSerialString()); writer.WritePropertyName("osState"); writer.WriteStringValue(OsState.ToSerialString()); if (Optional.IsDefined(Snapshot)) { writer.WritePropertyName("snapshot"); JsonSerializer.Serialize(writer, Snapshot); } if (Optional.IsDefined(ManagedDisk)) { writer.WritePropertyName("managedDisk"); JsonSerializer.Serialize(writer, ManagedDisk); } if (Optional.IsDefined(BlobUri)) { writer.WritePropertyName("blobUri"); writer.WriteStringValue(BlobUri); } if (Optional.IsDefined(Caching)) { writer.WritePropertyName("caching"); writer.WriteStringValue(Caching.Value.ToSerialString()); } if (Optional.IsDefined(DiskSizeGB)) { writer.WritePropertyName("diskSizeGB"); writer.WriteNumberValue(DiskSizeGB.Value); } if (Optional.IsDefined(StorageAccountType)) { writer.WritePropertyName("storageAccountType"); writer.WriteStringValue(StorageAccountType.Value.ToString()); } if (Optional.IsDefined(DiskEncryptionSet)) { writer.WritePropertyName("diskEncryptionSet"); JsonSerializer.Serialize(writer, DiskEncryptionSet); } writer.WriteEndObject(); }
public void TestRoboRioMapsToNativeAssemblySymbols() { OsType type = LoaderUtilities.GetOsType(); //Only run the roboRIO symbol test on windows. if (type != OsType.Windows32 || type != OsType.Windows64) { Assert.Pass(); } var roboRIOSymbols = GetRequestedNativeSymbols(); // Start the child process. Process p = new Process(); p.StartInfo.UseShellExecute = false; p.StartInfo.RedirectStandardOutput = true; p.StartInfo.FileName = "..\\..\\NetworkTablesCore\\NativeLibraries\\roborio\\frcnm.exe"; Console.WriteLine(p.StartInfo.FileName); p.StartInfo.Arguments = "..\\..\\NetworkTablesCore\\NativeLibraries\\roborio\\libHALAthena.so"; p.Start(); string output = p.StandardOutput.ReadToEnd(); p.WaitForExit(); bool found = true; string[] nativeSymbols = output.Split('\r'); foreach (var halSymbol in roboRIOSymbols) { bool foundSymbol = nativeSymbols.Any(nativeSymbol => nativeSymbol.EndsWith(halSymbol)); if (!foundSymbol) { found = false; Console.WriteLine(halSymbol); } } Assert.That(found); }
public void SetUp () { if ('/' == DSC) { OS = OsType.Unix; path1 = "/foo/test.txt"; path2 = "/etc"; path3 = "init.d"; } else if ('\\' == DSC) { OS = OsType.Windows; path1 = "c:\\foo\\test.txt"; path2 = Environment.GetEnvironmentVariable ("SYSTEMROOT"); path3 = "system32"; } else { OS = OsType.Mac; //FIXME: For Mac. figure this out when we need it path1 = "foo:test.txt"; path2 = "foo"; path3 = "bar"; } }
private static OsType GetOsTypeEnum() { OsType os_type = OsType.Web; #if UNITY_ANDROID Debug.Log("这里是安卓设备^_^"); os_type = OsType.Andorid; #endif #if UNITY_IPHONE Debug.Log("这里是苹果设备>_<"); os_type = OsType.Ios; #endif #if UNITY_STANDALONE_WIN Debug.Log("我是从Windows的电脑上运行的T_T"); os_type = OsType.Web; #endif return(os_type); }
public GzipHeader(string file) { using (Stream stream = new FileStream(file, FileMode.Open, FileAccess.Read, FileShare.ReadWrite)) { byte[] buffer = new byte[2048]; int read; read = stream.Read(magic, 0, 2); compressionMethod = (CompressionMethod)stream.ReadByte(); flags = (GzipHeaderFlags)stream.ReadByte(); stream.Read(fileModification, 0, 4); extraFlags = (byte)stream.ReadByte(); osType = (OsType)stream.ReadByte(); if ((flags & GzipHeaderFlags.Crc) > 0) { stream.Read(optionalPartNumber, 0, 2); } if ((flags & GzipHeaderFlags.ExtraFieldPresent) > 0) { stream.Read(optionalExtraFieldLength, 0, 2); optionalExtraField = new byte[OptionalExtraFieldLength]; stream.Read(optionalExtraField, 0, OptionalExtraFieldLength); } if ((flags & GzipHeaderFlags.OriginalFileNamePresent) > 0) { originalFileName = ReadNullTerminatedString(stream); } if ((flags & GzipHeaderFlags.FileCommentPresent) > 0) { short fullCommentSectionLen = readShort(stream); maybeEncoding = readShort(stream); short commentSectionLength = readShort(stream); fileComment = readString(stream, commentSectionLength); } if ((flags & GzipHeaderFlags.FileEncrypted) > 0) { stream.Read(encryptionHeader, 0, 12); } headerLength = stream.Position; } }
public void SetUp () { if ('/' == DSC) { OS = OsType.Unix; } else if ('\\' == DSC) { OS = OsType.Windows; } else { OS = OsType.Mac; //FIXME: For Mac. figure this out when we need it } files = new string [] { //resx files ".\\foo.resx", @"bar\foo.resx", "foo.fr.resx", @"dir\abc.en.resx", "foo.bar.resx", //non-resx "sample.txt", @"bar\sample.txt", "sample.it.png", @"dir\sample.en.png", "sample.inv.txt"}; engine = new Engine (Consts.BinPath); project = engine.CreateNewProject (); }
private void ScpForm_Load(object sender, EventArgs e) { Log.InfoFormat("SCP Driver Installer {0} [{1}]", Application.ProductVersion, DateTime.Now); _installer = Difx.Factory(); _installer.onLogEvent += Logger; var info = OsInfoHelper.OsInfo(); _valid = OsInfoHelper.OsParse(info); Log.InfoFormat("{0} detected", info); if (_valid == OsType.Invalid) { btnInstall.Enabled = false; btnUninstall.Enabled = false; Log.Error("Could not find a valid configuration"); } else { btnInstall.Enabled = true; btnUninstall.Enabled = true; Log.InfoFormat("Selected {0} configuration", _valid); } Icon = Resources.Scp_All; }
// ReSharper restore PrivateFieldCanBeConvertedToLocalVariable static Interop() { if (!s_libraryLoaded) { try { string[] commandArgs = Environment.GetCommandLineArgs(); foreach (var commandArg in commandArgs) { //search for a line with the prefix "-ntcore:" if (commandArg.ToLower().Contains("-ntcore:")) { //Split line to get the library. int splitLoc = commandArg.IndexOf(':'); string file = commandArg.Substring(splitLoc + 1); //If the file exists, just return it so dlopen can load it. if (File.Exists(file)) { s_libraryLocation = file; s_useCommandLineFile = true; } } } s_osType = LoaderUtilities.GetOsType(); if (!s_useCommandLineFile) { if (!LoaderUtilities.CheckOsValid(s_osType)) throw new InvalidOperationException("OS Not Supported"); string embeddedResourceLocation; LoaderUtilities.GetLibraryName(s_osType, out embeddedResourceLocation, out s_libraryLocation); bool successfullyExtracted = LoaderUtilities.ExtractLibrary(embeddedResourceLocation, ref s_libraryLocation); if (!successfullyExtracted) throw new FileNotFoundException( "Library file could not be found in the resorces. Please contact RobotDotNet for support for this issue"); } if (s_osType == OsType.Armv7HardFloat) { //Make sure the proper libstdc++.so.6 gets extracted. string resourceLocation = "NetworkTables.NativeLibraries.armv7.libstdc++.so"; string extractLoc = "libstdc++.so.6"; LoaderUtilities.ExtractLibrary(resourceLocation, ref extractLoc); } s_library = LoaderUtilities.LoadLibrary(s_libraryLocation, s_osType, out s_loader); if (s_library == IntPtr.Zero) { if (s_osType == OsType.Armv7HardFloat) { //We are arm v7. We might need the special libstdc++.so.6; Console.WriteLine("You are on an Arm V7 device. On most of these devices, a " + "special library needs to be loaded. This library has been extracted" + " to the current directory. Please prepend your run command with\n" + "env LD_LIBRARY_PATH=.:LD_LIBRARY_PATH yourcommand\nand run again."); throw new InvalidOperationException("Follow the instructions printed above to solve this error."); } else { throw new BadImageFormatException($"Library file {s_libraryLocation} could not be loaded successfully."); } } InitializeDelegates(s_library, s_loader); } catch (Exception e) { Console.WriteLine(e.Message); Console.WriteLine(e.StackTrace); Environment.Exit(1); } s_libraryLoaded = true; //Adds our unload code. OK to set both as only 1 //Will ever get called. AppDomain.CurrentDomain.ProcessExit += OnProcessExit; AppDomain.CurrentDomain.DomainUnload += OnProcessExit; } }
internal static IntPtr LoadLibrary(string dllLoc, OsType type, out ILibraryLoader loader) { switch (type) { case OsType.Windows32: case OsType.Windows64: loader = new WindowsLibraryLoader(); return loader.LoadLibrary(dllLoc); case OsType.Linux32: case OsType.Linux64: loader = new LinuxLibraryLoader(); return loader.LoadLibrary(dllLoc); case OsType.RoboRio: loader = new RoboRioLibraryLoader(); return loader.LoadLibrary(dllLoc); default: loader = null; return IntPtr.Zero; } }
internal static string ExtractLibrary(OsType type) { string inputName; string outputName; switch (type) { case OsType.Windows32: inputName = "HAL_Simulator.FRC_NetworkCommunication32.dll"; outputName = "FRC_NetworkCommunication.dlln"; break; case OsType.Windows64: inputName = "HAL_Simulator.FRC_NetworkCommunication64.dll"; outputName = "FRC_NetworkCommunication.dlln"; break; case OsType.Linux32: inputName = "HAL_Simulator.libFRC_NetworkCommunication32.so"; outputName = "libFRC_NetworkCommunication.so"; break; case OsType.Linux64: inputName = "HAL_Simulator.libFRC_NetworkCommunication64.so"; outputName = "libFRC_NetworkCommunication.so"; break; case OsType.RoboRio: return null; default: throw new ArgumentOutOfRangeException(nameof(type), type, null); } outputName = Path.GetTempPath() + outputName; byte[] bytes; using (Stream s = Assembly.GetExecutingAssembly().GetManifestResourceStream(inputName)) { if (s == null || s.Length == 0) return null; bytes = new byte[(int) s.Length]; s.Read(bytes, 0, (int) s.Length); } bool isFileSame = true; //If file exists if (File.Exists(outputName)) { //Load existing file into memory byte[] existingFile = File.ReadAllBytes(outputName); //If files are different length they are different, //and we can automatically assume they are different. if (existingFile.Length != bytes.Length) { isFileSame = false; } else { //Otherwise directly compare the files //I first tried hashing, but that took 1.5-2.0 seconds, //wheras this took 0.3 seconds. for (int i = 0; i < existingFile.Length; i++) { if (bytes[i] != existingFile[i]) { isFileSame = false; } } } } else { isFileSame = false; } //If file is different write the new file if (!isFileSame) { if (File.Exists(outputName)) File.Delete(outputName); File.WriteAllBytes(outputName, bytes); } //Force a garbage collection, since we just wasted about 12 MB of RAM. GC.Collect(); return outputName; }
private void ScpForm_Load(object sender, EventArgs e) { Log.InfoFormat("SCP Driver Installer {0} [{1}]", Application.ProductVersion, DateTime.Now); _installer = Difx.Instance; _installer.OnLogEvent += Logger; var info = OsInfoHelper.OsInfo; _valid = OsInfoHelper.OsParse(info); Log.InfoFormat("{0} detected", info); if (_valid == OsType.Invalid) { btnInstall.Enabled = false; btnUninstall.Enabled = false; Log.Error("Could not find a valid configuration"); } else { btnInstall.Enabled = true; btnUninstall.Enabled = true; Log.InfoFormat("Selected {0} configuration", _valid); } Icon = Resources.Scp_All; if (!OsInfoHelper.IsVc2013Installed) { MessageBox.Show(Resources.ScpForm_VcppMissingText, Resources.ScpForm_VcppMissingHead, MessageBoxButtons.OK, MessageBoxIcon.Error); Close(); } }
private void Window_Initialized(object sender, EventArgs e) { Log.InfoFormat("SCP Driver Installer {0} [Built: {1}]", Assembly.GetExecutingAssembly().GetName().Version, AssemblyHelper.LinkerTimestamp); _installer = Difx.Instance; _installer.OnLogEvent += Logger; var info = OsInfoHelper.OsInfo; _valid = OsInfoHelper.OsParse(info); Log.InfoFormat("{0} detected", info); // is MSVC already installed? _viewModel.InstallMsvc2010Redist = !OsInfoHelper.IsVc2010Installed; _viewModel.InstallMsvc2013Redist = !OsInfoHelper.IsVc2013Installed; // unblock system files foreach (var fInfo in Directory.GetFiles(WorkingDirectory, "*.*", SearchOption.AllDirectories) .Where(s => s.EndsWith(".dll") || s.EndsWith(".inf") || s.EndsWith(".sys") || s.EndsWith(".cat")) .Select(file => new FileInfo(file)) .Where(fInfo => fInfo.Unblock())) { Log.InfoFormat("Unblocked file {0}", fInfo.Name); } }
private void Window_Initialized(object sender, EventArgs e) { Log.InfoFormat("SCP Driver Installer {0} [Built: {1}]", Assembly.GetExecutingAssembly().GetName().Version, AssemblyHelper.LinkerTimestamp); _installer = Difx.Instance; _installer.OnLogEvent += Logger; var info = OsInfoHelper.OsInfo; _valid = OsInfoHelper.OsParse(info); Log.InfoFormat("{0} detected", info); // is MSVC already installed? _viewModel.InstallMsvc2010Redist = !OsInfoHelper.IsVc2010Installed; _viewModel.InstallMsvc2013Redist = !OsInfoHelper.IsVc2013Installed; // unblock system files foreach (var fInfo in Directory.GetFiles(GlobalConfiguration.AppDirectory, "*.*", SearchOption.AllDirectories) .Where(s => s.EndsWith(".dll") || s.EndsWith(".inf") || s.EndsWith(".sys") || s.EndsWith(".cat")) .Select(file => new FileInfo(file)) .Where(fInfo => fInfo.Unblock())) { Log.InfoFormat("Unblocked file {0}", fInfo.Name); } // get all local USB devices foreach (var usbDevice in WdiWrapper.Instance.UsbDeviceList) { BluetoothStackPanel.Children.Add(new CheckBox { Content = usbDevice }); DualShock3StackPanel.Children.Add(new CheckBox { Content = usbDevice }); DualShock4StackPanel.Children.Add(new CheckBox { Content = usbDevice }); } }