helpers: use old API for older systems

This commit is contained in:
Christian Hergert
2019-05-09 15:23:40 -07:00
parent 1bd0107c54
commit 44a555eb1f

View File

@ -22,6 +22,7 @@
#include "config.h" #include "config.h"
#include <gio/gio.h>
#include <errno.h> #include <errno.h>
#ifdef __linux__ #ifdef __linux__
# include <linux/perf_event.h> # include <linux/perf_event.h>
@ -262,6 +263,7 @@ helpers_get_proc_file (const gchar *path,
gsize *len) gsize *len)
{ {
g_autofree gchar *canon = NULL; g_autofree gchar *canon = NULL;
g_autoptr(GFile) file = NULL;
g_assert (path != NULL); g_assert (path != NULL);
g_assert (contents != NULL); g_assert (contents != NULL);
@ -270,13 +272,11 @@ helpers_get_proc_file (const gchar *path,
*contents = NULL; *contents = NULL;
*len = 0; *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 g_file_is_native (file) &&
return FALSE; g_str_has_prefix (canon, "/proc/") &&
g_file_get_contents (canon, contents, len, NULL);
if (!g_file_get_contents (canon, contents, len, NULL))
return FALSE;
return TRUE;
} }