[gnome-color-manager] Make gcm-fix-profile open the profile from memory, as then we can catch common access permission err



commit 952c3b841f143f4e226b09b7e02c90e943c47099
Author: Richard Hughes <richard hughsie com>
Date:   Mon Apr 5 16:58:39 2010 +0100

    Make gcm-fix-profile open the profile from memory, as then we can catch common access permission errors

 src/gcm-fix-profile.c |   15 ++++++++++++++-
 1 files changed, 14 insertions(+), 1 deletions(-)
---
diff --git a/src/gcm-fix-profile.c b/src/gcm-fix-profile.c
index bea17c6..5820136 100644
--- a/src/gcm-fix-profile.c
+++ b/src/gcm-fix-profile.c
@@ -35,8 +35,20 @@ gcm_fix_profile_filename (const gchar *filename, const gchar *description, const
 {
 	gboolean ret = TRUE;
 	cmsHPROFILE lcms_profile;
-	lcms_profile = cmsOpenProfileFromFile (filename, "r");
+	gchar *data = NULL;
+	gsize len;
+	GError *error = NULL;
+
+	ret = g_file_get_contents (filename, &data, &len, &error);
+	if (!ret) {
+		g_warning ("failed to open profile: %s", error->message);
+		g_error_free (error);
+		goto out;
+	}
+
+	lcms_profile = cmsOpenProfileFromMem (data, len);
 	if (lcms_profile == NULL || lcms_error_code != 0) {
+		g_warning ("failed to open profile");
 		ret = FALSE;
 		goto out;
 	}
@@ -72,6 +84,7 @@ gcm_fix_profile_filename (const gchar *filename, const gchar *description, const
 out:
 	if (lcms_profile != NULL)
 		cmsCloseProfile (lcms_profile);
+	g_free (data);
 	return ret;
 }
 



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