Fix problems with FFmpeg files that have all-zero stream IDs.
[dcpomatic.git] / src / lib / cross.cc
index ac94e8015af3554473424d8f672690f5cef8fef0..7436dbf26a9b4582edcfb8e1702638b2e91d3416 100644 (file)
 #include <sys/sysctl.h>
 #include <mach-o/dyld.h>
 #endif
+#ifdef DCPOMATIC_POSIX
+#include <sys/types.h>
+#include <ifaddrs.h>
+#include <netinet/in.h>
+#include <arpa/inet.h>
+#endif
 #include "exceptions.h"
 
 using std::pair;
@@ -45,6 +51,7 @@ using std::wstring;
 using std::make_pair;
 using boost::shared_ptr;
 
+/** @param s Number of seconds to sleep for */
 void
 dcpomatic_sleep (int s)
 {
@@ -63,6 +70,9 @@ cpu_info ()
        string info;
        
 #ifdef DCPOMATIC_LINUX
+       /* This use of ifstream is ok; the filename can never
+          be non-Latin
+       */
        ifstream f ("/proc/cpuinfo");
        while (f.good ()) {
                string l;
@@ -128,11 +138,8 @@ app_contents ()
        
        boost::filesystem::path path (buffer);
        path = boost::filesystem::canonical (path);
-       std::cout << "start " << path << "\n";
        path = path.parent_path ();
-       std::cout << "then " << path << "\n";
        path = path.parent_path ();
-       std::cout << "and then " << path << "\n";
        return path;
 }
 #endif
@@ -265,3 +272,19 @@ openssl_path ()
 #endif
 
 }
+
+/* Apparently there is no way to create an ofstream using a UTF-8
+   filename under Windows.  We are hence reduced to using fopen
+   with this wrapper.
+*/
+FILE *
+fopen_boost (boost::filesystem::path p, string t)
+{
+#ifdef DCPOMATIC_WINDOWS
+        wstring w (t.begin(), t.end());
+       /* c_str() here should give a UTF-16 string */
+        return _wfopen (p.c_str(), w.c_str ());
+#else
+        return fopen (p.c_str(), t.c_str ());
+#endif
+}