mirror of
https://github.com/libretro/RetroArch
synced 2025-04-11 00:44:20 +00:00
(platform_linux.c) Use retro_dirent.h
This commit is contained in:
parent
b79c2ced37
commit
f7f32f522d
@ -20,12 +20,6 @@
|
|||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <dirent.h>
|
|
||||||
#ifndef _DIRENT_HAVE_D_TYPE
|
|
||||||
#include <sys/stat.h>
|
|
||||||
#endif
|
|
||||||
#include <unistd.h>
|
|
||||||
#include <dirent.h>
|
|
||||||
|
|
||||||
#if defined(HW_RVL) && !defined(IS_SALAMANDER)
|
#if defined(HW_RVL) && !defined(IS_SALAMANDER)
|
||||||
#include <ogc/mutex.h>
|
#include <ogc/mutex.h>
|
||||||
|
@ -21,7 +21,7 @@
|
|||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
#include <dirent.h>
|
#include <retro_dirent.h>
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <sys/utsname.h>
|
#include <sys/utsname.h>
|
||||||
@ -359,37 +359,33 @@ bool frontend_linux_powerstate_check_apm(enum frontend_powerstate *state,
|
|||||||
bool frontend_linux_powerstate_check_acpi(enum frontend_powerstate *state,
|
bool frontend_linux_powerstate_check_acpi(enum frontend_powerstate *state,
|
||||||
int *seconds, int *percent)
|
int *seconds, int *percent)
|
||||||
{
|
{
|
||||||
struct dirent *dent = NULL;
|
bool ret = false;
|
||||||
DIR *dirp = NULL;
|
struct RDIR *entry = NULL;
|
||||||
bool have_battery = false;
|
bool have_battery = false;
|
||||||
bool have_ac = false;
|
bool have_ac = false;
|
||||||
bool charging = false;
|
bool charging = false;
|
||||||
|
|
||||||
*state = FRONTEND_POWERSTATE_NONE;
|
*state = FRONTEND_POWERSTATE_NONE;
|
||||||
|
|
||||||
dirp = opendir(proc_acpi_battery_path);
|
entry = retro_opendir(proc_acpi_battery_path);
|
||||||
if (dirp == NULL)
|
if (!entry)
|
||||||
return false; /* can't use this interface. */
|
goto end;
|
||||||
|
|
||||||
while ((dent = readdir(dirp)) != NULL)
|
if (retro_dirent_error(entry))
|
||||||
{
|
goto end;
|
||||||
const char *node = dent->d_name;
|
|
||||||
check_proc_acpi_battery(node, &have_battery, &charging,
|
|
||||||
seconds, percent);
|
|
||||||
}
|
|
||||||
closedir(dirp);
|
|
||||||
|
|
||||||
dirp = opendir(proc_acpi_ac_adapter_path);
|
while (retro_readdir(entry))
|
||||||
if (dirp == NULL)
|
check_proc_acpi_battery(retro_dirent_get_name(entry),
|
||||||
return false; /* can't use this interface. */
|
&have_battery, &charging, seconds, percent);
|
||||||
|
|
||||||
while ((dent = readdir(dirp)) != NULL)
|
retro_closedir(entry);
|
||||||
{
|
|
||||||
const char *node = dent->d_name;
|
|
||||||
|
|
||||||
check_proc_acpi_ac_adapter(node, &have_ac);
|
entry = retro_opendir(proc_acpi_ac_adapter_path);
|
||||||
}
|
if (!entry)
|
||||||
closedir(dirp);
|
goto end;
|
||||||
|
|
||||||
|
while (retro_readdir(entry))
|
||||||
|
check_proc_acpi_ac_adapter(retro_dirent_get_name(entry), &have_ac);
|
||||||
|
|
||||||
if (!have_battery)
|
if (!have_battery)
|
||||||
*state = FRONTEND_POWERSTATE_NO_SOURCE;
|
*state = FRONTEND_POWERSTATE_NO_SOURCE;
|
||||||
@ -400,7 +396,13 @@ bool frontend_linux_powerstate_check_acpi(enum frontend_powerstate *state,
|
|||||||
else
|
else
|
||||||
*state = FRONTEND_POWERSTATE_ON_POWER_SOURCE;
|
*state = FRONTEND_POWERSTATE_ON_POWER_SOURCE;
|
||||||
|
|
||||||
return true; /* definitive answer. */
|
ret = true;
|
||||||
|
|
||||||
|
end:
|
||||||
|
if (entry)
|
||||||
|
retro_closedir(entry);
|
||||||
|
|
||||||
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
static enum frontend_powerstate
|
static enum frontend_powerstate
|
||||||
|
Loading…
x
Reference in New Issue
Block a user