[gnome-boxes/wip/image-import: 7/18] util: Add is_mime_type()



commit 2924a036961f3fc9fd466a946174b57a57849321
Author: Zeeshan Ali (Khattak) <zeeshanak gnome org>
Date:   Wed Jun 5 04:02:33 2013 +0300

    util: Add is_mime_type()
    
    Add utility function to determine if given file is on given mimetype.

 src/util-app.vala |    7 +++++++
 1 files changed, 7 insertions(+), 0 deletions(-)
---
diff --git a/src/util-app.vala b/src/util-app.vala
index 0370b0c..836c153 100644
--- a/src/util-app.vala
+++ b/src/util-app.vala
@@ -529,6 +529,13 @@ namespace Boxes {
         return tokens[1];
     }
 
+    public bool is_mime_type (string filename, string mime_type) {
+        var file_type = ContentType.guess (filename, null, null);
+        var supertype = ContentType.from_mime_type (mime_type);
+
+        return ContentType.is_a (file_type, supertype);
+    }
+
     namespace UUID {
         [CCode (cname = "uuid_generate", cheader_filename = "uuid/uuid.h")]
         internal extern static void generate ([CCode (array_length = false)] uchar[] uuid);


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]