Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit5478140

Browse files
committed
uptime: make it compile on Windows
1 parent56c66a4 commit5478140

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

‎src/uu/uptime/src/uptime.rs

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,10 @@
88
use chrono::{Local,TimeZone,Utc};
99
use clap::ArgMatches;
1010
use std::ffi::OsString;
11+
#[cfg(not(windows))]
1112
use std::fs;
1213
use std::io;
14+
#[cfg(unix)]
1315
use std::os::unix::fs::FileTypeExt;
1416
use thiserror::Error;
1517
use uucore::error::set_exit_code;
@@ -27,7 +29,7 @@ use uucore::{format_usage, help_about, help_usage};
2729

2830
#[cfg(target_os ="openbsd")]
2931
use utmp_classic::{parse_from_path,UtmpEntry};
30-
#[cfg(not(target_os ="openbsd"))]
32+
#[cfg(not(any(windows,target_os ="openbsd")))]
3133
use uucore::utmpx::*;
3234

3335
constABOUT:&str =help_about!("uptime.md");
@@ -42,7 +44,7 @@ use uucore::libc::getloadavg;
4244

4345
#[cfg(windows)]
4446
extern"C"{
45-
fnGetTickCount() ->uucore::libc::uint32_t;
47+
fnGetTickCount() ->u32;
4648
}
4749

4850
#[derive(Debug,Error)]
@@ -203,6 +205,13 @@ fn uptime_with_file(file_path: &OsString) -> UResult<()> {
203205
Ok(())
204206
}
205207

208+
// TODO implement function
209+
#[cfg(not(unix))]
210+
fnuptime_with_file(_file_path:&OsString) ->UResult<()>{
211+
show_error!("not implemented yet");
212+
Ok(())
213+
}
214+
206215
/// Default uptime behaviour i.e. when no file argument is given.
207216
fndefault_uptime(matches:&ArgMatches) ->UResult<()>{
208217
#[cfg(target_os ="openbsd")]
@@ -345,7 +354,7 @@ fn print_time() {
345354
print!(" {} ", local_time.format("%H:%M:%S"));
346355
}
347356

348-
#[cfg(not(target_os ="openbsd"))]
357+
#[cfg(not(any(windows,target_os ="openbsd")))]
349358
fnget_uptime_from_boot_time(boot_time:time_t) ->i64{
350359
let now =Local::now().timestamp();
351360
#[cfg(target_pointer_width ="64")]

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp