From 44a555eb1f58d1c1e73a1740d6d0d63459a7fec3 Mon Sep 17 00:00:00 2001 From: Christian Hergert Date: Thu, 9 May 2019 15:23:40 -0700 Subject: [PATCH] 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 7b14010b..c8e13c0c 100644 --- a/src/helpers.c +++ b/src/helpers.c @@ -22,6 +22,7 @@ #include "config.h" +#include #include #ifdef __linux__ # include @@ -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); }