mirror of
https://github.com/crunchy-labs/crunchy-cli.git
synced 2026-01-21 12:12:00 -06:00
Only use tempfile name as windows named pipe name (#305)
This commit is contained in:
parent
ef2898f0e1
commit
7c42f29596
1 changed files with 9 additions and 7 deletions
|
|
@ -86,25 +86,27 @@ impl Drop for TempNamedPipe {
|
|||
|
||||
pub fn temp_named_pipe() -> io::Result<TempNamedPipe> {
|
||||
let (_, path) = tempfile("")?.keep()?;
|
||||
let path = path.to_string_lossy().to_string();
|
||||
let _ = std::fs::remove_file(path.clone());
|
||||
let _ = fs::remove_file(path.clone());
|
||||
|
||||
#[cfg(not(target_os = "windows"))]
|
||||
{
|
||||
nix::unistd::mkfifo(path.as_str(), nix::sys::stat::Mode::S_IRWXU)?;
|
||||
let filename = path.to_string_lossy().to_string();
|
||||
|
||||
nix::unistd::mkfifo(filename.as_str(), nix::sys::stat::Mode::S_IRWXU)?;
|
||||
|
||||
Ok(TempNamedPipe {
|
||||
reader: tokio::net::unix::pipe::OpenOptions::new().open_receiver(&path)?,
|
||||
name: path,
|
||||
name: filename,
|
||||
})
|
||||
}
|
||||
#[cfg(target_os = "windows")]
|
||||
{
|
||||
let path = format!(r"\\.\pipe\{}", &path);
|
||||
let pipe_name = path.file_name().unwrap().to_string_lossy().to_string();
|
||||
let pipe_path = format!(r"\\.\pipe\{}", pipe_name);
|
||||
|
||||
Ok(TempNamedPipe {
|
||||
reader: tokio::net::windows::named_pipe::ServerOptions::new().create(&path)?,
|
||||
name: path,
|
||||
reader: tokio::net::windows::named_pipe::ServerOptions::new().create(pipe_path)?,
|
||||
name: pipe_name,
|
||||
})
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue