X-Git-Url: https://bilbo.iut-bm.univ-fcomte.fr/and/gitweb/loba.git/blobdiff_plain/526e1f382ddc9f0010c41a526f3029af769162c9..6f21403d553131b282aeff52a2c496d71d05c97e:/main.cpp?ds=inline diff --git a/main.cpp b/main.cpp index f31e847..89e9bec 100644 --- a/main.cpp +++ b/main.cpp @@ -4,6 +4,7 @@ #include // strchr #include #include +#include #include #include @@ -149,6 +150,15 @@ static bool check_for_lost_load() return res; } +static void check_file_access(const std::string& name) +{ + if (access(name.c_str(), R_OK) != 0) { + std::cerr << "ERROR: cannot access to file \"" + << name << "\" for reading: " << strerror(errno) << "\n"; + exit(EXIT_FAILURE_ARGS); + } +} + static void signal_handler(int /*sig*/) { if (!opt::exit_request) { @@ -171,7 +181,7 @@ static void install_signal_handler() sigemptyset(&action.sa_mask); action.sa_flags = SA_RESTART; if (sigaction(SIGINT, &action, NULL) == -1) { - std::cerr << "sigaction: " << strerror(errno) << "\n"; + std::cerr << "ERROR: sigaction: " << strerror(errno) << "\n"; exit(EXIT_FAILURE_OTHER); } } @@ -236,6 +246,7 @@ int main(int argc, char* argv[]) // Create the platform and the application. XBT_DEBUG("Loading platform file..."); + check_file_access(opt::platform_file); MSG_create_environment(opt::platform_file.c_str()); XBT_DEBUG("Creating hostdata..."); hostdata::create(); @@ -264,6 +275,7 @@ int main(int argc, char* argv[]) } MY_launch_application(); // it is already opt::* aware... } else { + check_file_access(opt::deployment_file); MSG_launch_application(opt::deployment_file.c_str()); }