X-Git-Url: https://git.carlh.net/gitweb/?a=blobdiff_plain;f=src%2Flib%2Fcross.cc;h=ee0ef89b2ea0c9394b53124b700605d5c703a3af;hb=e16c8ed02a0cb1f733a990d75a9de1bf50cf89bd;hp=cdb7f281955f2e021d6872cb9e14d5461604295e;hpb=99aa6b5fd53426eee80b409ed99d1ee86c097cd5;p=dcpomatic.git diff --git a/src/lib/cross.cc b/src/lib/cross.cc index cdb7f2819..ee0ef89b2 100644 --- a/src/lib/cross.cc +++ b/src/lib/cross.cc @@ -20,31 +20,35 @@ #include #include #include "cross.h" +#include "compose.hpp" #include "log.h" -#ifdef DVDOMATIC_POSIX +#ifdef DCPOMATIC_LINUX #include +#include #endif -#ifdef DVDOMATIC_WINDOWS +#ifdef DCPOMATIC_WINDOWS #include #undef DATADIR #include #endif -#ifdef DVDOMATIC_OSX +#ifdef DCPOMATIC_OSX #include #endif using std::pair; +using std::list; using std::ifstream; using std::string; +using std::make_pair; using boost::shared_ptr; void -dvdomatic_sleep (int s) +dcpomatic_sleep (int s) { -#ifdef DVDOMATIC_POSIX +#ifdef DCPOMATIC_POSIX sleep (s); #endif -#ifdef DVDOMATIC_WINDOWS +#ifdef DCPOMATIC_WINDOWS Sleep (s * 1000); #endif } @@ -56,7 +60,7 @@ cpu_info () pair info; info.second = 0; -#ifdef DVDOMATIC_LINUX +#ifdef DCPOMATIC_LINUX ifstream f ("/proc/cpuinfo"); while (f.good ()) { string l; @@ -72,7 +76,7 @@ cpu_info () } #endif -#ifdef DVDOMATIC_OSX +#ifdef DCPOMATIC_OSX size_t N = sizeof (info.second); sysctlbyname ("hw.ncpu", &info.second, &N, 0, 0); char buffer[64]; @@ -88,7 +92,7 @@ cpu_info () void run_ffprobe (boost::filesystem::path content, boost::filesystem::path out, shared_ptr log) { -#ifdef DVDOMATIC_WINDOWS +#ifdef DCPOMATIC_WINDOWS SECURITY_ATTRIBUTES security; security.nLength = sizeof (security); security.bInheritHandle = TRUE; @@ -113,12 +117,14 @@ run_ffprobe (boost::filesystem::path content, boost::filesystem::path out, share startup_info.dwFlags |= STARTF_USESTDHANDLES; wchar_t command[512]; - wcscpy (command, L"ffprobe.exe "); + wcscpy (command, L"ffprobe.exe \""); wchar_t file[512]; MultiByteToWideChar (CP_UTF8, 0, content.string().c_str(), -1, file, sizeof(file)); wcscat (command, file); + wcscat (command, L"\""); + PROCESS_INFORMATION process_info; ZeroMemory (&process_info, sizeof (process_info)); if (!CreateProcess (0, command, 0, 0, TRUE, CREATE_NO_WINDOW, 0, 0, &startup_info, &process_info)) { @@ -150,8 +156,34 @@ run_ffprobe (boost::filesystem::path content, boost::filesystem::path out, share CloseHandle (process_info.hThread); CloseHandle (child_stderr_read); #else - string ffprobe = "ffprobe 2> \"" + c + "\" 2> \"" + file ("ffprobe.log"); + string ffprobe = "ffprobe \"" + content.string() + "\" 2> \"" + out.string() + "\""; log->log (String::compose ("Probing with %1", ffprobe)); system (ffprobe.c_str ()); #endif } + +list > +mount_info () +{ + list > m; + +#ifdef DCPOMATIC_LINUX + FILE* f = setmntent ("/etc/mtab", "r"); + if (!f) { + return m; + } + + while (1) { + struct mntent* mnt = getmntent (f); + if (!mnt) { + break; + } + + m.push_back (make_pair (mnt->mnt_dir, mnt->mnt_type)); + } + + endmntent (f); +#endif + + return m; +}