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

Commit131458b

Browse files
committed
uptime: make it compile on Windows
1 parent35eafac commit131458b

File tree

2 files changed

+18
-9
lines changed

2 files changed

+18
-9
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")]

‎tests/by-util/test_uptime.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,16 +8,16 @@
88

99
usecrate::common::util::TestScenario;
1010

11-
#[cfg(not(any(target_os ="macos", target_os ="openbsd")))]
11+
#[cfg(not(any(windows,target_os ="macos", target_os ="openbsd")))]
1212
use bincode::serialize;
1313
use regex::Regex;
14-
#[cfg(not(any(target_os ="macos", target_os ="openbsd")))]
14+
#[cfg(not(any(windows,target_os ="macos", target_os ="openbsd")))]
1515
use serde::Serialize;
16-
#[cfg(not(any(target_os ="macos", target_os ="openbsd")))]
16+
#[cfg(not(any(windows,target_os ="macos", target_os ="openbsd")))]
1717
use serde_big_array::BigArray;
18-
#[cfg(not(any(target_os ="macos", target_os ="openbsd")))]
18+
#[cfg(not(any(windows,target_os ="macos", target_os ="openbsd")))]
1919
use std::fs::File;
20-
#[cfg(not(any(target_os ="macos", target_os ="openbsd")))]
20+
#[cfg(not(any(windows,target_os ="macos", target_os ="openbsd")))]
2121
use std::{io::Write, path::PathBuf};
2222

2323
#[test]
@@ -98,7 +98,7 @@ fn test_uptime_with_non_existent_file() {
9898
// TODO create a similar test for macos
9999
// This will pass
100100
#[test]
101-
#[cfg(not(any(target_os ="openbsd", target_os ="macos")))]
101+
#[cfg(not(any(windows,target_os ="openbsd", target_os ="macos")))]
102102
#[cfg_attr(
103103
all(target_arch ="aarch64", target_os ="linux"),
104104
ignore ="Issue #7159 - Test not supported on ARM64 Linux"

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp