OneLauncher-Cracked/packages/oneclient_core/src/os_ext.rs
LynithDev 9ab0a0ecdd
Freya rewrite
This is v2 of OneClient. Removed all web-related stuff.

Co-Authored-By: Julian Chang <wyvest@polyfrost.org>
2026-07-05 16:37:05 -04:00

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(),
}
}
}