+#[cfg(target_os = "linux")]\r
+fn get_number_of_players() -> u32 {\r
+ let mut journal =\r
+ journal::OpenOptions::default().current_user(true).open().unwrap();\r
+\r
+ journal.seek_tail().unwrap();\r
+\r
+ loop {\r
+ match journal.previous_entry() {\r
+ Ok(Some(entry)) => {\r
+ if let (Some(unit), Some(mess)) = (entry.get("_SYSTEMD_UNIT"), entry.get("MESSAGE")) {\r
+ if unit == "valheim.service" {\r
+ if let Some(pos) = mess.find("Connections") {\r
+ let nb_of_connections_str = mess.get(pos+12..).unwrap();\r
+ if let Some(pos_end) = nb_of_connections_str.find(' ') {\r
+ if let Ok(n) = nb_of_connections_str.get(0..pos_end).unwrap().parse() {\r
+ return n;\r
+ }\r
+ }\r
+ }\r
+ }\r
+ }\r
+ },\r
+ _ => return 0\r
+ }\r
+ }\r
+}\r
+\r
+#[cfg(target_os = "windows")]\r
+fn get_number_of_players() -> u32 {\r
+ 0\r
+}\r
+\r
+fn get_last_backup_datetime(backup_path: &str) -> Option<SystemTime> {\r
+ let mut times =\r
+ fs::read_dir(backup_path).ok()?.filter_map(\r
+ |e| {\r
+ let dir = e.ok()?;\r
+ if dir.path().is_file() { Some(dir.metadata().ok()?.modified().ok()?) } else { None }\r
+ }\r
+ )\r
+ .collect::<Vec<SystemTime>>();\r
+\r
+ times.sort();\r
+\r
+ Some(times.last()?.clone())\r
+}\r
+\r
+pub fn get_valheim_executable_information(world_path: &str, backup_path: &str) -> Option<ValheimExe> {\r