diff options
author | Aaron Ball <nullspoon@oper.io> | 2017-12-24 13:59:28 -0700 |
---|---|---|
committer | Aaron Ball <nullspoon@oper.io> | 2017-12-24 13:59:28 -0700 |
commit | efd02b9c1eeba985b5c431b4a02b2cd060561227 (patch) | |
tree | 82a38dbd2e485d5a1a1b542b3cd31c6e41766e4c | |
parent | 5fa3aee08a78889ec99adb85b009fdac39f028e0 (diff) | |
parent | 782d023a32a047c3d19ec6a21318587c6446de48 (diff) | |
download | luminous-efd02b9c1eeba985b5c431b4a02b2cd060561227.tar.gz luminous-efd02b9c1eeba985b5c431b4a02b2cd060561227.tar.xz |
Merge branch 'errno'v1.0
-rw-r--r-- | src/main.c | 17 |
1 files changed, 15 insertions, 2 deletions
@@ -18,6 +18,7 @@ #include <stdlib.h> #include <string.h> #include <time.h> +#include <errno.h> struct props { @@ -78,8 +79,14 @@ int fadeup(struct props* props) { nanosleep(&tim, &tim2); FILE* fd = fopen(props->filebrightness, "w"); - if(! fd) + if(! fd) { + if(errno == EACCES) { + fprintf(stderr, "Permission denied: %s\n", props->filebrightness); + } else { + fprintf(stderr, "Could not open file %s\n", props->filebrightness); + } return -1; + } // Write the new brightness to the brightness file fprintf(fd, "%d\n", props->cur); @@ -117,8 +124,14 @@ int fadedown(struct props* props) { nanosleep(&tim, &tim2); FILE* fd = fopen(props->filebrightness, "w"); - if(! fd) + if(! fd) { + if(errno == EACCES) { + fprintf(stderr, "Permission denied: %s\n", props->filebrightness); + } else { + fprintf(stderr, "Could not open file %s\n", props->filebrightness); + } return -1; + } // Write the new brightness to the brightness file fprintf(fd, "%d\n", props->cur); |