Skip to content

Commit

Permalink
Use tempfile crate to create tempfile
Browse files Browse the repository at this point in the history
Removes dependency on nix
Adds dependency on tempfile

Fixes build failure on MacOS due to absence of `O_TMPFILE`

Fixes kevincox#7
  • Loading branch information
n8henrie committed Jan 2, 2019
1 parent 3c42078 commit fb97516
Show file tree
Hide file tree
Showing 5 changed files with 140 additions and 33 deletions.
157 changes: 135 additions & 22 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ futures-cpupool = "0.1"
hyper = "0.11"
lazy_static = "1.0.0"
lru-cache = "0.1.1"
nix = "0.9"
os_pipe = "0.6"
percent-encoding = "1.0"
pnet = "0.21.0"
Expand All @@ -22,6 +21,7 @@ serde-xml-rs = "0.2"
serde_derive = "1.0"
serde_json = "1.0"
smallvec = "0.6.2"
tempfile = "^3.0"
tokio-core = "0.1"
tokio-file-unix = "0.4"
tokio-io = "0.1"
Expand Down
1 change: 0 additions & 1 deletion src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ error_chain!{
Io(::std::io::Error);
Json(::serde_json::Error);
KXml(::xml::Error);
Nix(::nix::Error);
Utf8Error(::std::str::Utf8Error);
Xml(::serde_xml_rs::Error);
}
Expand Down
11 changes: 3 additions & 8 deletions src/ffmpeg.rs
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
use futures;
use futures::stream::Stream;
use nix;
use os_pipe::IntoStdio;
use os_pipe;
use serde_json;
use std;
use std::io::{Write};
use std::os::unix::fs::FileExt;
use std::os::unix::io::FromRawFd;
use tempfile;

use error::ResultExt;

Expand Down Expand Up @@ -345,12 +344,8 @@ impl futures::Stream for MediaStream {

pub fn transcode(source: &Format, target: &Format, input: Input, exec: &::Executors)
-> ::Result<std::sync::Arc<::Media>> {
let fd = nix::fcntl::open(
"/tmp",
{ use nix::fcntl::*; O_APPEND | O_CLOEXEC | O_TMPFILE | O_RDWR },
{ use nix::sys::stat::*; S_IRUSR | S_IWUSR })?;
let file = unsafe { std::fs::File::from_raw_fd(fd) };

let file = tempfile::tempfile().expect("Error opening tempfile");

let mut cmd = start_ffmpeg();
// cmd.stderr(std::process::Stdio::null());
add_input(input, exec, &mut cmd)?;
Expand Down
2 changes: 1 addition & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ extern crate futures_cpupool;
#[macro_use] extern crate hyper;
#[macro_use] extern crate lazy_static;
extern crate lru_cache;
extern crate nix;
extern crate os_pipe;
extern crate percent_encoding;
extern crate regex;
Expand All @@ -16,6 +15,7 @@ extern crate serde;
extern crate serde_json;
extern crate serde_xml_rs;
extern crate smallvec;
extern crate tempfile;
extern crate tokio_core;
extern crate tokio_file_unix;
extern crate tokio_io;
Expand Down

0 comments on commit fb97516

Please sign in to comment.