mail-archives/mono-osx/2007-December/001099.html

101 строка
3.4 KiB
HTML
Исходник Постоянная ссылка Обычный вид История

2019-06-06 22:05:17 +03:00
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
<HTML>
<HEAD>
<TITLE> [Mono-osx] OSX vs Linux
</TITLE>
<LINK REL="Index" HREF="index.html" >
<LINK REL="made" HREF="mailto:mono-osx%40lists.ximian.com?Subject=%5BMono-osx%5D%20OSX%20vs%20Linux&In-Reply-To=47724CF5283C94439900996CDF98D5BE791DB5%40igtdalexc002.corp.ignitetech.com">
<META NAME="robots" CONTENT="index,nofollow">
<META http-equiv="Content-Type" content="text/html; charset=us-ascii">
<LINK REL="Previous" HREF="001093.html">
<LINK REL="Next" HREF="001094.html">
</HEAD>
<BODY BGCOLOR="#ffffff">
<H1>[Mono-osx] OSX vs Linux</H1>
<B>Miguel de Icaza</B>
<A HREF="mailto:mono-osx%40lists.ximian.com?Subject=%5BMono-osx%5D%20OSX%20vs%20Linux&In-Reply-To=47724CF5283C94439900996CDF98D5BE791DB5%40igtdalexc002.corp.ignitetech.com"
TITLE="[Mono-osx] OSX vs Linux">miguel at novell.com
</A><BR>
<I>Mon Dec 17 19:03:46 EST 2007</I>
<P><UL>
<LI>Previous message: <A HREF="001093.html">[Mono-osx] OSX vs Linux
</A></li>
<LI>Next message: <A HREF="001094.html">[Mono-osx] OSX vs Linux
</A></li>
<LI> <B>Messages sorted by:</B>
<a href="date.html#1099">[ date ]</a>
<a href="thread.html#1099">[ thread ]</a>
<a href="subject.html#1099">[ subject ]</a>
<a href="author.html#1099">[ author ]</a>
</LI>
</UL>
<HR>
<!--beginarticle-->
<PRE>Hello,
&gt;<i> I'm having some trouble distinguishing the difference between Linux and
</I>&gt;<i> OSX.
</I>
Oh.
&gt;<i>From the subject line I felt a new flame war was brewing.
</I>
The uname approach works, the following is a piece of uname that uses
P/Invoke instead of depending on uname, its part of mkbundle.cs:
using System.Runtime.InteropServices;
[DllImport (&quot;libc&quot;)]
static extern int uname (IntPtr buf);
static void DetectOS ()
{
if (!IsUnix) {
Console.WriteLine (&quot;OS is: Windows&quot;);
style = &quot;windows&quot;;
return;
}
IntPtr buf = UnixMarshal.AllocHeap(8192);
if (uname (buf) != 0){
Console.WriteLine (&quot;Warning: Unable to detect OS&quot;);
return;
}
string os = Marshal.PtrToStringAnsi (buf);
Console.WriteLine (&quot;OS is: &quot; + os);
if (os == &quot;Darwin&quot;)
style = &quot;osx&quot;;
UnixMarshal.FreeHeap(buf);
}
static bool IsUnix {
get {
int p = (int) Environment.OSVersion.Platform;
return ((p == 4) || (p == 128));
}
}
</PRE>
<!--endarticle-->
<HR>
<P><UL>
<!--threads-->
<LI>Previous message: <A HREF="001093.html">[Mono-osx] OSX vs Linux
</A></li>
<LI>Next message: <A HREF="001094.html">[Mono-osx] OSX vs Linux
</A></li>
<LI> <B>Messages sorted by:</B>
<a href="date.html#1099">[ date ]</a>
<a href="thread.html#1099">[ thread ]</a>
<a href="subject.html#1099">[ subject ]</a>
<a href="author.html#1099">[ author ]</a>
</LI>
</UL>
<hr>
<a href="http://lists.ximian.com/mailman/listinfo/mono-osx">More information about the Mono-osx
mailing list</a><br>
</body></html>