mirror of
https://github.com/uutils/coreutils
synced 2024-07-23 19:04:18 +00:00
tail: add equivalent of stdin_is_pipe_or_fifo() for Windows
* add support to determine if stdin is readable on Windows
This commit is contained in:
parent
6a1cf72316
commit
84480f892d
1
Cargo.lock
generated
1
Cargo.lock
generated
|
@ -2939,6 +2939,7 @@ dependencies = [
|
|||
"notify",
|
||||
"uucore",
|
||||
"winapi 0.3.9",
|
||||
"winapi-util",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
|
|
@ -24,6 +24,7 @@ uucore = { version=">=0.0.11", package="uucore", path="../../uucore", features=[
|
|||
|
||||
[target.'cfg(windows)'.dependencies]
|
||||
winapi = { version="0.3", features=["fileapi", "handleapi", "processthreadsapi", "synchapi", "winbase"] }
|
||||
winapi-util = { version= "0.1.5" }
|
||||
|
||||
[target.'cfg(unix)'.dependencies]
|
||||
nix = { version = "0.24.1", default-features = false, features=["fs"] }
|
||||
|
|
|
@ -1435,10 +1435,13 @@ pub fn stdin_is_pipe_or_fifo() -> bool {
|
|||
{
|
||||
platform::stdin_is_pipe_or_fifo()
|
||||
}
|
||||
// FIXME windows has GetFileType which can determine if the file is a pipe/FIFO
|
||||
// so this check can also be performed
|
||||
#[cfg(not(unix))]
|
||||
false
|
||||
#[cfg(windows)]
|
||||
{
|
||||
use winapi_util;
|
||||
winapi_util::file::typ(winapi_util::HandleRef::stdin())
|
||||
.map(|t| t.is_disk() || t.is_pipe())
|
||||
.unwrap_or(false)
|
||||
}
|
||||
}
|
||||
|
||||
pub fn stdin_is_bad_fd() -> bool {
|
||||
|
|
|
@ -11,7 +11,9 @@ extern crate tail;
|
|||
|
||||
use crate::common::util::*;
|
||||
use std::char::from_digit;
|
||||
use std::io::{Read, Write};
|
||||
#[cfg(unix)]
|
||||
use std::io::Read;
|
||||
use std::io::Write;
|
||||
use std::process::Stdio;
|
||||
#[cfg(unix)]
|
||||
use std::thread::sleep;
|
||||
|
|
Loading…
Reference in a new issue