Merge pull request #241 into master
8c76e7cc container: root: macro: common: throw if invalid loading path (Aaron Fiore)
This commit was merged in pull request #241.
This commit is contained in:
@@ -24,6 +24,7 @@
|
||||
#define CONTAINER_SRC_ROOT_MACRO_COMMON_UTILITY_HH_
|
||||
|
||||
#include <ctime>
|
||||
#include <filesystem>
|
||||
#include <initializer_list>
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
@@ -72,6 +73,18 @@ class Command final
|
||||
//! \brief Load given file path
|
||||
static void load(const std::string& path)
|
||||
{
|
||||
std::filesystem::path p(path);
|
||||
if (!std::filesystem::exists(p))
|
||||
{
|
||||
throw std::runtime_error(
|
||||
std::string{"'" + path + "' does not exist!"}.c_str());
|
||||
}
|
||||
if (!std::filesystem::is_regular_file(p))
|
||||
{
|
||||
throw std::runtime_error(
|
||||
std::string{"'" + path + "' is not a regular file!"}.c_str());
|
||||
}
|
||||
|
||||
std::string cmd{".L " + path};
|
||||
Command::cmd_handler({cmd});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user