diff options
author | Harshit Jain <harshitjain6751@gmail.com> | 2018-05-04 14:54:37 +0530 |
---|---|---|
committer | Isaac Chen <isaacchen@isaacchen.cn> | 2018-07-13 00:03:17 +0000 |
commit | ad9a011a075ae2ff64c5110c6ea9c288fa3bfe17 (patch) | |
tree | e71e34c8f52ac984c11dce7701cf03dbea6e2192 /light | |
parent | 9cfa4c0be9451ea33d54e0173b9b4978d7ca9906 (diff) |
wayne: light: Throw a warning if path stream ain't valid
Diffstat (limited to 'light')
-rw-r--r-- | light/Light.cpp | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/light/Light.cpp b/light/Light.cpp index c170ae2..786e8c2 100644 --- a/light/Light.cpp +++ b/light/Light.cpp @@ -39,7 +39,14 @@ namespace implementation { */ static void set(std::string path, std::string value) { std::ofstream file(path); - file << value; + /* Only write brightness value if stream is open, alive & well */ + if (file.is_open()) { + file << value; + } else { + /* Fire a warning a bail out */ + ALOGE("failed to write %s to %s", value.c_str(), path.c_str()); + return; + } } static void set(std::string path, int value) { |