Added a basic check to make sure we don't try to transcode a partially written file
This commit is contained in:
16
src/util/io.rs
Normal file
16
src/util/io.rs
Normal file
@@ -0,0 +1,16 @@
|
||||
use std::process;
|
||||
|
||||
// checks whether a file is currently open in another program (e.g. still being written)
|
||||
pub fn is_file_locked(filepath: &str) -> bool {
|
||||
let cmd = process::Command::new("/usr/bin/lsof")
|
||||
.arg(filepath)
|
||||
.output()
|
||||
.expect("Failed to execute command");
|
||||
|
||||
let results = &String::from_utf8_lossy(&cmd.stdout);
|
||||
if results.contains(filepath) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
1
src/util/mod.rs
Normal file
1
src/util/mod.rs
Normal file
@@ -0,0 +1 @@
|
||||
pub mod io;
|
||||
Reference in New Issue
Block a user