Avoid using unix-specific methods on windows
This commit is contained in:
parent
99531d757c
commit
ae6dbb945b
1 changed files with 23 additions and 1 deletions
|
|
@ -4,8 +4,23 @@ use std::process::{Child, ChildStdin, Command, Stdio};
|
|||
use std::str;
|
||||
use tree_sitter::Parser;
|
||||
|
||||
#[cfg(windows)]
|
||||
pub(crate) struct LogSession();
|
||||
|
||||
#[cfg(windows)]
|
||||
pub(crate) fn start_logging_graphs(parser: &mut Parser, path: &str) -> Result<LogSession> {
|
||||
Ok(LogSession())
|
||||
}
|
||||
|
||||
#[cfg(windows)]
|
||||
pub(crate) fn stop_logging_graphs(parser: &mut Parser, mut session: LogSession) -> Result<()> {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[cfg(unix)]
|
||||
pub(crate) struct LogSession(Child, ChildStdin);
|
||||
|
||||
#[cfg(unix)]
|
||||
pub(crate) fn start_logging_graphs(parser: &mut Parser, path: &str) -> Result<LogSession> {
|
||||
let mut dot_file = File::create(path)?;
|
||||
dot_file.write(b"<!DOCTYPE html>\n<style>svg { width: 100%; }</style>\n\n")?;
|
||||
|
|
@ -19,13 +34,20 @@ pub(crate) fn start_logging_graphs(parser: &mut Parser, path: &str) -> Result<Lo
|
|||
.stdin
|
||||
.take()
|
||||
.expect("Failed to open stdin for Dot");
|
||||
|
||||
parser.print_dot_graphs(&dot_stdin);
|
||||
|
||||
Ok(LogSession(dot_process, dot_stdin))
|
||||
}
|
||||
|
||||
#[cfg(unix)]
|
||||
pub(crate) fn stop_logging_graphs(parser: &mut Parser, mut session: LogSession) -> Result<()> {
|
||||
drop(session.1);
|
||||
parser.stop_printing_dot_graphs();
|
||||
|
||||
if cfg!(unix) {
|
||||
parser.stop_printing_dot_graphs();
|
||||
}
|
||||
|
||||
session.0.wait()?;
|
||||
|
||||
if cfg!(target_os = "macos") {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue