From 9321fb0db9beacb29edf928ced74d38066bf163d Mon Sep 17 00:00:00 2001 From: Michael Carlberg Date: Wed, 1 Jun 2016 16:06:24 +0200 Subject: [PATCH] fix(backlight): Check file existance --- src/modules/backlight.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/modules/backlight.cpp b/src/modules/backlight.cpp index 62e7aac5..560ee744 100644 --- a/src/modules/backlight.cpp +++ b/src/modules/backlight.cpp @@ -23,7 +23,12 @@ BacklightModule::BacklightModule(const std::string& name_) : InotifyModule(name_ this->path_val = string::replace(PATH_BACKLIGHT_VAL, "%card%", card); this->path_max = string::replace(PATH_BACKLIGHT_MAX, "%card%", card); - this->watch(string::replace(PATH_BACKLIGHT_VAL, "%card%", card)); + if (!io::file::exists(this->path_val)) + throw ModuleError("[BacklightModule] The file \""+ this->path_val +"\" does not exist"); + if (!io::file::exists(this->path_max)) + throw ModuleError("[BacklightModule] The file \""+ this->path_max +"\" does not exist"); + + this->watch(this->path_val); } bool BacklightModule::on_event(InotifyEvent *event)