[Mono-list] Detecting if platform is Mac

Geoff Norton gnorton at novell.com
Mon Jan 5 15:00:55 EST 2009


On Mon, 2009-01-05 at 20:57 +0100, Petit Eric wrote:
> argg, sorry chris , i would like to send this to the list :
> 
> declare a "string Platform = "win";"
> use :
> if(environment.platformid == unix) to use a process with redirect
> output and start
> process.start("uname -a");
> then parse the response with .indexof
> 
> i remember, for the process + return function, yu can use my class :
> http://monoosc.svn.sourceforge.net/viewvc/monoosc/MonoOSC/MonoOSC/Class/UnixShell.cs?revision=34&view=markup
> :-)

Like I've already said in this thread, using a process to run uname is
senseless overhead.  Use p/invoke like in XplatUI.cs

-g


> 
> 2009/1/5 Erik Ylvisaker <eylvisaker at physics.ucdavis.edu>:
> > So, the reason I want to detect if we are running MacOS is I am writing
> > Mac OpenGL bindings for the OpenTK project.  On MacOS we need to make
> > appropriate AGL calls instead of GLX or WGL calls in order to construct
> > an OpenGL context.  Perhaps a better solution would be to check the type
> > of the XPlatUI driver to see what it is, although I'd like to avoid
> > writing code which depends on private mono internals.
> >
> > Miguel de Icaza wrote:
> >>> Apparently in .NET 3.5 Microsoft added two members to the
> >>> System.PlatformID type, called Xbox and MacOSX.  Is there any support in
> >>> Mono for these?  Of course, I don't care about the Xbox value I am just
> >>> interested in being able to detect whether my code is running on MacOS
> >>> or Linux.
> >>>
> >>
> >> We added support for reporting this value back, but it turned out to
> >> break too much code in both Mono and our own modules, so we took this
> >> patch out.
> >>
> >> A lot of code assumed that it was Unix if the value was Unix, and when
> >> we returned the new value assumed it was running on Windows.
> >>
> >> We will continue to monitor progress on third party code and eventually
> >> make this change.
> >>
> >> But in general, the PlatformID is a poor way of detecting the platform,
> >> and instead you should base your code on other parameters like path
> >> separators for example.
> >>
> >>
> > _______________________________________________
> > Mono-list maillist  -  Mono-list at lists.ximian.com
> > http://lists.ximian.com/mailman/listinfo/mono-list
> >
> 
> 
> 



More information about the Mono-list mailing list