Re: [Mono-list] Detecting if platform is Mac
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 : > > 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@lists.ximian.com > > http://lists.ximian.com/mailman/listinfo/mono-list > > > > > ___ Mono-list maillist - Mono-list@lists.ximian.com http://lists.ximian.com/mailman/listinfo/mono-list
Re: [Mono-list] Detecting if platform is Mac
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 :-) 2009/1/5 Erik Ylvisaker : > 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@lists.ximian.com > http://lists.ximian.com/mailman/listinfo/mono-list > -- Cordially. Small Eric Quotations of the days: --- If one day one reproaches you that your work is not a work of professional, say you that: Amateurs built the arch of Noah, and professionals the Titanic. --- Few people are done for independence, it is the privilege of the powerful ones. --- No key was wounded during the drafting of this message. ___ Mono-list maillist - Mono-list@lists.ximian.com http://lists.ximian.com/mailman/listinfo/mono-list
Re: [Mono-list] Detecting if platform is Mac
On Mon, Jan 5, 2009 at 1:51 PM, Erik Ylvisaker wrote: > 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. My favorite method of dealing with platform-specific native libraries is to find a function in the libraries that doesn't do anything, or that you can feed invalid input to cause it to do nothing (but obviously not crash). Specify a P/Invoke definition for each, then call them until you find one that doesn't throw DllNotFoundException. Then that's your library/platform. -- Chris Howie http://www.chrishowie.com http://en.wikipedia.org/wiki/User:Crazycomputers ___ Mono-list maillist - Mono-list@lists.ximian.com http://lists.ximian.com/mailman/listinfo/mono-list
Re: [Mono-list] Detecting if platform is Mac
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@lists.ximian.com http://lists.ximian.com/mailman/listinfo/mono-list
Re: [Mono-list] Detecting if platform is Mac
> 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@lists.ximian.com http://lists.ximian.com/mailman/listinfo/mono-list
Re: [Mono-list] Detecting if platform is Mac
On Wed, 2008-12-31 at 15:33 -0500, Geoff Norton wrote: > On Wed, 2008-12-31 at 11:53 -0800, Erik Ylvisaker wrote: > > Otherwise, is there another recommended way to detect if running on > > MacOS? Currently we are spawning uname and checking to see if the > > output is "Darwin". This works, but I don't know if there's a better way. > > Dont spawn uname, p/invoke it. Look in > mcs/class/Managed.Windows.Forms/System.Windows.Forms/XplatUI.cs for an > example. Or use Mono.Unix.Native.Syscall.uname(): http://go-mono.com/docs/index.aspx?tlin...@ecma%3a285%23syscall%2fm%2f231 The Utsname.system field is what you're after. - Jon ___ Mono-list maillist - Mono-list@lists.ximian.com http://lists.ximian.com/mailman/listinfo/mono-list
Re: [Mono-list] Detecting if platform is Mac
On Wed, 2008-12-31 at 11:53 -0800, Erik Ylvisaker 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 might support this in 2.4. > > Otherwise, is there another recommended way to detect if running on > MacOS? Currently we are spawning uname and checking to see if the > output is "Darwin". This works, but I don't know if there's a better way. Dont spawn uname, p/invoke it. Look in mcs/class/Managed.Windows.Forms/System.Windows.Forms/XplatUI.cs for an example. -g > ___ > Mono-list maillist - Mono-list@lists.ximian.com > http://lists.ximian.com/mailman/listinfo/mono-list ___ Mono-list maillist - Mono-list@lists.ximian.com http://lists.ximian.com/mailman/listinfo/mono-list
[Mono-list] Detecting if platform is Mac
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. Otherwise, is there another recommended way to detect if running on MacOS? Currently we are spawning uname and checking to see if the output is "Darwin". This works, but I don't know if there's a better way. ___ Mono-list maillist - Mono-list@lists.ximian.com http://lists.ximian.com/mailman/listinfo/mono-list