Avoid unnecessary re-writes of video assets if they are staying the same (#1638).
[dcpomatic.git] / src / lib / cross.cc
index e3fb22f3999544f69cd0be9be5e40b7e3fb2fb03..1b83bad7c6dca9a02cf9696eccf8c8834f0fa8b7 100644 (file)
@@ -65,7 +65,7 @@ using boost::shared_ptr;
 
 /** @param s Number of seconds to sleep for */
 void
-dcpomatic_sleep (int s)
+dcpomatic_sleep_seconds (int s)
 {
 #ifdef DCPOMATIC_POSIX
        sleep (s);
@@ -474,3 +474,43 @@ 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 "";
+}
+
+/** @return true if this process is a 32-bit one running on a 64-bit-capable OS */
+bool
+running_32_on_64 ()
+{
+#ifdef DCPOMATIC_WINDOWS
+       BOOL p;
+       IsWow64Process (GetCurrentProcess(), &p);
+       return p;
+#endif
+       /* XXX: assuming nobody does this on Linux / OS X */
+       return false;
+}