1use crate::constants;
2use std::fs;
3use std::io::prelude::*;
4
5#[allow(dead_code)]
6#[derive(Debug)]
7pub struct RuntimeOS {
8 family: String,
9}
10
11impl RuntimeOS {
12 pub fn new(&self) -> Self {
13 if self.is_wsl() {
14 Self {
15 family: String::from("wsl"),
16 }
17 } else {
18 Self {
19 family: String::from(std::env::consts::OS),
20 }
21 }
22 }
23
24 fn is_wsl(&self) -> bool {
25 let mut file = fs::File::open(constants::OS_RELEASE_PATH).expect("File not found");
26 let mut data = String::new();
27 file.read_to_string(&mut data)
28 .expect("Error while reading file");
29 data.to_lowercase().contains("wsl")
30 }
31}