X-Git-Url: https://main.carlh.net/gitweb/?a=blobdiff_plain;ds=sidebyside;f=src%2Flib%2Fcross.cc;h=7f95d1f71885fd07f172d53ddc3c1e928335005e;hb=a5e87b6f0f496f4ed71d9129d40a5baebb68495f;hp=730cfe1d0f46a8457652d29cfbad0b0e64a9ae9d;hpb=2935d9d158cf35496a35107f9c4ab7d2929cf6c3;p=dcpomatic.git diff --git a/src/lib/cross.cc b/src/lib/cross.cc index 730cfe1d0..7f95d1f71 100644 --- a/src/lib/cross.cc +++ b/src/lib/cross.cc @@ -1,5 +1,5 @@ /* - Copyright (C) 2012 Carl Hetherington + Copyright (C) 2012-2015 Carl Hetherington This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -17,11 +17,11 @@ */ -#include -#include #include "cross.h" #include "compose.hpp" #include "log.h" +#include "exceptions.h" +#include #ifdef DCPOMATIC_LINUX #include #include @@ -42,12 +42,13 @@ #include #include #endif -#include "exceptions.h" +#include #include "i18n.h" #define LOG_GENERAL(...) log->log (String::compose (__VA_ARGS__), Log::TYPE_GENERAL); #define LOG_ERROR(...) log->log (String::compose (__VA_ARGS__), Log::TYPE_ERROR); +#define LOG_ERROR_NC(...) log->log (__VA_ARGS__, Log::TYPE_ERROR); using std::pair; using std::list; @@ -150,6 +151,23 @@ app_contents () } #endif +boost::filesystem::path +shared_path () +{ +#ifdef DCPOMATIC_LINUX + return boost::filesystem::canonical (LINUX_SHARE_PREFIX); +#endif +#ifdef DCPOMATIC_WINDOWS + wchar_t dir[512]; + GetModuleFileName (GetModuleHandle (0), dir, sizeof (dir)); + PathRemoveFileSpec (dir); + return dir.parent_path(); +#endif +#ifdef DCPOMATIC_OSX + return app_contents(); +#endif +} + void run_ffprobe (boost::filesystem::path content, boost::filesystem::path out, shared_ptr log) { @@ -162,7 +180,7 @@ run_ffprobe (boost::filesystem::path content, boost::filesystem::path out, share HANDLE child_stderr_read; HANDLE child_stderr_write; if (!CreatePipe (&child_stderr_read, &child_stderr_write, &security, 0)) { - log->log ("ffprobe call failed (could not CreatePipe)"); + LOG_ERROR_NC ("ffprobe call failed (could not CreatePipe)"); return; } @@ -189,19 +207,19 @@ run_ffprobe (boost::filesystem::path content, boost::filesystem::path out, share 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)) { - LOG_ERROR (N_("ffprobe call failed (could not CreateProcess)")); + LOG_ERROR_NC (N_("ffprobe call failed (could not CreateProcess)")); return; } FILE* o = fopen_boost (out, "w"); if (!o) { - LOG_ERROR (N_("ffprobe call failed (could not create output file)")); + LOG_ERROR_NC (N_("ffprobe call failed (could not create output file)")); return; } CloseHandle (child_stderr_write); - while (1) { + while (true) { char buffer[512]; DWORD read; if (!ReadFile(child_stderr_read, buffer, sizeof(buffer), &read, 0) || read == 0) { @@ -246,7 +264,7 @@ mount_info () return m; } - while (1) { + while (true) { struct mntent* mnt = getmntent (f); if (!mnt) { break; @@ -309,7 +327,7 @@ void Waker::nudge () { #ifdef DCPOMATIC_WINDOWS - SetThreadExecutionState (ES_CONTINUOUS); + SetThreadExecutionState (ES_SYSTEM_REQUIRED); #endif }