From f7f32f522d4743077c10623082ad348f10dfbb1e Mon Sep 17 00:00:00 2001 From: twinaphex Date: Fri, 4 Sep 2015 20:37:18 +0200 Subject: [PATCH] (platform_linux.c) Use retro_dirent.h --- frontend/drivers/platform_gx.c | 6 ---- frontend/drivers/platform_linux.c | 48 ++++++++++++++++--------------- 2 files changed, 25 insertions(+), 29 deletions(-) diff --git a/frontend/drivers/platform_gx.c b/frontend/drivers/platform_gx.c index 9fe0d9eadf..77abac8269 100644 --- a/frontend/drivers/platform_gx.c +++ b/frontend/drivers/platform_gx.c @@ -20,12 +20,6 @@ #include #include #include -#include -#ifndef _DIRENT_HAVE_D_TYPE -#include -#endif -#include -#include #if defined(HW_RVL) && !defined(IS_SALAMANDER) #include diff --git a/frontend/drivers/platform_linux.c b/frontend/drivers/platform_linux.c index be203581a9..28e4e1c355 100644 --- a/frontend/drivers/platform_linux.c +++ b/frontend/drivers/platform_linux.c @@ -21,7 +21,7 @@ #include #include -#include +#include #include #include #include @@ -359,37 +359,33 @@ bool frontend_linux_powerstate_check_apm(enum frontend_powerstate *state, bool frontend_linux_powerstate_check_acpi(enum frontend_powerstate *state, int *seconds, int *percent) { - struct dirent *dent = NULL; - DIR *dirp = NULL; + bool ret = false; + struct RDIR *entry = NULL; bool have_battery = false; bool have_ac = false; bool charging = false; *state = FRONTEND_POWERSTATE_NONE; - dirp = opendir(proc_acpi_battery_path); - if (dirp == NULL) - return false; /* can't use this interface. */ + entry = retro_opendir(proc_acpi_battery_path); + if (!entry) + goto end; - while ((dent = readdir(dirp)) != NULL) - { - const char *node = dent->d_name; - check_proc_acpi_battery(node, &have_battery, &charging, - seconds, percent); - } - closedir(dirp); + if (retro_dirent_error(entry)) + goto end; - dirp = opendir(proc_acpi_ac_adapter_path); - if (dirp == NULL) - return false; /* can't use this interface. */ + while (retro_readdir(entry)) + check_proc_acpi_battery(retro_dirent_get_name(entry), + &have_battery, &charging, seconds, percent); - while ((dent = readdir(dirp)) != NULL) - { - const char *node = dent->d_name; + retro_closedir(entry); - check_proc_acpi_ac_adapter(node, &have_ac); - } - closedir(dirp); + entry = retro_opendir(proc_acpi_ac_adapter_path); + if (!entry) + goto end; + + while (retro_readdir(entry)) + check_proc_acpi_ac_adapter(retro_dirent_get_name(entry), &have_ac); if (!have_battery) *state = FRONTEND_POWERSTATE_NO_SOURCE; @@ -400,7 +396,13 @@ bool frontend_linux_powerstate_check_acpi(enum frontend_powerstate *state, else *state = FRONTEND_POWERSTATE_ON_POWER_SOURCE; - return true; /* definitive answer. */ + ret = true; + +end: + if (entry) + retro_closedir(entry); + + return ret; } static enum frontend_powerstate