File tree Expand file tree Collapse file tree 1 file changed +25
-11
lines changed Expand file tree Collapse file tree 1 file changed +25
-11
lines changed Original file line number Diff line number Diff line change @@ -59,26 +59,40 @@ private static void CheckOS() {
59
59
}
60
60
61
61
IntPtr buf = Marshal . AllocHGlobal ( 8192 ) ;
62
- if ( uname ( buf ) == 0 ) {
63
- string os = Marshal . PtrToStringAnsi ( buf ) ;
64
- switch ( os ) {
65
- case "Darwin" :
66
- isMacOS = true ;
67
- break ;
68
- case "FreeBSD" :
69
- isFreeBSD = true ;
70
- break ;
62
+ try {
63
+ if ( uname ( buf ) == 0 ) {
64
+ string os = Marshal . PtrToStringAnsi ( buf ) ;
65
+ switch ( os ) {
66
+ case "Darwin" :
67
+ isMacOS = true ;
68
+ break ;
69
+ case "FreeBSD" :
70
+ isFreeBSD = true ;
71
+ break ;
72
+ }
71
73
}
72
74
}
73
- Marshal . FreeHGlobal ( buf ) ;
74
- checkedOS = true ;
75
+ finally {
76
+ Marshal . FreeHGlobal ( buf ) ;
77
+ checkedOS = true ;
78
+ }
75
79
}
76
80
#endif
77
81
78
82
public static bool IsMacOS {
79
83
get {
80
84
if ( ! checkedOS )
85
+ #if UNITY
86
+ try {
87
+ CheckOS ( ) ;
88
+ }
89
+ catch ( DllNotFoundException e ) {
90
+ // libc does not exist, so this is not MacOS
91
+ isMacOS = false ;
92
+ }
93
+ #else
81
94
CheckOS ( ) ;
95
+ #endif
82
96
return isMacOS ;
83
97
}
84
98
}
You can’t perform that action at this time.
0 commit comments