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