This is v2 of OneClient. Removed all web-related stuff. Co-Authored-By: Julian Chang <wyvest@polyfrost.org>
53 lines
1.4 KiB
Rust
53 lines
1.4 KiB
Rust
use interfrost::api::minecraft::Os;
|
|
|
|
pub trait OsExt {
|
|
fn native() -> Self;
|
|
fn native_arch(java_arch: &str) -> Self;
|
|
fn get_os(&self) -> Self;
|
|
}
|
|
|
|
impl OsExt for Os {
|
|
fn native() -> Self {
|
|
match std::env::consts::OS {
|
|
"windows" => Self::Windows,
|
|
"macos" => Self::Osx,
|
|
"linux" => Self::Linux,
|
|
_ => Self::Unknown,
|
|
}
|
|
}
|
|
|
|
fn native_arch(java_arch: &str) -> Self {
|
|
if std::env::consts::OS == "windows" {
|
|
if java_arch == "aarch64" {
|
|
Self::WindowsArm64
|
|
} else {
|
|
Self::Windows
|
|
}
|
|
} else if std::env::consts::OS == "linux" {
|
|
if java_arch == "aarch64" {
|
|
Self::LinuxArm64
|
|
} else if java_arch == "arm" {
|
|
Self::LinuxArm32
|
|
} else {
|
|
Self::Linux
|
|
}
|
|
} else if std::env::consts::OS == "macos" {
|
|
if java_arch == "aarch64" {
|
|
Self::OsxArm64
|
|
} else {
|
|
Self::Osx
|
|
}
|
|
} else {
|
|
Self::Unknown
|
|
}
|
|
}
|
|
|
|
fn get_os(&self) -> Self {
|
|
match self {
|
|
Self::OsxArm64 => Self::Osx,
|
|
Self::LinuxArm32 | Self::LinuxArm64 => Self::Linux,
|
|
Self::WindowsArm64 => Self::Windows,
|
|
_ => self.clone(),
|
|
}
|
|
}
|
|
}
|