mirror of
https://github.com/denoland/deno.git
synced 2024-11-25 15:29:32 -05:00
normalize rids (#9832)
This commit is contained in:
parent
277e19f4d2
commit
197305908b
8 changed files with 55 additions and 57 deletions
|
@ -296,7 +296,7 @@ pub async fn op_fetch_request_write(
|
||||||
let resource = state
|
let resource = state
|
||||||
.borrow()
|
.borrow()
|
||||||
.resource_table
|
.resource_table
|
||||||
.get::<FetchRequestBodyResource>(rid as u32)
|
.get::<FetchRequestBodyResource>(rid)
|
||||||
.ok_or_else(bad_resource_id)?;
|
.ok_or_else(bad_resource_id)?;
|
||||||
let body = RcRef::map(&resource, |r| &r.body).borrow_mut().await;
|
let body = RcRef::map(&resource, |r| &r.body).borrow_mut().await;
|
||||||
let cancel = RcRef::map(resource, |r| &r.cancel);
|
let cancel = RcRef::map(resource, |r| &r.cancel);
|
||||||
|
@ -325,7 +325,7 @@ pub async fn op_fetch_response_read(
|
||||||
let resource = state
|
let resource = state
|
||||||
.borrow()
|
.borrow()
|
||||||
.resource_table
|
.resource_table
|
||||||
.get::<FetchResponseBodyResource>(rid as u32)
|
.get::<FetchResponseBodyResource>(rid)
|
||||||
.ok_or_else(bad_resource_id)?;
|
.ok_or_else(bad_resource_id)?;
|
||||||
let mut reader = RcRef::map(&resource, |r| &r.reader).borrow_mut().await;
|
let mut reader = RcRef::map(&resource, |r| &r.reader).borrow_mut().await;
|
||||||
let cancel = RcRef::map(resource, |r| &r.cancel);
|
let cancel = RcRef::map(resource, |r| &r.cancel);
|
||||||
|
|
|
@ -208,13 +208,13 @@ async fn op_open_async(
|
||||||
#[derive(Deserialize)]
|
#[derive(Deserialize)]
|
||||||
#[serde(rename_all = "camelCase")]
|
#[serde(rename_all = "camelCase")]
|
||||||
pub struct SeekArgs {
|
pub struct SeekArgs {
|
||||||
rid: i32,
|
rid: u32,
|
||||||
offset: i64,
|
offset: i64,
|
||||||
whence: i32,
|
whence: i32,
|
||||||
}
|
}
|
||||||
|
|
||||||
fn seek_helper(args: SeekArgs) -> Result<(u32, SeekFrom), AnyError> {
|
fn seek_helper(args: SeekArgs) -> Result<(u32, SeekFrom), AnyError> {
|
||||||
let rid = args.rid as u32;
|
let rid = args.rid;
|
||||||
let offset = args.offset;
|
let offset = args.offset;
|
||||||
let whence = args.whence as u32;
|
let whence = args.whence as u32;
|
||||||
// Translate seek mode to Rust repr.
|
// Translate seek mode to Rust repr.
|
||||||
|
@ -273,7 +273,7 @@ async fn op_seek_async(
|
||||||
#[derive(Deserialize)]
|
#[derive(Deserialize)]
|
||||||
#[serde(rename_all = "camelCase")]
|
#[serde(rename_all = "camelCase")]
|
||||||
pub struct FdatasyncArgs {
|
pub struct FdatasyncArgs {
|
||||||
rid: i32,
|
rid: u32,
|
||||||
}
|
}
|
||||||
|
|
||||||
fn op_fdatasync_sync(
|
fn op_fdatasync_sync(
|
||||||
|
@ -281,7 +281,7 @@ fn op_fdatasync_sync(
|
||||||
args: FdatasyncArgs,
|
args: FdatasyncArgs,
|
||||||
_zero_copy: &mut [ZeroCopyBuf],
|
_zero_copy: &mut [ZeroCopyBuf],
|
||||||
) -> Result<Value, AnyError> {
|
) -> Result<Value, AnyError> {
|
||||||
let rid = args.rid as u32;
|
let rid = args.rid;
|
||||||
StdFileResource::with(state, rid, |r| match r {
|
StdFileResource::with(state, rid, |r| match r {
|
||||||
Ok(std_file) => std_file.sync_data().map_err(AnyError::from),
|
Ok(std_file) => std_file.sync_data().map_err(AnyError::from),
|
||||||
Err(_) => Err(type_error("cannot sync this type of resource".to_string())),
|
Err(_) => Err(type_error("cannot sync this type of resource".to_string())),
|
||||||
|
@ -294,7 +294,7 @@ async fn op_fdatasync_async(
|
||||||
args: FdatasyncArgs,
|
args: FdatasyncArgs,
|
||||||
_zero_copy: BufVec,
|
_zero_copy: BufVec,
|
||||||
) -> Result<Value, AnyError> {
|
) -> Result<Value, AnyError> {
|
||||||
let rid = args.rid as u32;
|
let rid = args.rid;
|
||||||
|
|
||||||
let resource = state
|
let resource = state
|
||||||
.borrow_mut()
|
.borrow_mut()
|
||||||
|
@ -317,7 +317,7 @@ async fn op_fdatasync_async(
|
||||||
#[derive(Deserialize)]
|
#[derive(Deserialize)]
|
||||||
#[serde(rename_all = "camelCase")]
|
#[serde(rename_all = "camelCase")]
|
||||||
pub struct FsyncArgs {
|
pub struct FsyncArgs {
|
||||||
rid: i32,
|
rid: u32,
|
||||||
}
|
}
|
||||||
|
|
||||||
fn op_fsync_sync(
|
fn op_fsync_sync(
|
||||||
|
@ -325,7 +325,7 @@ fn op_fsync_sync(
|
||||||
args: FsyncArgs,
|
args: FsyncArgs,
|
||||||
_zero_copy: &mut [ZeroCopyBuf],
|
_zero_copy: &mut [ZeroCopyBuf],
|
||||||
) -> Result<Value, AnyError> {
|
) -> Result<Value, AnyError> {
|
||||||
let rid = args.rid as u32;
|
let rid = args.rid;
|
||||||
StdFileResource::with(state, rid, |r| match r {
|
StdFileResource::with(state, rid, |r| match r {
|
||||||
Ok(std_file) => std_file.sync_all().map_err(AnyError::from),
|
Ok(std_file) => std_file.sync_all().map_err(AnyError::from),
|
||||||
Err(_) => Err(type_error("cannot sync this type of resource".to_string())),
|
Err(_) => Err(type_error("cannot sync this type of resource".to_string())),
|
||||||
|
@ -338,7 +338,7 @@ async fn op_fsync_async(
|
||||||
args: FsyncArgs,
|
args: FsyncArgs,
|
||||||
_zero_copy: BufVec,
|
_zero_copy: BufVec,
|
||||||
) -> Result<Value, AnyError> {
|
) -> Result<Value, AnyError> {
|
||||||
let rid = args.rid as u32;
|
let rid = args.rid;
|
||||||
|
|
||||||
let resource = state
|
let resource = state
|
||||||
.borrow_mut()
|
.borrow_mut()
|
||||||
|
@ -361,7 +361,7 @@ async fn op_fsync_async(
|
||||||
#[derive(Deserialize)]
|
#[derive(Deserialize)]
|
||||||
#[serde(rename_all = "camelCase")]
|
#[serde(rename_all = "camelCase")]
|
||||||
pub struct FstatArgs {
|
pub struct FstatArgs {
|
||||||
rid: i32,
|
rid: u32,
|
||||||
}
|
}
|
||||||
|
|
||||||
fn op_fstat_sync(
|
fn op_fstat_sync(
|
||||||
|
@ -370,8 +370,7 @@ fn op_fstat_sync(
|
||||||
_zero_copy: &mut [ZeroCopyBuf],
|
_zero_copy: &mut [ZeroCopyBuf],
|
||||||
) -> Result<Value, AnyError> {
|
) -> Result<Value, AnyError> {
|
||||||
super::check_unstable(state, "Deno.fstat");
|
super::check_unstable(state, "Deno.fstat");
|
||||||
let rid = args.rid as u32;
|
let metadata = StdFileResource::with(state, args.rid, |r| match r {
|
||||||
let metadata = StdFileResource::with(state, rid, |r| match r {
|
|
||||||
Ok(std_file) => std_file.metadata().map_err(AnyError::from),
|
Ok(std_file) => std_file.metadata().map_err(AnyError::from),
|
||||||
Err(_) => Err(type_error("cannot stat this type of resource".to_string())),
|
Err(_) => Err(type_error("cannot stat this type of resource".to_string())),
|
||||||
})?;
|
})?;
|
||||||
|
@ -385,7 +384,7 @@ async fn op_fstat_async(
|
||||||
) -> Result<Value, AnyError> {
|
) -> Result<Value, AnyError> {
|
||||||
super::check_unstable2(&state, "Deno.fstat");
|
super::check_unstable2(&state, "Deno.fstat");
|
||||||
|
|
||||||
let rid = args.rid as u32;
|
let rid = args.rid;
|
||||||
|
|
||||||
let resource = state
|
let resource = state
|
||||||
.borrow_mut()
|
.borrow_mut()
|
||||||
|
@ -1314,7 +1313,7 @@ async fn op_read_link_async(
|
||||||
#[derive(Deserialize)]
|
#[derive(Deserialize)]
|
||||||
#[serde(rename_all = "camelCase")]
|
#[serde(rename_all = "camelCase")]
|
||||||
pub struct FtruncateArgs {
|
pub struct FtruncateArgs {
|
||||||
rid: i32,
|
rid: u32,
|
||||||
len: i32,
|
len: i32,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1324,7 +1323,7 @@ fn op_ftruncate_sync(
|
||||||
_zero_copy: &mut [ZeroCopyBuf],
|
_zero_copy: &mut [ZeroCopyBuf],
|
||||||
) -> Result<Value, AnyError> {
|
) -> Result<Value, AnyError> {
|
||||||
super::check_unstable(state, "Deno.ftruncate");
|
super::check_unstable(state, "Deno.ftruncate");
|
||||||
let rid = args.rid as u32;
|
let rid = args.rid;
|
||||||
let len = args.len as u64;
|
let len = args.len as u64;
|
||||||
StdFileResource::with(state, rid, |r| match r {
|
StdFileResource::with(state, rid, |r| match r {
|
||||||
Ok(std_file) => std_file.set_len(len).map_err(AnyError::from),
|
Ok(std_file) => std_file.set_len(len).map_err(AnyError::from),
|
||||||
|
@ -1339,7 +1338,7 @@ async fn op_ftruncate_async(
|
||||||
_zero_copy: BufVec,
|
_zero_copy: BufVec,
|
||||||
) -> Result<Value, AnyError> {
|
) -> Result<Value, AnyError> {
|
||||||
super::check_unstable2(&state, "Deno.ftruncate");
|
super::check_unstable2(&state, "Deno.ftruncate");
|
||||||
let rid = args.rid as u32;
|
let rid = args.rid;
|
||||||
let len = args.len as u64;
|
let len = args.len as u64;
|
||||||
|
|
||||||
let resource = state
|
let resource = state
|
||||||
|
@ -1586,7 +1585,7 @@ async fn op_make_temp_file_async(
|
||||||
#[derive(Deserialize)]
|
#[derive(Deserialize)]
|
||||||
#[serde(rename_all = "camelCase")]
|
#[serde(rename_all = "camelCase")]
|
||||||
pub struct FutimeArgs {
|
pub struct FutimeArgs {
|
||||||
rid: i32,
|
rid: u32,
|
||||||
atime: (i64, u32),
|
atime: (i64, u32),
|
||||||
mtime: (i64, u32),
|
mtime: (i64, u32),
|
||||||
}
|
}
|
||||||
|
@ -1597,7 +1596,7 @@ fn op_futime_sync(
|
||||||
_zero_copy: &mut [ZeroCopyBuf],
|
_zero_copy: &mut [ZeroCopyBuf],
|
||||||
) -> Result<Value, AnyError> {
|
) -> Result<Value, AnyError> {
|
||||||
super::check_unstable(state, "Deno.futimeSync");
|
super::check_unstable(state, "Deno.futimeSync");
|
||||||
let rid = args.rid as u32;
|
let rid = args.rid;
|
||||||
let atime = filetime::FileTime::from_unix_time(args.atime.0, args.atime.1);
|
let atime = filetime::FileTime::from_unix_time(args.atime.0, args.atime.1);
|
||||||
let mtime = filetime::FileTime::from_unix_time(args.mtime.0, args.mtime.1);
|
let mtime = filetime::FileTime::from_unix_time(args.mtime.0, args.mtime.1);
|
||||||
|
|
||||||
|
@ -1620,7 +1619,7 @@ async fn op_futime_async(
|
||||||
_zero_copy: BufVec,
|
_zero_copy: BufVec,
|
||||||
) -> Result<Value, AnyError> {
|
) -> Result<Value, AnyError> {
|
||||||
super::check_unstable2(&state, "Deno.futime");
|
super::check_unstable2(&state, "Deno.futime");
|
||||||
let rid = args.rid as u32;
|
let rid = args.rid;
|
||||||
let atime = filetime::FileTime::from_unix_time(args.atime.0, args.atime.1);
|
let atime = filetime::FileTime::from_unix_time(args.atime.0, args.atime.1);
|
||||||
let mtime = filetime::FileTime::from_unix_time(args.mtime.0, args.mtime.1);
|
let mtime = filetime::FileTime::from_unix_time(args.mtime.0, args.mtime.1);
|
||||||
|
|
||||||
|
|
|
@ -55,7 +55,7 @@ pub fn init(rt: &mut deno_core::JsRuntime) {
|
||||||
|
|
||||||
#[derive(Deserialize)]
|
#[derive(Deserialize)]
|
||||||
pub(crate) struct AcceptArgs {
|
pub(crate) struct AcceptArgs {
|
||||||
pub rid: i32,
|
pub rid: u32,
|
||||||
pub transport: String,
|
pub transport: String,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -64,7 +64,7 @@ async fn accept_tcp(
|
||||||
args: AcceptArgs,
|
args: AcceptArgs,
|
||||||
_zero_copy: BufVec,
|
_zero_copy: BufVec,
|
||||||
) -> Result<Value, AnyError> {
|
) -> Result<Value, AnyError> {
|
||||||
let rid = args.rid as u32;
|
let rid = args.rid;
|
||||||
|
|
||||||
let resource = state
|
let resource = state
|
||||||
.borrow()
|
.borrow()
|
||||||
|
@ -125,7 +125,7 @@ async fn op_accept(
|
||||||
|
|
||||||
#[derive(Deserialize)]
|
#[derive(Deserialize)]
|
||||||
pub(crate) struct ReceiveArgs {
|
pub(crate) struct ReceiveArgs {
|
||||||
pub rid: i32,
|
pub rid: u32,
|
||||||
pub transport: String,
|
pub transport: String,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -137,7 +137,7 @@ async fn receive_udp(
|
||||||
assert_eq!(zero_copy.len(), 1, "Invalid number of arguments");
|
assert_eq!(zero_copy.len(), 1, "Invalid number of arguments");
|
||||||
let mut zero_copy = zero_copy[0].clone();
|
let mut zero_copy = zero_copy[0].clone();
|
||||||
|
|
||||||
let rid = args.rid as u32;
|
let rid = args.rid;
|
||||||
|
|
||||||
let resource = state
|
let resource = state
|
||||||
.borrow_mut()
|
.borrow_mut()
|
||||||
|
@ -181,7 +181,7 @@ async fn op_datagram_receive(
|
||||||
|
|
||||||
#[derive(Deserialize)]
|
#[derive(Deserialize)]
|
||||||
struct SendArgs {
|
struct SendArgs {
|
||||||
rid: i32,
|
rid: u32,
|
||||||
transport: String,
|
transport: String,
|
||||||
#[serde(flatten)]
|
#[serde(flatten)]
|
||||||
transport_args: ArgsEnum,
|
transport_args: ArgsEnum,
|
||||||
|
@ -215,7 +215,7 @@ async fn op_datagram_send(
|
||||||
let resource = state
|
let resource = state
|
||||||
.borrow_mut()
|
.borrow_mut()
|
||||||
.resource_table
|
.resource_table
|
||||||
.get::<UdpSocketResource>(rid as u32)
|
.get::<UdpSocketResource>(rid)
|
||||||
.ok_or_else(|| bad_resource("Socket has been closed"))?;
|
.ok_or_else(|| bad_resource("Socket has been closed"))?;
|
||||||
let socket = RcRef::map(&resource, |r| &r.socket).borrow().await;
|
let socket = RcRef::map(&resource, |r| &r.socket).borrow().await;
|
||||||
let byte_length = socket.send_to(&zero_copy, &addr).await?;
|
let byte_length = socket.send_to(&zero_copy, &addr).await?;
|
||||||
|
@ -235,7 +235,7 @@ async fn op_datagram_send(
|
||||||
let resource = state
|
let resource = state
|
||||||
.borrow()
|
.borrow()
|
||||||
.resource_table
|
.resource_table
|
||||||
.get::<net_unix::UnixDatagramResource>(rid as u32)
|
.get::<net_unix::UnixDatagramResource>(rid)
|
||||||
.ok_or_else(|| {
|
.ok_or_else(|| {
|
||||||
custom_error("NotConnected", "Socket has been closed")
|
custom_error("NotConnected", "Socket has been closed")
|
||||||
})?;
|
})?;
|
||||||
|
|
|
@ -65,7 +65,7 @@ pub(crate) async fn accept_unix(
|
||||||
args: AcceptArgs,
|
args: AcceptArgs,
|
||||||
_bufs: BufVec,
|
_bufs: BufVec,
|
||||||
) -> Result<Value, AnyError> {
|
) -> Result<Value, AnyError> {
|
||||||
let rid = args.rid as u32;
|
let rid = args.rid;
|
||||||
|
|
||||||
let resource = state
|
let resource = state
|
||||||
.borrow()
|
.borrow()
|
||||||
|
@ -104,7 +104,7 @@ pub(crate) async fn receive_unix_packet(
|
||||||
) -> Result<Value, AnyError> {
|
) -> Result<Value, AnyError> {
|
||||||
assert_eq!(bufs.len(), 1, "Invalid number of arguments");
|
assert_eq!(bufs.len(), 1, "Invalid number of arguments");
|
||||||
|
|
||||||
let rid = args.rid as u32;
|
let rid = args.rid;
|
||||||
let mut buf = bufs.into_iter().next().unwrap();
|
let mut buf = bufs.into_iter().next().unwrap();
|
||||||
|
|
||||||
let resource = state
|
let resource = state
|
||||||
|
|
|
@ -178,7 +178,7 @@ fn op_run(
|
||||||
#[derive(Deserialize)]
|
#[derive(Deserialize)]
|
||||||
#[serde(rename_all = "camelCase")]
|
#[serde(rename_all = "camelCase")]
|
||||||
pub struct RunStatusArgs {
|
pub struct RunStatusArgs {
|
||||||
rid: i32,
|
rid: u32,
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn op_run_status(
|
async fn op_run_status(
|
||||||
|
@ -186,7 +186,7 @@ async fn op_run_status(
|
||||||
args: RunStatusArgs,
|
args: RunStatusArgs,
|
||||||
_zero_copy: BufVec,
|
_zero_copy: BufVec,
|
||||||
) -> Result<Value, AnyError> {
|
) -> Result<Value, AnyError> {
|
||||||
let rid = args.rid as u32;
|
let rid = args.rid;
|
||||||
|
|
||||||
{
|
{
|
||||||
let s = state.borrow();
|
let s = state.borrow();
|
||||||
|
|
|
@ -63,7 +63,7 @@ pub struct BindSignalArgs {
|
||||||
#[cfg(unix)]
|
#[cfg(unix)]
|
||||||
#[derive(Deserialize)]
|
#[derive(Deserialize)]
|
||||||
pub struct SignalArgs {
|
pub struct SignalArgs {
|
||||||
rid: i32,
|
rid: u32,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(unix)]
|
#[cfg(unix)]
|
||||||
|
@ -93,7 +93,7 @@ async fn op_signal_poll(
|
||||||
_zero_copy: BufVec,
|
_zero_copy: BufVec,
|
||||||
) -> Result<Value, AnyError> {
|
) -> Result<Value, AnyError> {
|
||||||
super::check_unstable2(&state, "Deno.signal");
|
super::check_unstable2(&state, "Deno.signal");
|
||||||
let rid = args.rid as u32;
|
let rid = args.rid;
|
||||||
|
|
||||||
let resource = state
|
let resource = state
|
||||||
.borrow_mut()
|
.borrow_mut()
|
||||||
|
@ -116,7 +116,7 @@ pub fn op_signal_unbind(
|
||||||
_zero_copy: &mut [ZeroCopyBuf],
|
_zero_copy: &mut [ZeroCopyBuf],
|
||||||
) -> Result<Value, AnyError> {
|
) -> Result<Value, AnyError> {
|
||||||
super::check_unstable(state, "Deno.signal");
|
super::check_unstable(state, "Deno.signal");
|
||||||
let rid = args.rid as u32;
|
let rid = args.rid;
|
||||||
state
|
state
|
||||||
.resource_table
|
.resource_table
|
||||||
.close(rid)
|
.close(rid)
|
||||||
|
|
|
@ -98,7 +98,7 @@ async fn op_start_tls(
|
||||||
args: StartTLSArgs,
|
args: StartTLSArgs,
|
||||||
_zero_copy: BufVec,
|
_zero_copy: BufVec,
|
||||||
) -> Result<Value, AnyError> {
|
) -> Result<Value, AnyError> {
|
||||||
let rid = args.rid as u32;
|
let rid = args.rid;
|
||||||
|
|
||||||
let mut domain = args.hostname.as_str();
|
let mut domain = args.hostname.as_str();
|
||||||
if domain.is_empty() {
|
if domain.is_empty() {
|
||||||
|
@ -350,7 +350,7 @@ fn op_listen_tls(
|
||||||
|
|
||||||
#[derive(Deserialize)]
|
#[derive(Deserialize)]
|
||||||
pub struct AcceptTlsArgs {
|
pub struct AcceptTlsArgs {
|
||||||
rid: i32,
|
rid: u32,
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn op_accept_tls(
|
async fn op_accept_tls(
|
||||||
|
@ -358,7 +358,7 @@ async fn op_accept_tls(
|
||||||
args: AcceptTlsArgs,
|
args: AcceptTlsArgs,
|
||||||
_zero_copy: BufVec,
|
_zero_copy: BufVec,
|
||||||
) -> Result<Value, AnyError> {
|
) -> Result<Value, AnyError> {
|
||||||
let rid = args.rid as u32;
|
let rid = args.rid;
|
||||||
|
|
||||||
let resource = state
|
let resource = state
|
||||||
.borrow()
|
.borrow()
|
||||||
|
|
|
@ -225,27 +225,26 @@ fn op_isatty(
|
||||||
) -> Result<Value, AnyError> {
|
) -> Result<Value, AnyError> {
|
||||||
let rid = args.rid;
|
let rid = args.rid;
|
||||||
|
|
||||||
let isatty: bool =
|
let isatty: bool = StdFileResource::with(state, rid, move |r| match r {
|
||||||
StdFileResource::with(state, rid as u32, move |r| match r {
|
Ok(std_file) => {
|
||||||
Ok(std_file) => {
|
#[cfg(windows)]
|
||||||
#[cfg(windows)]
|
{
|
||||||
{
|
use winapi::um::consoleapi;
|
||||||
use winapi::um::consoleapi;
|
|
||||||
|
|
||||||
let handle = get_windows_handle(&std_file)?;
|
let handle = get_windows_handle(&std_file)?;
|
||||||
let mut test_mode: DWORD = 0;
|
let mut test_mode: DWORD = 0;
|
||||||
// If I cannot get mode out of console, it is not a console.
|
// If I cannot get mode out of console, it is not a console.
|
||||||
Ok(unsafe { consoleapi::GetConsoleMode(handle, &mut test_mode) != 0 })
|
Ok(unsafe { consoleapi::GetConsoleMode(handle, &mut test_mode) != 0 })
|
||||||
}
|
|
||||||
#[cfg(unix)]
|
|
||||||
{
|
|
||||||
use std::os::unix::io::AsRawFd;
|
|
||||||
let raw_fd = std_file.as_raw_fd();
|
|
||||||
Ok(unsafe { libc::isatty(raw_fd as libc::c_int) == 1 })
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
_ => Ok(false),
|
#[cfg(unix)]
|
||||||
})?;
|
{
|
||||||
|
use std::os::unix::io::AsRawFd;
|
||||||
|
let raw_fd = std_file.as_raw_fd();
|
||||||
|
Ok(unsafe { libc::isatty(raw_fd as libc::c_int) == 1 })
|
||||||
|
}
|
||||||
|
}
|
||||||
|
_ => Ok(false),
|
||||||
|
})?;
|
||||||
Ok(json!(isatty))
|
Ok(json!(isatty))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -269,7 +268,7 @@ fn op_console_size(
|
||||||
|
|
||||||
let rid = args.rid;
|
let rid = args.rid;
|
||||||
|
|
||||||
let size = StdFileResource::with(state, rid as u32, move |r| match r {
|
let size = StdFileResource::with(state, rid, move |r| match r {
|
||||||
Ok(std_file) => {
|
Ok(std_file) => {
|
||||||
#[cfg(windows)]
|
#[cfg(windows)]
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in a new issue