[fractal] create get_file_media_info
- From: Alexandre Franke <afranke src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [fractal] create get_file_media_info
- Date: Mon, 25 Feb 2019 21:27:56 +0000 (UTC)
commit e795177d27cf73b833fe6400386a5b148d61a611
Author: mairandomness <mairakodama gmail com>
Date: Mon Feb 25 14:41:41 2019 -0500
create get_file_media_info
fractal-gtk/src/appop/message.rs | 14 ++++++++++++++
1 file changed, 14 insertions(+)
---
diff --git a/fractal-gtk/src/appop/message.rs b/fractal-gtk/src/appop/message.rs
index 95f2ff18..b0f11898 100644
--- a/fractal-gtk/src/appop/message.rs
+++ b/fractal-gtk/src/appop/message.rs
@@ -276,6 +276,7 @@ impl AppOp {
let info = match mtype {
"m.image" => get_image_media_info(path_string, mime.as_ref()),
"m.audio" => get_audio_media_info(path_string, mime.as_ref()),
+ "m.file" => get_file_media_info(path_string, mime.as_ref()),
_ => None,
};
@@ -540,3 +541,16 @@ fn get_audio_media_info(file: &str, mimetype: &str) -> Option<JsonValue> {
Some(info)
}
+
+fn get_file_media_info(file: &str, mimetype: &str) -> Option<JsonValue> {
+ let size = fs::metadata(file).ok()?.len();
+
+ let info = json!({
+ "info": {
+ "size": size,
+ "mimetype": mimetype,
+ }
+ });
+
+ Some(info)
+}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]