mirror of
https://github.com/claunia/marechai.git
synced 2025-12-16 19:14:25 +00:00
Added banner.
This commit is contained in:
308
cicm_web/Interop/DetectOS.cs
Normal file
308
cicm_web/Interop/DetectOS.cs
Normal file
@@ -0,0 +1,308 @@
|
|||||||
|
// /***************************************************************************
|
||||||
|
// The Disc Image Chef
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
//
|
||||||
|
// Filename : DetectOS.cs
|
||||||
|
// Author(s) : Natalia Portillo <claunia@claunia.com>
|
||||||
|
//
|
||||||
|
// Component : Interop services.
|
||||||
|
//
|
||||||
|
// --[ Description ] ----------------------------------------------------------
|
||||||
|
//
|
||||||
|
// Detects underlying operating system.
|
||||||
|
//
|
||||||
|
// --[ License ] --------------------------------------------------------------
|
||||||
|
//
|
||||||
|
// Permission is hereby granted, free of charge, to any person obtaining a
|
||||||
|
// copy of this software and associated documentation files (the
|
||||||
|
// "Software"), to deal in the Software without restriction, including
|
||||||
|
// without limitation the rights to use, copy, modify, merge, publish,
|
||||||
|
// distribute, sublicense, and/or sell copies of the Software, and to
|
||||||
|
// permit persons to whom the Software is furnished to do so, subject to
|
||||||
|
// the following conditions:
|
||||||
|
//
|
||||||
|
// The above copyright notice and this permission notice shall be included
|
||||||
|
// in all copies or substantial portions of the Software.
|
||||||
|
//
|
||||||
|
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||||
|
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||||
|
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||||
|
// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
||||||
|
// CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
||||||
|
// TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
||||||
|
// SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
//
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
// Copyright © 2011-2018 Natalia Portillo
|
||||||
|
// ****************************************************************************/
|
||||||
|
|
||||||
|
using System;
|
||||||
|
using System.Diagnostics;
|
||||||
|
using System.IO;
|
||||||
|
using System.Runtime.InteropServices;
|
||||||
|
|
||||||
|
namespace DiscImageChef.Interop
|
||||||
|
{
|
||||||
|
public static class DetectOS
|
||||||
|
{
|
||||||
|
public static readonly bool IsMono = Type.GetType("Mono.Runtime") != null;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Checks if the underlying runtime runs in 64-bit mode
|
||||||
|
/// </summary>
|
||||||
|
public static readonly bool Is64Bit = IntPtr.Size == 8;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Checks if the underlying runtime runs in 32-bit mode
|
||||||
|
/// </summary>
|
||||||
|
public static readonly bool Is32Bit = IntPtr.Size == 4;
|
||||||
|
|
||||||
|
[DllImport("libc", SetLastError = true)]
|
||||||
|
static extern int uname(out utsname name);
|
||||||
|
|
||||||
|
[DllImport("libc", SetLastError = true, EntryPoint = "sysctlbyname", CharSet = CharSet.Ansi)]
|
||||||
|
static extern int OSX_sysctlbyname(string name, IntPtr oldp, IntPtr oldlenp, IntPtr newp, uint newlen);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets the real platform ID, not the incomplete .NET framework one
|
||||||
|
/// </summary>
|
||||||
|
/// <returns>Platform ID</returns>
|
||||||
|
/// <exception cref="Exception">Unhandled exception</exception>
|
||||||
|
public static PlatformID GetRealPlatformID()
|
||||||
|
{
|
||||||
|
if((int)Environment.OSVersion.Platform < 4 || (int)Environment.OSVersion.Platform == 5)
|
||||||
|
return (PlatformID)(int)Environment.OSVersion.Platform;
|
||||||
|
|
||||||
|
int error = uname(out utsname unixname);
|
||||||
|
if(error != 0) throw new Exception($"Unhandled exception calling uname: {Marshal.GetLastWin32Error()}");
|
||||||
|
|
||||||
|
switch(unixname.sysname)
|
||||||
|
{
|
||||||
|
// TODO: Differentiate Linux, Android, Tizen
|
||||||
|
case "Linux":
|
||||||
|
{
|
||||||
|
#if __ANDROID__
|
||||||
|
return PlatformID.Android;
|
||||||
|
#else
|
||||||
|
return PlatformID.Linux;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
case "Darwin":
|
||||||
|
{
|
||||||
|
int osxError;
|
||||||
|
|
||||||
|
IntPtr pLen = Marshal.AllocHGlobal(sizeof(int));
|
||||||
|
osxError = OSX_sysctlbyname("hw.machine", IntPtr.Zero, pLen, IntPtr.Zero, 0);
|
||||||
|
if(osxError != 0)
|
||||||
|
{
|
||||||
|
Marshal.FreeHGlobal(pLen);
|
||||||
|
|
||||||
|
throw new Exception($"Unhandled exception calling uname: {Marshal.GetLastWin32Error()}");
|
||||||
|
}
|
||||||
|
|
||||||
|
int length = Marshal.ReadInt32(pLen);
|
||||||
|
IntPtr pStr = Marshal.AllocHGlobal(length);
|
||||||
|
osxError = OSX_sysctlbyname("hw.machine", pStr, pLen, IntPtr.Zero, 0);
|
||||||
|
if(osxError != 0)
|
||||||
|
{
|
||||||
|
Marshal.FreeHGlobal(pStr);
|
||||||
|
Marshal.FreeHGlobal(pLen);
|
||||||
|
|
||||||
|
throw new Exception($"Unhandled exception calling uname: {Marshal.GetLastWin32Error()}");
|
||||||
|
}
|
||||||
|
|
||||||
|
string machine = Marshal.PtrToStringAnsi(pStr);
|
||||||
|
|
||||||
|
Marshal.FreeHGlobal(pStr);
|
||||||
|
Marshal.FreeHGlobal(pLen);
|
||||||
|
|
||||||
|
if(machine != null && (machine.StartsWith("iPad", StringComparison.Ordinal) ||
|
||||||
|
machine.StartsWith("iPod", StringComparison.Ordinal) ||
|
||||||
|
machine.StartsWith("iPhone", StringComparison.Ordinal)))
|
||||||
|
return PlatformID.iOS;
|
||||||
|
|
||||||
|
return PlatformID.MacOSX;
|
||||||
|
}
|
||||||
|
case "GNU": return PlatformID.Hurd;
|
||||||
|
case "FreeBSD":
|
||||||
|
case "GNU/kFreeBSD": return PlatformID.FreeBSD;
|
||||||
|
case "DragonFly": return PlatformID.DragonFly;
|
||||||
|
case "Haiku": return PlatformID.Haiku;
|
||||||
|
case "HP-UX": return PlatformID.HPUX;
|
||||||
|
case "AIX": return PlatformID.AIX;
|
||||||
|
case "OS400": return PlatformID.OS400;
|
||||||
|
case "IRIX":
|
||||||
|
case "IRIX64": return PlatformID.IRIX;
|
||||||
|
case "Minix": return PlatformID.Minix;
|
||||||
|
case "NetBSD": return PlatformID.NetBSD;
|
||||||
|
case "NONSTOP_KERNEL": return PlatformID.NonStop;
|
||||||
|
case "OpenBSD": return PlatformID.OpenBSD;
|
||||||
|
case "QNX": return PlatformID.QNX;
|
||||||
|
case "SINIX-Y": return PlatformID.SINIX;
|
||||||
|
case "SunOS": return PlatformID.Solaris;
|
||||||
|
case "OSF1": return PlatformID.Tru64;
|
||||||
|
case "ULTRIX": return PlatformID.Ultrix;
|
||||||
|
case "SCO_SV": return PlatformID.OpenServer;
|
||||||
|
case "UnixWare": return PlatformID.UnixWare;
|
||||||
|
case "Interix":
|
||||||
|
case "UWIN-W7": return PlatformID.Win32NT;
|
||||||
|
default:
|
||||||
|
{
|
||||||
|
if(unixname.sysname.StartsWith("CYGWIN_NT", StringComparison.Ordinal) ||
|
||||||
|
unixname.sysname.StartsWith("MINGW32_NT", StringComparison.Ordinal) ||
|
||||||
|
unixname.sysname.StartsWith("MSYS_NT", StringComparison.Ordinal) ||
|
||||||
|
unixname.sysname.StartsWith("UWIN", StringComparison.Ordinal)) return PlatformID.Win32NT;
|
||||||
|
|
||||||
|
return PlatformID.Unknown;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets a string for the current operating system REAL version (handles Darwin 1.4 and Windows 10 falsifying)
|
||||||
|
/// </summary>
|
||||||
|
/// <returns>Current operating system version</returns>
|
||||||
|
public static string GetVersion()
|
||||||
|
{
|
||||||
|
string environ = Environment.OSVersion.Version.ToString();
|
||||||
|
|
||||||
|
switch(GetRealPlatformID())
|
||||||
|
{
|
||||||
|
case PlatformID.MacOSX:
|
||||||
|
if(Environment.OSVersion.Version.Major != 1)
|
||||||
|
return $"10.{Environment.OSVersion.Version.Major - 4}.{Environment.OSVersion.Version.Minor}";
|
||||||
|
|
||||||
|
switch(Environment.OSVersion.Version.Minor)
|
||||||
|
{
|
||||||
|
case 3: return "10.0";
|
||||||
|
case 4: return "10.1";
|
||||||
|
}
|
||||||
|
|
||||||
|
goto default;
|
||||||
|
case PlatformID.Win32NT:
|
||||||
|
// From Windows 8.1 the reported version is simply falsified...
|
||||||
|
if(Environment.OSVersion.Version.Major == 6 && Environment.OSVersion.Version.Major >= 2 ||
|
||||||
|
Environment.OSVersion.Version.Major > 6)
|
||||||
|
return FileVersionInfo
|
||||||
|
.GetVersionInfo(Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.System),
|
||||||
|
"KERNEL32.DLL")).ProductVersion;
|
||||||
|
|
||||||
|
return environ;
|
||||||
|
default: return environ;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// From a platform ID and version returns a human-readable version
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="id">Platform ID</param>
|
||||||
|
/// <param name="version">Version number</param>
|
||||||
|
/// <returns>Operating system name</returns>
|
||||||
|
public static string GetPlatformName(PlatformID id, string version = null)
|
||||||
|
{
|
||||||
|
switch(id)
|
||||||
|
{
|
||||||
|
case PlatformID.AIX: return "AIX";
|
||||||
|
case PlatformID.Android: return "Android";
|
||||||
|
case PlatformID.DragonFly: return "DragonFly BSD";
|
||||||
|
case PlatformID.FreeBSD: return "FreeBSD";
|
||||||
|
case PlatformID.Haiku: return "Haiku";
|
||||||
|
case PlatformID.HPUX: return "HP/UX";
|
||||||
|
case PlatformID.Hurd: return "Hurd";
|
||||||
|
case PlatformID.iOS: return "iOS";
|
||||||
|
case PlatformID.IRIX: return "IRIX";
|
||||||
|
case PlatformID.Linux: return "Linux";
|
||||||
|
case PlatformID.MacOSX:
|
||||||
|
if(string.IsNullOrEmpty(version)) return "macOS";
|
||||||
|
|
||||||
|
string[] pieces = version.Split('.');
|
||||||
|
if(pieces.Length < 2 || !int.TryParse(pieces[1], out int minor)) return "macOS";
|
||||||
|
|
||||||
|
if(minor >= 12) return "macOS";
|
||||||
|
if(minor >= 8) return "OS X";
|
||||||
|
|
||||||
|
return "Mac OS X";
|
||||||
|
|
||||||
|
case PlatformID.Minix: return "MINIX";
|
||||||
|
case PlatformID.NetBSD: return "NetBSD";
|
||||||
|
case PlatformID.NonStop: return "NonStop OS";
|
||||||
|
case PlatformID.OpenBSD: return "OpenBSD";
|
||||||
|
case PlatformID.OpenServer: return "SCO OpenServer";
|
||||||
|
case PlatformID.OS400: return "OS/400";
|
||||||
|
case PlatformID.PlayStation3: return "Sony CellOS";
|
||||||
|
case PlatformID.PlayStation4: return "Sony Orbis OS";
|
||||||
|
case PlatformID.QNX: return "QNX";
|
||||||
|
case PlatformID.SINIX: return "SINIX";
|
||||||
|
case PlatformID.Solaris: return "Sun Solaris";
|
||||||
|
case PlatformID.Tizen: return "Samsung Tizen";
|
||||||
|
case PlatformID.Tru64: return "Tru64 UNIX";
|
||||||
|
case PlatformID.Ultrix: return "Ultrix";
|
||||||
|
case PlatformID.Unix: return "UNIX";
|
||||||
|
case PlatformID.UnixWare: return "SCO UnixWare";
|
||||||
|
case PlatformID.Wii: return "Nintendo Wii";
|
||||||
|
case PlatformID.WiiU: return "Nintendo Wii U";
|
||||||
|
case PlatformID.Win32NT:
|
||||||
|
if(string.IsNullOrEmpty(version)) return "Windows NT/2000/XP/Vista/7/10";
|
||||||
|
if(version.StartsWith("3.", StringComparison.Ordinal) ||
|
||||||
|
version.StartsWith("4.", StringComparison.Ordinal)) return "Windows NT";
|
||||||
|
if(version.StartsWith("5.0", StringComparison.Ordinal)) return "Windows 2000";
|
||||||
|
if(version.StartsWith("5.1", StringComparison.Ordinal)) return "Windows XP";
|
||||||
|
if(version.StartsWith("5.2", StringComparison.Ordinal)) return "Windows 2003";
|
||||||
|
if(version.StartsWith("6.0", StringComparison.Ordinal)) return "Windows Vista";
|
||||||
|
if(version.StartsWith("6.1", StringComparison.Ordinal)) return "Windows 7";
|
||||||
|
if(version.StartsWith("6.2", StringComparison.Ordinal)) return "Windows 8";
|
||||||
|
if(version.StartsWith("6.3", StringComparison.Ordinal)) return "Windows 8.1";
|
||||||
|
if(version.StartsWith("10.0", StringComparison.Ordinal)) return "Windows 10";
|
||||||
|
|
||||||
|
return "Windows NT/2000/XP/Vista/7/10";
|
||||||
|
case PlatformID.Win32S: return "Windows 3.x with win32s";
|
||||||
|
case PlatformID.Win32Windows:
|
||||||
|
if(string.IsNullOrEmpty(version)) return "Windows 9x/Me";
|
||||||
|
if(version.StartsWith("4.0", StringComparison.Ordinal)) return "Windows 95";
|
||||||
|
if(version.StartsWith("4.10.2222", StringComparison.Ordinal)) return "Windows 98 SE";
|
||||||
|
if(version.StartsWith("4.1", StringComparison.Ordinal)) return "Windows 98";
|
||||||
|
if(version.StartsWith("4.9", StringComparison.Ordinal)) return "Windows Me";
|
||||||
|
|
||||||
|
return "Windows 9x/Me";
|
||||||
|
case PlatformID.WinCE: return "Windows CE/Mobile";
|
||||||
|
case PlatformID.WindowsPhone: return "Windows Phone";
|
||||||
|
case PlatformID.Xbox: return "Xbox OS";
|
||||||
|
case PlatformID.zOS: return "z/OS";
|
||||||
|
default: return id.ToString();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// POSIX uname structure, size from OSX, big enough to handle extra fields
|
||||||
|
/// </summary>
|
||||||
|
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)]
|
||||||
|
struct utsname
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// System name
|
||||||
|
/// </summary>
|
||||||
|
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 256)]
|
||||||
|
public string sysname;
|
||||||
|
/// <summary>
|
||||||
|
/// Node name
|
||||||
|
/// </summary>
|
||||||
|
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 256)]
|
||||||
|
public string nodename;
|
||||||
|
/// <summary>
|
||||||
|
/// Release level
|
||||||
|
/// </summary>
|
||||||
|
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 256)]
|
||||||
|
public string release;
|
||||||
|
/// <summary>
|
||||||
|
/// Version level
|
||||||
|
/// </summary>
|
||||||
|
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 256)]
|
||||||
|
public string version;
|
||||||
|
/// <summary>
|
||||||
|
/// Hardware level
|
||||||
|
/// </summary>
|
||||||
|
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 256)]
|
||||||
|
public string machine;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
192
cicm_web/Interop/PlatformID.cs
Normal file
192
cicm_web/Interop/PlatformID.cs
Normal file
@@ -0,0 +1,192 @@
|
|||||||
|
// /***************************************************************************
|
||||||
|
// The Disc Image Chef
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
//
|
||||||
|
// Filename : PlatformID.cs
|
||||||
|
// Author(s) : Natalia Portillo <claunia@claunia.com>
|
||||||
|
//
|
||||||
|
// Component : Interop services.
|
||||||
|
//
|
||||||
|
// --[ Description ] ----------------------------------------------------------
|
||||||
|
//
|
||||||
|
// Contains an enhanced PlatformID enumeration.
|
||||||
|
//
|
||||||
|
// --[ License ] --------------------------------------------------------------
|
||||||
|
//
|
||||||
|
// Permission is hereby granted, free of charge, to any person obtaining a
|
||||||
|
// copy of this software and associated documentation files (the
|
||||||
|
// "Software"), to deal in the Software without restriction, including
|
||||||
|
// without limitation the rights to use, copy, modify, merge, publish,
|
||||||
|
// distribute, sublicense, and/or sell copies of the Software, and to
|
||||||
|
// permit persons to whom the Software is furnished to do so, subject to
|
||||||
|
// the following conditions:
|
||||||
|
//
|
||||||
|
// The above copyright notice and this permission notice shall be included
|
||||||
|
// in all copies or substantial portions of the Software.
|
||||||
|
//
|
||||||
|
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||||
|
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||||
|
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||||
|
// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
||||||
|
// CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
||||||
|
// TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
||||||
|
// SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
//
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
// Copyright © 2011-2018 Natalia Portillo
|
||||||
|
// ****************************************************************************/
|
||||||
|
|
||||||
|
namespace DiscImageChef.Interop
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Contains an arbitrary list of OSes, even if .NET does not run on them
|
||||||
|
/// </summary>
|
||||||
|
public enum PlatformID
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Win32s
|
||||||
|
/// </summary>
|
||||||
|
Win32S = 0,
|
||||||
|
/// <summary>
|
||||||
|
/// Win32 (Windows 9x)
|
||||||
|
/// </summary>
|
||||||
|
Win32Windows = 1,
|
||||||
|
/// <summary>
|
||||||
|
/// Windows NT
|
||||||
|
/// </summary>
|
||||||
|
Win32NT = 2,
|
||||||
|
/// <summary>
|
||||||
|
/// Windows Mobile
|
||||||
|
/// </summary>
|
||||||
|
WinCE = 3,
|
||||||
|
/// <summary>
|
||||||
|
/// UNIX (do not use, too generic)
|
||||||
|
/// </summary>
|
||||||
|
Unix = 4,
|
||||||
|
/// <summary>
|
||||||
|
/// Xbox 360
|
||||||
|
/// </summary>
|
||||||
|
Xbox = 5,
|
||||||
|
/// <summary>
|
||||||
|
/// OS X
|
||||||
|
/// </summary>
|
||||||
|
MacOSX = 6,
|
||||||
|
/// <summary>
|
||||||
|
/// iOS is not OS X
|
||||||
|
/// </summary>
|
||||||
|
iOS = 7,
|
||||||
|
/// <summary>
|
||||||
|
/// Linux
|
||||||
|
/// </summary>
|
||||||
|
Linux = 8,
|
||||||
|
/// <summary>
|
||||||
|
/// Sun Solaris
|
||||||
|
/// </summary>
|
||||||
|
Solaris = 9,
|
||||||
|
/// <summary>
|
||||||
|
/// NetBSD
|
||||||
|
/// </summary>
|
||||||
|
NetBSD = 10,
|
||||||
|
/// <summary>
|
||||||
|
/// OpenBSD
|
||||||
|
/// </summary>
|
||||||
|
OpenBSD = 11,
|
||||||
|
/// <summary>
|
||||||
|
/// FreeBSD
|
||||||
|
/// </summary>
|
||||||
|
FreeBSD = 12,
|
||||||
|
/// <summary>
|
||||||
|
/// DragonFly BSD
|
||||||
|
/// </summary>
|
||||||
|
DragonFly = 13,
|
||||||
|
/// <summary>
|
||||||
|
/// Nintendo Wii
|
||||||
|
/// </summary>
|
||||||
|
Wii = 14,
|
||||||
|
/// <summary>
|
||||||
|
/// Nintendo Wii U
|
||||||
|
/// </summary>
|
||||||
|
WiiU = 15,
|
||||||
|
/// <summary>
|
||||||
|
/// Sony PlayStation 3
|
||||||
|
/// </summary>
|
||||||
|
PlayStation3 = 16,
|
||||||
|
/// <summary>
|
||||||
|
/// Sony Playstation 4
|
||||||
|
/// </summary>
|
||||||
|
PlayStation4 = 17,
|
||||||
|
/// <summary>
|
||||||
|
/// Google Android
|
||||||
|
/// </summary>
|
||||||
|
Android = 18,
|
||||||
|
/// <summary>
|
||||||
|
/// Samsung Tizen
|
||||||
|
/// </summary>
|
||||||
|
Tizen = 19,
|
||||||
|
/// <summary>
|
||||||
|
/// Windows Phone
|
||||||
|
/// </summary>
|
||||||
|
WindowsPhone = 20,
|
||||||
|
/// <summary>
|
||||||
|
/// GNU/Hurd
|
||||||
|
/// </summary>
|
||||||
|
Hurd = 21,
|
||||||
|
/// <summary>
|
||||||
|
/// Haiku
|
||||||
|
/// </summary>
|
||||||
|
Haiku = 22,
|
||||||
|
/// <summary>
|
||||||
|
/// HP-UX
|
||||||
|
/// </summary>
|
||||||
|
HPUX = 23,
|
||||||
|
/// <summary>
|
||||||
|
/// AIX
|
||||||
|
/// </summary>
|
||||||
|
AIX = 24,
|
||||||
|
/// <summary>
|
||||||
|
/// OS/400
|
||||||
|
/// </summary>
|
||||||
|
OS400 = 25,
|
||||||
|
/// <summary>
|
||||||
|
/// IRIX
|
||||||
|
/// </summary>
|
||||||
|
IRIX = 26,
|
||||||
|
/// <summary>
|
||||||
|
/// Minix
|
||||||
|
/// </summary>
|
||||||
|
Minix = 27,
|
||||||
|
/// <summary>
|
||||||
|
/// NonStop
|
||||||
|
/// </summary>
|
||||||
|
NonStop = 28,
|
||||||
|
/// <summary>
|
||||||
|
/// QNX
|
||||||
|
/// </summary>
|
||||||
|
QNX = 29,
|
||||||
|
/// <summary>
|
||||||
|
/// SINIX
|
||||||
|
/// </summary>
|
||||||
|
SINIX = 30,
|
||||||
|
/// <summary>
|
||||||
|
/// Tru64 UNIX
|
||||||
|
/// </summary>
|
||||||
|
Tru64 = 31,
|
||||||
|
/// <summary>
|
||||||
|
/// Ultrix
|
||||||
|
/// </summary>
|
||||||
|
Ultrix = 32,
|
||||||
|
/// <summary>
|
||||||
|
/// SCO OpenServer / SCO UNIX
|
||||||
|
/// </summary>
|
||||||
|
OpenServer = 33,
|
||||||
|
/// <summary>
|
||||||
|
/// SCO UnixWare
|
||||||
|
/// </summary>
|
||||||
|
UnixWare = 34,
|
||||||
|
/// <summary>
|
||||||
|
/// IBM z/OS
|
||||||
|
/// </summary>
|
||||||
|
zOS = 35,
|
||||||
|
Unknown = -1
|
||||||
|
}
|
||||||
|
}
|
||||||
79
cicm_web/Interop/Version.cs
Normal file
79
cicm_web/Interop/Version.cs
Normal file
@@ -0,0 +1,79 @@
|
|||||||
|
// /***************************************************************************
|
||||||
|
// The Disc Image Chef
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
//
|
||||||
|
// Filename : Version.cs
|
||||||
|
// Author(s) : Natalia Portillo <claunia@claunia.com>
|
||||||
|
//
|
||||||
|
// Component : Interop services.
|
||||||
|
//
|
||||||
|
// --[ Description ] ----------------------------------------------------------
|
||||||
|
//
|
||||||
|
// Returns DiscImageChef version.
|
||||||
|
//
|
||||||
|
// --[ License ] --------------------------------------------------------------
|
||||||
|
//
|
||||||
|
// Permission is hereby granted, free of charge, to any person obtaining a
|
||||||
|
// copy of this software and associated documentation files (the
|
||||||
|
// "Software"), to deal in the Software without restriction, including
|
||||||
|
// without limitation the rights to use, copy, modify, merge, publish,
|
||||||
|
// distribute, sublicense, and/or sell copies of the Software, and to
|
||||||
|
// permit persons to whom the Software is furnished to do so, subject to
|
||||||
|
// the following conditions:
|
||||||
|
//
|
||||||
|
// The above copyright notice and this permission notice shall be included
|
||||||
|
// in all copies or substantial portions of the Software.
|
||||||
|
//
|
||||||
|
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||||
|
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||||
|
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||||
|
// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
||||||
|
// CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
||||||
|
// TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
||||||
|
// SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
//
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
// Copyright © 2011-2018 Natalia Portillo
|
||||||
|
// ****************************************************************************/
|
||||||
|
|
||||||
|
using System;
|
||||||
|
using System.Reflection;
|
||||||
|
using System.Runtime;
|
||||||
|
|
||||||
|
namespace DiscImageChef.Interop
|
||||||
|
{
|
||||||
|
public static class Version
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Gets version string
|
||||||
|
/// </summary>
|
||||||
|
/// <returns>Version</returns>
|
||||||
|
public static string GetVersion()
|
||||||
|
{
|
||||||
|
return typeof(Version).Assembly.GetName().Version.ToString();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static string GetNetCoreVersion()
|
||||||
|
{
|
||||||
|
Assembly assembly = typeof(GCSettings).Assembly;
|
||||||
|
string[] assemblyPath =
|
||||||
|
assembly.CodeBase.Split(new[] {'/', '\\'}, StringSplitOptions.RemoveEmptyEntries);
|
||||||
|
int netCoreAppIndex = Array.IndexOf(assemblyPath, "Microsoft.NETCore.App");
|
||||||
|
if(netCoreAppIndex > 0 && netCoreAppIndex < assemblyPath.Length - 2)
|
||||||
|
return assemblyPath[netCoreAppIndex + 1];
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static string GetMonoVersion()
|
||||||
|
{
|
||||||
|
if(!DetectOS.IsMono) return null;
|
||||||
|
|
||||||
|
MethodInfo monoDisplayName = Type.GetType("Mono.Runtime")
|
||||||
|
?.GetMethod("GetDisplayName", BindingFlags.NonPublic | BindingFlags.Static);
|
||||||
|
if(monoDisplayName != null) return (string)monoDisplayName.Invoke(null, null);
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -28,8 +28,11 @@
|
|||||||
// Copyright © 2003-2018 Natalia Portillo
|
// Copyright © 2003-2018 Natalia Portillo
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
|
|
||||||
|
using System;
|
||||||
|
using DiscImageChef.Interop;
|
||||||
using Microsoft.AspNetCore;
|
using Microsoft.AspNetCore;
|
||||||
using Microsoft.AspNetCore.Hosting;
|
using Microsoft.AspNetCore.Hosting;
|
||||||
|
using Version = DiscImageChef.Interop.Version;
|
||||||
|
|
||||||
namespace cicm_web
|
namespace cicm_web
|
||||||
{
|
{
|
||||||
@@ -37,6 +40,71 @@ namespace cicm_web
|
|||||||
{
|
{
|
||||||
public static void Main(string[] args)
|
public static void Main(string[] args)
|
||||||
{
|
{
|
||||||
|
Console.Clear();
|
||||||
|
|
||||||
|
Console.Write(
|
||||||
|
"\u001b[32m . ,,\n" +
|
||||||
|
"\u001b[32m ;,. '0d.\n" +
|
||||||
|
"\u001b[32m oc oWd \u001b[31m" +
|
||||||
|
@"________/\\\\\\\\\___/\\\\\\\\\\\_________/\\\\\\\\\___/\\\\____________/\\\\_" +
|
||||||
|
"\n\u001b[0m" +
|
||||||
|
"\u001b[32m ;X. 'WN' \u001b[31m" +
|
||||||
|
@" _____/\\\////////___\/////\\\///_______/\\\////////___\/\\\\\\________/\\\\\\_" +
|
||||||
|
"\n\u001b[0m" +
|
||||||
|
"\u001b[32m oMo cMM: \u001b[31m" +
|
||||||
|
@" ___/\\\/________________\/\\\________/\\\/____________\/\\\//\\\____/\\\//\\\_" +
|
||||||
|
"\n\u001b[0m" +
|
||||||
|
"\u001b[32m ;MM. .MMM; \u001b[31m" +
|
||||||
|
@" __/\\\__________________\/\\\_______/\\\______________\/\\\\///\\\/\\\/_\/\\\_" +
|
||||||
|
"\n\u001b[0m" +
|
||||||
|
"\u001b[32m NMM WMMW \u001b[31m" +
|
||||||
|
@" _\/\\\__________________\/\\\______\/\\\______________\/\\\__\///\\\/___\/\\\_" +
|
||||||
|
"\n\u001b[0m" +
|
||||||
|
"\u001b[32m 'MMM MMMM; \u001b[31m" +
|
||||||
|
@" _\//\\\_________________\/\\\______\//\\\_____________\/\\\____\///_____\/\\\_" +
|
||||||
|
"\n\u001b[0m" +
|
||||||
|
"\u001b[32m ,MMM: dMMMM: \u001b[31m" +
|
||||||
|
@" __\///\\\_______________\/\\\_______\///\\\___________\/\\\_____________\/\\\_" +
|
||||||
|
"\n\u001b[0m" +
|
||||||
|
"\u001b[32m .MMMW. :MMMMM. \u001b[31m" +
|
||||||
|
@" ____\////\\\\\\\\\___/\\\\\\\\\\\_____\////\\\\\\\\\__\/\\\_____________\/\\\_" +
|
||||||
|
"\n\u001b[0m" +
|
||||||
|
"\u001b[32m XMMMW: .:xKNMMMMMMN0d, lMMMMMd \u001b[31m" +
|
||||||
|
@" _______\/////////___\///////////_________\/////////___\///______________\///__" +
|
||||||
|
"\n\u001b[0m" +
|
||||||
|
"\u001b[32m :MMMMMK; cWMNkl:;;;:lxKMXc .0MMMMMO\u001b[0m\n" +
|
||||||
|
"\u001b[32m ..KMMMMMMNo,. ,OMMMMMMW:,. \u001b[37;1m Canary Islands Computer Museum Website\u001b[0m\n" +
|
||||||
|
"\u001b[32m .;d0NMMMMMMMMMMMMMMW0d:' .;lOWMMMMMMMMMMMMMXkl. \u001b[37;1m Version \u001b[0m\u001b[33m{0}\u001b[37;1m-\u001b[0m\u001b[31m{1}\u001b[0m\n" +
|
||||||
|
"\u001b[32m :KMMMMMMMMMMMMMMMMMMMMMMMMc WMMMMMMMMMMMMMMMMMMMMMMWk'\u001b[0m\n" +
|
||||||
|
"\u001b[32m ;NMMMMWX0kkkkO0XMMMMMMMMMMM0' dNMMMMMMMMMMW0xl:;,;:oOWMMX; \u001b[37;1m Running under \u001b[35;1m{2}\u001b[37;1m, \u001b[35m{3}-bit\u001b[37;1m in \u001b[35m{4}-bit\u001b[37;1m mode.\u001b[0m\n" +
|
||||||
|
"\u001b[32m xMMWk:. .c0MMMMMW' OMMMMMM0c'.. .oNMO \u001b[37;1m Using \u001b[33;1m{5}\u001b[37;1m version \u001b[31;1m{6}\u001b[0m\n" +
|
||||||
|
"\u001b[32m OMNc .MNc oWMMk 'WMMNl. .MMK ;KX.\u001b[0m\n" +
|
||||||
|
"\u001b[32m xMO WMN ; ., , ': ,MMx lK\u001b[0m\n" +
|
||||||
|
"\u001b[32m ,Md cMMl .XMMMWWMMMO XMW. :\u001b[0m\n" +
|
||||||
|
"\u001b[32m Ok xMMl XMMMMMMMMc 0MW,\u001b[0m\n" +
|
||||||
|
"\u001b[32m 0 oMM0' lMMMMMMMM. :NMN'\u001b[0m\n" +
|
||||||
|
"\u001b[32m . .0MMKl ;MMMMMMMM oNMWd\u001b[0m\n" +
|
||||||
|
"\u001b[32m .dNW cMMMMMMMM, XKl\u001b[0m\n" +
|
||||||
|
"\u001b[32m 0MMMMMMMMK\u001b[0m\n" +
|
||||||
|
"\u001b[32m ;MMMMMMMMMMO \u001b[37;1m Proudly presented to you by:\u001b[0m\n" +
|
||||||
|
"\u001b[32m 'WMMMMKxMMMMM0 \u001b[34;1m Natalia Portillo\u001b[0m\n" +
|
||||||
|
"\u001b[32m oMMMMNc :WMMMMN:\u001b[0m\n" +
|
||||||
|
"\u001b[32m .dWMMM0; dWMMMMXl. \u001b[37;1m Thanks to all contributors, collaborators, translators, donators and friends.\u001b[0m\n" +
|
||||||
|
"\u001b[32m .......,cd0WMMNk: c0MMMMMWKkolc:clodc'\u001b[0m\n" +
|
||||||
|
"\u001b[32m .';loddol:'. ':oxkkOkkxoc,.\u001b[0m\n" +
|
||||||
|
"\u001b[0m\n", Version.GetVersion(),
|
||||||
|
#if DEBUG
|
||||||
|
"DEBUG"
|
||||||
|
#else
|
||||||
|
"RELEASE"
|
||||||
|
#endif
|
||||||
|
, DetectOS.GetPlatformName(DetectOS.GetRealPlatformID()),
|
||||||
|
Environment.Is64BitOperatingSystem ? 64 : 32, Environment.Is64BitProcess ? 64 : 32,
|
||||||
|
DetectOS.IsMono ? "Mono" : ".NET Core",
|
||||||
|
DetectOS.IsMono ? Version.GetMonoVersion() : Version.GetNetCoreVersion());
|
||||||
|
|
||||||
|
Console.WriteLine("\u001b[31;1mStarting web server...\u001b[0m");
|
||||||
|
|
||||||
BuildWebHost(args).Run();
|
BuildWebHost(args).Run();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
<Project Sdk="Microsoft.NET.Sdk.Web">
|
<Project Sdk="Microsoft.NET.Sdk.Web">
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<TargetFramework>netcoreapp2.0</TargetFramework>
|
<TargetFramework>netcoreapp2.0</TargetFramework>
|
||||||
<Version>3.0.99.8</Version>
|
<Version>3.0.99.18</Version>
|
||||||
<Company>Canary Islands Computer Museum</Company>
|
<Company>Canary Islands Computer Museum</Company>
|
||||||
<Copyright>Copyright © 2003-2018 Natalia Portillo</Copyright>
|
<Copyright>Copyright © 2003-2018 Natalia Portillo</Copyright>
|
||||||
<Product>Canary Islands Computer Museum Website</Product>
|
<Product>Canary Islands Computer Museum Website</Product>
|
||||||
|
|||||||
Reference in New Issue
Block a user