|
|
@ -1,4 +1,5 @@ |
|
|
|
#include <dirent.h> |
|
|
|
#include <dirent.h> |
|
|
|
|
|
|
|
#include <fcntl.h> |
|
|
|
#include <stdio.h> |
|
|
|
#include <stdio.h> |
|
|
|
#include <stdlib.h> |
|
|
|
#include <stdlib.h> |
|
|
|
#include <string.h> |
|
|
|
#include <string.h> |
|
|
@ -31,11 +32,11 @@ static char * powerstatefile = "/sys/power/state"; |
|
|
|
void |
|
|
|
void |
|
|
|
writefile(char *filepath, char *str) |
|
|
|
writefile(char *filepath, char *str) |
|
|
|
{ |
|
|
|
{ |
|
|
|
FILE *f; |
|
|
|
int f; |
|
|
|
f = fopen(filepath, "w"); |
|
|
|
f = open(filepath, O_WRONLY); |
|
|
|
if (f) { |
|
|
|
if (f != NULL) { |
|
|
|
fprintf(f, "%s\n", str); |
|
|
|
write(f, str, strlen(str)); |
|
|
|
fclose(f); |
|
|
|
close(f); |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
fprintf(stderr, "Couldn't open filepath <%s>\n", filepath); |
|
|
|
fprintf(stderr, "Couldn't open filepath <%s>\n", filepath); |
|
|
|
} |
|
|
|
} |
|
|
|