in roscpp_azure_iothub/src/ros_azure_iothub_cpp_node.cpp [525:556]
static bool ReadKeyFromFile(const std::string fileName, std::string &key)
{
key = "";
if (fileName.empty())
{
ROS_ERROR("File name empty.");
return false;
}
std::ifstream f(fileName); //taking file as inputstream
if(f)
{
try
{
std::ostringstream ss;
ss << f.rdbuf(); // reading data
key = ss.str();
}
catch(const std::exception& e)
{
ROS_ERROR("Exception thrown during file read: %s", e.what());
}
}
else
{
ROS_ERROR("Could not read from file.");
return false;
}
ROS_INFO("File Read: %s", fileName.c_str());
return true;
}