mirror of
https://github.com/RubyMetric/chsrc
synced 2025-10-20 01:27:41 +08:00
修复Android系统检测 (#313)
This commit is contained in:
17
lib/xy.h
17
lib/xy.h
@@ -1290,18 +1290,21 @@ xy_detect_os ()
|
|||||||
char buf[256] = {0};
|
char buf[256] = {0};
|
||||||
fread (buf, 1, sizeof(buf) - 1, fp);
|
fread (buf, 1, sizeof(buf) - 1, fp);
|
||||||
fclose (fp);
|
fclose (fp);
|
||||||
if (strstr (buf, "Android"))
|
if (strstr (buf, "Linux"))
|
||||||
{
|
|
||||||
xy.on_android = true;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
else if (strstr (buf, "Linux"))
|
|
||||||
{
|
{
|
||||||
xy.on_linux = true;
|
xy.on_linux = true;
|
||||||
return;
|
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 */
|
/* 判断 macOS */
|
||||||
DIR *d = opendir ("/System/Applications");
|
DIR *d = opendir ("/System/Applications");
|
||||||
if (d)
|
if (d)
|
||||||
@@ -1312,6 +1315,7 @@ xy_detect_os ()
|
|||||||
{
|
{
|
||||||
xy.on_macos = true;
|
xy.on_macos = true;
|
||||||
closedir (d);
|
closedir (d);
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1333,6 +1337,7 @@ xy_detect_os ()
|
|||||||
pclose (fp);
|
pclose (fp);
|
||||||
if (strstr (buf, "BSD") != NULL)
|
if (strstr (buf, "BSD") != NULL)
|
||||||
xy.on_bsd = true;
|
xy.on_bsd = true;
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!(xy.on_windows || xy.on_linux || xy.on_android || xy.on_macos || xy.on_bsd))
|
if (!(xy.on_windows || xy.on_linux || xy.on_android || xy.on_macos || xy.on_bsd))
|
||||||
|
Reference in New Issue
Block a user