Files
SCOPENET-MC/crates/core/src/sys.rs
T
Claude 1b1bb984bc Restyle to a clean, flat look and rename brand to SCOPENET
- Brand is now SCOPENET everywhere (defaults, UI, installer, docs)
- Launcher: solid backgrounds (no animated orbs/grain), flat Play button
  without gradient/shine/glow, quieter rail with a simple active
  indicator, smaller type scale, Inter as default font, glass off by
  default, restyled sliders
- Panel: same flat treatment; live preview mirrors the new launcher
- New flat scope-reticle logo and app icons
- Calmer default palette
- Fix: lock the shared cargo cache in the Docker build (amd64/arm64 raced)
- Fix: Windows-only clippy lint in sys.rs

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_011ARcGWxLx21FwXJ3yfGriS
2026-09-28 05:30:19 +00:00

42 lines
1.3 KiB
Rust

//! Tiny system probes (kept dependency-free to stay lightweight).
/// Total physical memory in MiB (best effort; 8 GiB if unknown).
pub fn total_memory_mb() -> u64 {
imp().unwrap_or(8192)
}
#[cfg(windows)]
fn imp() -> Option<u64> {
use windows_sys::Win32::System::SystemInformation::{GlobalMemoryStatusEx, MEMORYSTATUSEX};
let mut status: MEMORYSTATUSEX = unsafe { std::mem::zeroed() };
status.dwLength = std::mem::size_of::<MEMORYSTATUSEX>() as u32;
let ok = unsafe { GlobalMemoryStatusEx(&mut status) };
(ok != 0).then_some(status.ullTotalPhys / 1024 / 1024)
}
#[cfg(target_os = "linux")]
fn imp() -> Option<u64> {
let info = std::fs::read_to_string("/proc/meminfo").ok()?;
let line = info.lines().find(|l| l.starts_with("MemTotal:"))?;
let kb: u64 = line.split_whitespace().nth(1)?.parse().ok()?;
Some(kb / 1024)
}
#[cfg(not(any(windows, target_os = "linux")))]
fn imp() -> Option<u64> {
None
}
/// Recursively sum file sizes under `path`.
pub fn dir_size(path: &std::path::Path) -> u64 {
let Ok(entries) = std::fs::read_dir(path) else { return 0 };
entries
.filter_map(|e| e.ok())
.map(|e| match e.file_type() {
Ok(t) if t.is_dir() => dir_size(&e.path()),
Ok(t) if t.is_file() => e.metadata().map(|m| m.len()).unwrap_or(0),
_ => 0,
})
.sum()
}