mirror of
https://github.com/RGBCube/uutils-coreutils
synced 2025-09-14 19:16:17 +00:00
Fix OSX crash for uptime
This commit is contained in:
parent
0192235a1a
commit
4b857105c9
1 changed files with 10 additions and 6 deletions
|
@ -127,7 +127,6 @@ fn print_nusers() {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
fn print_time() {
|
||||
let local_time = unsafe { *localtime(&time(null())) };
|
||||
|
||||
|
@ -139,16 +138,21 @@ fn print_time() {
|
|||
}
|
||||
|
||||
fn get_uptime() -> int {
|
||||
let uptime_text = File::open(&Path::new("/proc/uptime"))
|
||||
.read_to_str().unwrap();
|
||||
let proc_uptime = File::open(&Path::new("/proc/uptime"))
|
||||
.read_to_str();
|
||||
|
||||
return match uptime_text.words().next() {
|
||||
let uptime_text = match proc_uptime {
|
||||
Ok(s) => s,
|
||||
_ => return -1
|
||||
};
|
||||
|
||||
match uptime_text.words().next() {
|
||||
Some(s) => match from_str(s.replace(".","")) {
|
||||
Some(n) => n,
|
||||
None => -1
|
||||
},
|
||||
None => -1
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
fn print_uptime() {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue