mirror of
https://github.com/varun-r-mallya/sysprof.git
synced 2025-12-31 20:36:25 +00:00
helpers: use old API for older systems
This commit is contained in:
@ -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);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user