mirror of
https://github.com/RGBCube/uutils-coreutils
synced 2025-07-28 11:37:44 +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
4 changed files with 12 additions and 5 deletions
1
Cargo.lock
generated
1
Cargo.lock
generated
|
@ -2939,6 +2939,7 @@ dependencies = [
|
||||||
"notify",
|
"notify",
|
||||||
"uucore",
|
"uucore",
|
||||||
"winapi 0.3.9",
|
"winapi 0.3.9",
|
||||||
|
"winapi-util",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
|
|
|
@ -24,6 +24,7 @@ uucore = { version=">=0.0.11", package="uucore", path="../../uucore", features=[
|
||||||
|
|
||||||
[target.'cfg(windows)'.dependencies]
|
[target.'cfg(windows)'.dependencies]
|
||||||
winapi = { version="0.3", features=["fileapi", "handleapi", "processthreadsapi", "synchapi", "winbase"] }
|
winapi = { version="0.3", features=["fileapi", "handleapi", "processthreadsapi", "synchapi", "winbase"] }
|
||||||
|
winapi-util = { version= "0.1.5" }
|
||||||
|
|
||||||
[target.'cfg(unix)'.dependencies]
|
[target.'cfg(unix)'.dependencies]
|
||||||
nix = { version = "0.24.1", default-features = false, features=["fs"] }
|
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()
|
platform::stdin_is_pipe_or_fifo()
|
||||||
}
|
}
|
||||||
// FIXME windows has GetFileType which can determine if the file is a pipe/FIFO
|
#[cfg(windows)]
|
||||||
// so this check can also be performed
|
{
|
||||||
#[cfg(not(unix))]
|
use winapi_util;
|
||||||
false
|
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 {
|
pub fn stdin_is_bad_fd() -> bool {
|
||||||
|
|
|
@ -11,7 +11,9 @@ extern crate tail;
|
||||||
|
|
||||||
use crate::common::util::*;
|
use crate::common::util::*;
|
||||||
use std::char::from_digit;
|
use std::char::from_digit;
|
||||||
use std::io::{Read, Write};
|
#[cfg(unix)]
|
||||||
|
use std::io::Read;
|
||||||
|
use std::io::Write;
|
||||||
use std::process::Stdio;
|
use std::process::Stdio;
|
||||||
#[cfg(unix)]
|
#[cfg(unix)]
|
||||||
use std::thread::sleep;
|
use std::thread::sleep;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue