intermodal/src/platform_interface.rs
Casey Rodarmor 3739a92857
Support creating multi-file torrents
type: added
2020-04-07 19:01:04 -07:00

38 lines
813 B
Rust

use crate::common::*;
pub(crate) trait PlatformInterface {
fn open(path: &Path) -> Result<(), Error> {
let mut command = Self::opener()?;
command.push(OsString::from(path));
let command_string = || {
command
.iter()
.map(|arg| arg.to_string_lossy().into_owned())
.collect::<Vec<String>>()
.join(",")
};
let status = Command::new(&command[0])
.args(&command[1..])
.status()
.map_err(|source| Error::CommandInvoke {
source,
command: command_string(),
})?;
if status.success() {
Ok(())
} else {
Err(Error::CommandStatus {
command: command_string(),
status,
})
}
}
fn opener() -> Result<Vec<OsString>, Error>;
fn hidden(path: &Path) -> Result<bool, Error>;
}