creat shutdown.h i system_utils.h
fix: arreglants uns includes per a windows
This commit is contained in:
47
source/shutdown.h
Normal file
47
source/shutdown.h
Normal file
@@ -0,0 +1,47 @@
|
||||
#pragma once
|
||||
|
||||
// Utilidad multiplataforma para apagar el sistema de forma segura
|
||||
namespace SystemShutdown {
|
||||
|
||||
// Códigos de resultado para las operaciones de apagado
|
||||
enum class ShutdownResult {
|
||||
SUCCESS = 0,
|
||||
ERROR_PERMISSION, // Error de permisos insuficientes
|
||||
ERROR_SYSTEM_CALL, // Error en la llamada al sistema
|
||||
ERROR_FORK_FAILED, // Error al crear proceso hijo (Unix)
|
||||
ERROR_UNSUPPORTED // Sistema operativo no soportado
|
||||
};
|
||||
|
||||
// Configuración para el apagado del sistema
|
||||
struct ShutdownConfig {
|
||||
int delay_seconds;
|
||||
bool force_close_apps;
|
||||
const char* shutdown_message;
|
||||
|
||||
// Constructor con valores por defecto
|
||||
ShutdownConfig()
|
||||
: delay_seconds(5)
|
||||
, force_close_apps(true)
|
||||
, shutdown_message("El sistema se apagará...")
|
||||
{}
|
||||
};
|
||||
|
||||
// Apaga el sistema con configuración por defecto
|
||||
ShutdownResult shutdownSystem();
|
||||
|
||||
// Apaga el sistema con configuración personalizada
|
||||
ShutdownResult shutdownSystem(const ShutdownConfig& config);
|
||||
|
||||
// Apaga el sistema con parámetros simples
|
||||
ShutdownResult shutdownSystem(int delay_seconds, bool force_apps = true);
|
||||
|
||||
// Convierte un código de resultado a string descriptivo
|
||||
const char* resultToString(ShutdownResult result);
|
||||
|
||||
// Verifica si el sistema actual soporta apagado programático
|
||||
bool isShutdownSupported();
|
||||
|
||||
// Obtiene información sobre los permisos necesarios en la plataforma actual
|
||||
const char* getRequiredPermissions();
|
||||
|
||||
} // namespace SystemShutdown
|
||||
Reference in New Issue
Block a user