mirror of
https://gitee.com/RubyMetric/chsrc.git
synced 2025-12-25 20:52:49 +00:00
修复Android系统检测 (#313)
This commit is contained in:
parent
730d18a8a9
commit
6af3e51566
17
lib/xy.h
17
lib/xy.h
|
|
@ -1290,18 +1290,21 @@ xy_detect_os ()
|
|||
char buf[256] = {0};
|
||||
fread (buf, 1, sizeof(buf) - 1, fp);
|
||||
fclose (fp);
|
||||
if (strstr (buf, "Android"))
|
||||
{
|
||||
xy.on_android = true;
|
||||
return;
|
||||
}
|
||||
else if (strstr (buf, "Linux"))
|
||||
if (strstr (buf, "Linux"))
|
||||
{
|
||||
xy.on_linux = true;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// @consult https://android.googlesource.com/platform/system/core/+/refs/heads/main/rootdir/init.environ.rc.in
|
||||
char *android_env = getenv ("ANDROID_ROOT");
|
||||
if (xy_str_find (android_env, "/system").found)
|
||||
{
|
||||
xy.on_android = true;
|
||||
return;
|
||||
}
|
||||
|
||||
/* 判断 macOS */
|
||||
DIR *d = opendir ("/System/Applications");
|
||||
if (d)
|
||||
|
|
@ -1312,6 +1315,7 @@ xy_detect_os ()
|
|||
{
|
||||
xy.on_macos = true;
|
||||
closedir (d);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -1333,6 +1337,7 @@ xy_detect_os ()
|
|||
pclose (fp);
|
||||
if (strstr (buf, "BSD") != NULL)
|
||||
xy.on_bsd = true;
|
||||
return;
|
||||
}
|
||||
|
||||
if (!(xy.on_windows || xy.on_linux || xy.on_android || xy.on_macos || xy.on_bsd))
|
||||
|
|
|
|||
Loading…
Reference in New Issue