swaroop: encrypt decryption private key with motherboard UUID.
[dcpomatic.git] / src / lib / cross.cc
index e3fb22f3999544f69cd0be9be5e40b7e3fb2fb03..171bf2c8100767bb79d8d5b610767c768a44e705 100644 (file)
@@ -474,3 +474,30 @@ home_directory ()
                return boost::filesystem::path(getenv("HOMEDRIVE")) / boost::filesystem::path(getenv("HOMEPATH"));
 #endif
 }
+
+string
+command_and_read (string cmd)
+{
+#ifdef DCPOMATIC_LINUX
+       FILE* pipe = popen (cmd.c_str(), "r");
+       if (!pipe) {
+               throw runtime_error ("popen failed");
+       }
+
+       string result;
+       char buffer[128];
+       try {
+               while (fgets(buffer, sizeof(buffer), pipe)) {
+                       result += buffer;
+               }
+       } catch (...) {
+               pclose (pipe);
+               throw;
+       }
+
+       pclose (pipe);
+       return result;
+#endif
+
+       return "";
+}