wayne: light: Throw a warning if path stream ain't valid

This commit is contained in:
Harshit Jain 2018-05-04 14:54:37 +05:30 committed by Isaac Chen
parent 9cfa4c0be9
commit ad9a011a07

View file

@ -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) {