fix: stop segfaulting on non-existent directories
This commit is contained in:
@@ -3,6 +3,7 @@
|
||||
#include <stdbool.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include "log.h"
|
||||
#include "utils.h"
|
||||
|
||||
#include "config.h"
|
||||
@@ -17,6 +18,10 @@ char
|
||||
/* open up the battery capacity for reading */
|
||||
d = concat(battery_status_path, "/capacity");
|
||||
f = fopen(d, "r");
|
||||
if (!f) {
|
||||
log_fatal("battery directory does not exist");
|
||||
return NULL;
|
||||
}
|
||||
free(d);
|
||||
|
||||
/* create enough space for the battery percentage */
|
||||
|
Reference in New Issue
Block a user