mirror of
https://github.com/fish-shell/fish-shell.git
synced 2025-03-04 12:59:38 +08:00
io: add FFI wrappers for io_streams_t fields
This commit is contained in:
parent
ba5e1dfb69
commit
cc744d30c0
@ -4,6 +4,7 @@ use crate::wchar::{wstr, WString, L};
|
||||
use crate::wchar_ffi::{c_str, empty_wstring, WCharFromFFI};
|
||||
use crate::wgetopt::{wgetopter_t, wopt, woption, woption_argument_t};
|
||||
use libc::c_int;
|
||||
use std::os::fd::RawFd;
|
||||
use std::pin::Pin;
|
||||
|
||||
#[cxx::bridge]
|
||||
@ -122,6 +123,20 @@ impl io_streams_t {
|
||||
pub fn ffi_ref(&self) -> &builtins_ffi::io_streams_t {
|
||||
unsafe { &*self.streams }
|
||||
}
|
||||
|
||||
pub fn stdin_is_directly_redirected(&self) -> bool {
|
||||
self.ffi_ref().ffi_stdin_is_directly_redirected()
|
||||
}
|
||||
|
||||
pub fn stdin_fd(&self) -> Option<RawFd> {
|
||||
let ret = self.ffi_ref().ffi_stdin_fd().0;
|
||||
|
||||
if ret < 0 {
|
||||
None
|
||||
} else {
|
||||
Some(ret)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn rust_run_builtin(
|
||||
|
2
src/io.h
2
src/io.h
@ -512,6 +512,8 @@ struct io_streams_t : noncopyable_t {
|
||||
output_stream_t &get_err() { return err; };
|
||||
io_streams_t(const io_streams_t &) = delete;
|
||||
bool get_out_redirected() { return out_is_redirected; };
|
||||
bool ffi_stdin_is_directly_redirected() const { return stdin_is_directly_redirected; };
|
||||
int ffi_stdin_fd() const { return stdin_fd; };
|
||||
};
|
||||
|
||||
#endif
|
||||
|
Loading…
x
Reference in New Issue
Block a user