Add helper: get_tempfile()
This commit is contained in:
parent
adf12992bb
commit
62ced34964
1 changed files with 13 additions and 0 deletions
13
src/ui/external/mod.rs
vendored
13
src/ui/external/mod.rs
vendored
|
@ -1 +1,14 @@
|
||||||
|
use std::fs::File;
|
||||||
|
|
||||||
pub mod editor;
|
pub mod editor;
|
||||||
|
|
||||||
|
pub fn get_tempfile(ext: &str) -> Option<(String, File)> {
|
||||||
|
use rand::random;
|
||||||
|
|
||||||
|
let randomname = format!("/tmp/imag-{}.{}", random::<u64>(), ext);
|
||||||
|
debug!("Attempting to create tempfile at {}", randomname);
|
||||||
|
File::create(randomname.clone())
|
||||||
|
.map_err(|e| debug!(" Error -> {}", e))
|
||||||
|
.ok()
|
||||||
|
.map(|f| (randomname, f))
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in a new issue