diff options
author | rabite <rabite@posteo.de> | 2019-03-31 03:28:07 +0200 |
---|---|---|
committer | rabite <rabite@posteo.de> | 2019-03-31 03:28:07 +0200 |
commit | ed32c83aca9acf40b09c5fb4e7a24cbc2d76d7c9 (patch) | |
tree | 1f7105b67257fcc41ba348ce01e662540e3c672f /src/files.rs | |
parent | ed6abefc3c4876bc1ea7dade58909fc161706b60 (diff) |
finally fixed memory leak
Diffstat (limited to 'src/files.rs')
-rw-r--r-- | src/files.rs | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/src/files.rs b/src/files.rs index aa0fa72..a1c5592 100644 --- a/src/files.rs +++ b/src/files.rs @@ -10,7 +10,7 @@ use std::os::unix::ffi::{OsStringExt, OsStrExt}; use std::ffi::{OsStr, OsString}; use lscolors::LsColors; -use mime_detective; +use tree_magic; use users::{get_current_username, get_current_groupname, get_user_by_uid, @@ -717,10 +717,12 @@ impl File { Ok((size, unit)) } - pub fn get_mime(&self) -> Option<String> { - let detective = mime_detective::MimeDetective::new().ok()?; - let mime = detective.detect_filepath(&self.path).ok()?; - Some(mime.type_().as_str().to_string()) + // pub fn get_mime(&self) -> String { + // tree_magic::from_filepath(&self.path) + // } + + pub fn is_text(&self) -> bool { + tree_magic::match_filepath("text/plain", &self.path) } |