[f-spot] Check if file exists for GIO



commit f690055fa8d27fff23f9c438bc11f12c49debd3a
Author: Paul Wellner Bou <paul purecodes org>
Date:   Fri May 21 14:25:41 2010 +0200

    Check if file exists for GIO
    
    https://bugzilla.gnome.org/show_bug.cgi?id=619282

 src/Imaging/ImageFile.cs |    9 +++++++--
 1 files changed, 7 insertions(+), 2 deletions(-)
---
diff --git a/src/Imaging/ImageFile.cs b/src/Imaging/ImageFile.cs
index be20669..c974c9f 100644
--- a/src/Imaging/ImageFile.cs
+++ b/src/Imaging/ImageFile.cs
@@ -205,8 +205,13 @@ namespace FSpot {
 			Type t = (Type) name_table [extension];
 
 			if (t == null) {
-				GLib.FileInfo info = GLib.FileFactory.NewForUri (uri).QueryInfo ("standard::type,standard::content-type", GLib.FileQueryInfoFlags.None, null);
-				t = (Type) name_table [info.ContentType];
+				// check if GIO can find the file, which is not the case
+				// with filenames with invalid encoding
+				GLib.File f = GLib.FileFactory.NewForUri (uri);
+				if (f.QueryExists (null)) {
+					GLib.FileInfo info = f.QueryInfo ("standard::type,standard::content-type", GLib.FileQueryInfoFlags.None, null);
+					t = (Type) name_table [info.ContentType];
+				}
 			}
 
 			return t;



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