[Mono-list] Detect OS using mono framework

Chris Howie cdhowie at gmail.com
Thu Mar 27 22:23:41 EDT 2008


On Thu, Mar 27, 2008 at 1:29 PM, Jonathan Pryor <jonpryor at vt.edu> wrote:
> Your OSDetection.IsOSX code can be simplified greatly by using
> Mono.Posix.dll in Mono 1.9:
>
>        static bool IsOSX {
>                get {
>                        if (IsWindows)
>                                return false;
>                        Mono.Unix.Native.Utsname buf;
>                        if (Mono.Unix.Native.Syscall.uname (out buf) ==
>                        0) {
>                                return string.Compare(buf.sysname, "darwin", true) == 0
>                        }
>                        return false;
>                }
>        }
>
> See also:
>
> http://www.go-mono.com/docs/index.aspx?link=T%3aMono.Unix.Native.Utsname%2f*
> http://www.go-mono.com/docs/index.aspx?tlink=0@ecma%3a152%23Syscall%2fM%2f230
>
>  - Jon

Won't the JIT explode if this is called on MS.NET?

-- 
Chris Howie
http://www.chrishowie.com
http://en.wikipedia.org/wiki/User:Crazycomputers


More information about the Mono-list mailing list