use super::*;
impl PlatformInterface for Platform {
fn make_shebang_command(
config: &Config,
path: &Path,
shebang: Shebang,
working_directory: Option<&Path>,
) -> Result<Command, OutputError> {
use std::borrow::Cow;
let command = if shebang.interpreter.contains('/') {
let mut cygpath = Command::resolve(&config.cygpath);
if let Some(working_directory) = working_directory {
cygpath.current_dir(working_directory);
}
cygpath
.arg("--windows")
.arg(shebang.interpreter)
.stdin(Stdio::null())
.stdout(Stdio::piped())
.stderr(Stdio::piped());
Cow::Owned(cygpath.output_guard_stdout()?)
} else {
Cow::Borrowed(shebang.interpreter)
};
let mut cmd = Command::resolve(command.as_ref());
if let Some(working_directory) = working_directory {
cmd.current_dir(working_directory);
}
if let Some(argument) = shebang.argument {
cmd.arg(argument);
}
cmd.arg(path);
Ok(cmd)
}
fn set_execute_permission(_path: &Path) -> io::Result<()> {
Ok(())
}
fn signal_from_exit_status(_exit_status: process::ExitStatus) -> Option<i32> {
None
}
fn convert_native_path(config: &Config, working_directory: &Path, path: &Path) -> FunctionResult {
let mut cygpath = Command::resolve(&config.cygpath);
cygpath
.current_dir(working_directory)
.arg("--unix")
.arg(path)
.stdin(Stdio::null())
.stdout(Stdio::piped())
.stderr(Stdio::piped());
match cygpath.output_guard_stdout() {
Ok(shell_path) => Ok(shell_path),
Err(_) => path
.to_str()
.map(str::to_string)
.ok_or_else(|| String::from("Error getting current directory: unicode decode error")),
}
}
fn install_signal_handler<T: Fn(Signal) + Send + 'static>(handler: T) -> RunResult<'static> {
ctrlc::set_handler(move || handler(Signal::Interrupt))
.map_err(|source| Error::SignalHandlerInstall { source })
}
}