[sysprof/wip/chergert/sysprof-3] helpers: use old API for older systems



commit 587d834f6733b029c223765f68456ae460bcf4b4
Author: Christian Hergert <chergert redhat com>
Date:   Thu May 9 15:23:40 2019 -0700

    helpers: use old API for older systems

 src/helpers.c | 16 ++++++++--------
 1 file changed, 8 insertions(+), 8 deletions(-)
---
diff --git a/src/helpers.c b/src/helpers.c
index 7b14010..c8e13c0 100644
--- a/src/helpers.c
+++ b/src/helpers.c
@@ -22,6 +22,7 @@
 
 #include "config.h"
 
+#include <gio/gio.h>
 #include <errno.h>
 #ifdef __linux__
 # include <linux/perf_event.h>
@@ -262,6 +263,7 @@ helpers_get_proc_file (const gchar  *path,
                        gsize        *len)
 {
   g_autofree gchar *canon = NULL;
+  g_autoptr(GFile) file = NULL;
 
   g_assert (path != NULL);
   g_assert (contents != NULL);
@@ -270,13 +272,11 @@ helpers_get_proc_file (const gchar  *path,
   *contents = NULL;
   *len = 0;
 
-  canon = g_canonicalize_filename (path, "/proc/");
+  /* Canonicalize filename */
+  file = g_file_new_for_path (path);
+  canon = g_file_get_path (file);
 
-  if (!g_str_has_prefix (canon, "/proc/"))
-    return FALSE;
-
-  if (!g_file_get_contents (canon, contents, len, NULL))
-    return FALSE;
-
-  return TRUE;
+  return g_file_is_native (file) &&
+         g_str_has_prefix (canon, "/proc/") &&
+         g_file_get_contents (canon, contents, len, NULL);
 }


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