rustftechh 0.1.1

A blazingly fast, highly extensible, and feature-rich system information tool written in Rust with fastfetch parity and multi-distro logos
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
use super::ffi;
use crate::utils::clean;

pub fn detect_hostname() -> Option<String> {
    unsafe {
        let mut buf = [0u16; 256];
        let mut size = buf.len() as ffi::DWORD;
        if ffi::GetComputerNameW(buf.as_mut_ptr(), &mut size) == 0 {
            return None;
        }
        let name = ffi::from_wide_nul(&buf);
        let cleaned = clean(name.trim());
        if cleaned.is_empty() { None } else { Some(cleaned) }
    }
}