static Native() { if (Environment.OSVersion.Platform == PlatformID.Win32NT || Environment.OSVersion.Platform == PlatformID.Win32S || Environment.OSVersion.Platform == PlatformID.Win32Windows || Environment.OSVersion.Platform == PlatformID.WinCE) { Instance = new NativeWin32(); } else { Instance = new NativePosix(); } }
protected internal static DriveInfo GetDriveInfo(string path) { string symTarget; string driveFormat = ""; DriveInfo driveInfo; bool unix = false; driveInfo = null; if (Environment.OSVersion.Platform == PlatformID.Win32NT || Environment.OSVersion.Platform == PlatformID.Win32S || Environment.OSVersion.Platform == PlatformID.Win32Windows || Environment.OSVersion.Platform == PlatformID.WinCE) { if (path.Length != 3) { return(null); } if (path[1] != ':') { return(null); } if (!Char.IsLetter(path[0])) { return(null); } path = path.Left(2) + "\\"; } else if (Environment.OSVersion.Platform == PlatformID.Unix) { unix = true; } ActionUtils.IgnoreExceptions(() => driveInfo = new DriveInfo(path)); if (unix && driveInfo != null) { try { driveFormat = driveInfo.DriveFormat; } catch (IOException) { } } if (driveInfo == null || driveFormat == "Unknown") { if ((symTarget = Native.GetInstance().GetSymbolicLinkTarget(path)) != null) { ActionUtils.IgnoreExceptions(() => driveInfo = new DriveInfo(symTarget)); if (unix && driveInfo != null) { try { driveFormat = driveInfo.DriveFormat; } catch (IOException) { } } } } if (driveInfo == null || driveFormat == "Unknown") { return(null); } return(driveInfo); }