[Mono-list] Detect OS using mono framework

Jonathan Pryor jonpryor at vt.edu
Thu Mar 27 13:29:13 EDT 2008


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




More information about the Mono-list mailing list