From 77974a4367581d10fe81eba10a28617ec54627a4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=99=BD=E5=B1=B1=E9=A2=A8=E9=9C=B2?= Date: Tue, 20 Feb 2024 10:41:35 +0900 Subject: [PATCH] Stubbing unix-dependent values on Windows (#8036) Release Notes: - N/A --- crates/fs/src/fs.rs | 14 ++++++++++++-- crates/terminal/src/terminal.rs | 16 +++++++++++++--- 2 files changed, 25 insertions(+), 5 deletions(-) diff --git a/crates/fs/src/fs.rs b/crates/fs/src/fs.rs index 885b94e3a3..968c1795f1 100644 --- a/crates/fs/src/fs.rs +++ b/crates/fs/src/fs.rs @@ -11,6 +11,9 @@ use fsevent::StreamFlags; #[cfg(not(target_os = "macos"))] use notify::{Config, EventKind, Watcher}; +#[cfg(unix)] +use std::os::unix::fs::MetadataExt; + use futures::{future::BoxFuture, Stream, StreamExt}; use git2::Repository as LibGitRepository; use parking_lot::Mutex; @@ -21,7 +24,6 @@ use std::io::Write; use std::sync::Arc; use std::{ io, - os::unix::fs::MetadataExt, path::{Component, Path, PathBuf}, pin::Pin, time::{Duration, SystemTime}, @@ -239,8 +241,16 @@ impl Fs for RealFs { } else { symlink_metadata }; + + #[cfg(unix)] + let inode = metadata.ino(); + + // todo!(windows) + #[cfg(windows)] + let inode = 0; + Ok(Some(Metadata { - inode: metadata.ino(), + inode, mtime: metadata.modified().unwrap(), is_symlink, is_dir: metadata.file_type().is_dir(), diff --git a/crates/terminal/src/terminal.rs b/crates/terminal/src/terminal.rs index 0ac714dd7b..c1a023da00 100644 --- a/crates/terminal/src/terminal.rs +++ b/crates/terminal/src/terminal.rs @@ -45,13 +45,15 @@ use std::{ cmp::{self, min}, fmt::Display, ops::{Deref, Index, RangeInclusive}, - os::unix::prelude::AsRawFd, path::PathBuf, sync::Arc, time::Duration, }; use thiserror::Error; +#[cfg(unix)] +use std::os::unix::prelude::AsRawFd; + use gpui::{ actions, black, px, AnyWindowHandle, AppContext, Bounds, ClipboardItem, EventEmitter, Hsla, Keystroke, ModelContext, Modifiers, MouseButton, MouseDownEvent, MouseMoveEvent, MouseUpEvent, @@ -376,8 +378,12 @@ impl TerminalBuilder { } }; - let fd = pty.file().as_raw_fd(); - let shell_pid = pty.child().id(); + #[cfg(unix)] + let (fd, shell_pid) = (pty.file().as_raw_fd(), pty.child().id()); + + // todo!(windows) + #[cfg(windows)] + let (fd, shell_pid) = (-1, 0); //And connect them together let event_loop = EventLoop::new( @@ -641,7 +647,11 @@ impl Terminal { /// Updates the cached process info, returns whether the Zed-relevant info has changed fn update_process_info(&mut self) -> bool { + #[cfg(unix)] let mut pid = unsafe { libc::tcgetpgrp(self.shell_fd as i32) }; + // todo!(windows) + #[cfg(windows)] + let mut pid = -1; if pid < 0 { pid = self.shell_pid as i32; }