Add getIndirectID function

This function will look up the sensor ID for a sensor when
it is specified in a label file in hwmon sysfs.

This functionality was previously all contained in
getIndirectlLabelEnv().  A future commit will remove this
function entirely and just use getIndirectID() and getEnv()
to look up the label for the indirect case.

Change-Id: Ifeb636eb0e58a6204f782f64e9aba839b812a967
Signed-off-by: Matt Spinler <spinler@us.ibm.com>
diff --git a/env.cpp b/env.cpp
index efd081b..3194441 100644
--- a/env.cpp
+++ b/env.cpp
@@ -48,6 +48,34 @@
     return getEnv(prefix, sensor);
 }
 
+std::string getIndirectID(
+        std::string path,
+        const SensorSet::key_type& sensor)
+{
+    std::string content;
+
+    path.append(sensor.first);
+    path.append(sensor.second);
+    path.append(1, '_');
+    path.append(hwmon::entry::label);
+
+    std::ifstream handle(path.c_str());
+    if (!handle.fail())
+    {
+        content.assign(
+                (std::istreambuf_iterator<char>(handle)),
+                (std::istreambuf_iterator<char>()));
+
+        if (!content.empty())
+        {
+            //remove the newline
+            content.pop_back();
+        }
+    }
+
+    return content;
+}
+
 std::string getIndirectLabelEnv(
     const char* prefix, std::string path, const SensorSet::key_type& sensor)
 {