* @brief Some utility functions and classes.
*/
-#include <sstream>
#include <iomanip>
#include <iostream>
#include <fstream>
#include "rect.h"
#include "md5_digester.h"
#include "audio_processor.h"
+#include "safe_stringstream.h"
#ifdef DCPOMATIC_WINDOWS
#include "stack.hpp"
#endif
#include "i18n.h"
using std::string;
-using std::stringstream;
using std::setfill;
using std::ostream;
using std::endl;
int h = m / 60;
m -= (h * 60);
- stringstream hms;
+ SafeStringStream hms;
hms << h << N_(":");
hms.width (2);
hms << std::setfill ('0') << m << N_(":");
int h = m / 60;
m -= (h * 60);
- stringstream ap;
+ SafeStringStream ap;
bool const hours = h > 0;
bool const minutes = h < 10 && m > 0;
static string
ffmpeg_version_to_string (int v)
{
- stringstream s;
+ SafeStringStream s;
s << ((v & 0xff0000) >> 16) << N_(".") << ((v & 0xff00) >> 8) << N_(".") << (v & 0xff);
return s.str ();
}
}
#endif
+#ifdef DCPOMATIC_OSX
+boost::filesystem::path
+mo_path ()
+{
+ return "DCP-o-matic.app/Contents/Resources";
+}
+#endif
+
void
dcpomatic_setup_gettext_i18n (string lang)
{
-#ifdef DCPOMATIC_POSIX
+#ifdef DCPOMATIC_LINUX
lang += ".UTF8";
#endif
if (!lang.empty ()) {
- /* Override our environment language; this is essential on
- Windows.
+ /* Override our environment language. Note that the caller must not
+ free the string passed into putenv().
*/
- char cmd[64];
- snprintf (cmd, sizeof(cmd), "LANGUAGE=%s", lang.c_str ());
- putenv (cmd);
- snprintf (cmd, sizeof(cmd), "LANG=%s", lang.c_str ());
- putenv (cmd);
- snprintf (cmd, sizeof(cmd), "LC_ALL=%s", lang.c_str ());
- putenv (cmd);
+ string s = String::compose ("LANGUAGE=%1", lang);
+ putenv (strdup (s.c_str ()));
+ s = String::compose ("LANG=%1", lang);
+ putenv (strdup (s.c_str ()));
+ s = String::compose ("LC_ALL=%1", lang);
+ putenv (strdup (s.c_str ()));
}
setlocale (LC_ALL, "");
textdomain ("libdcpomatic");
-#ifdef DCPOMATIC_WINDOWS
+#if defined(DCPOMATIC_WINDOWS) || defined(DCPOMATIC_OSX)
bindtextdomain ("libdcpomatic", mo_path().string().c_str());
bind_textdomain_codeset ("libdcpomatic", "UTF8");
#endif
-#ifdef DCPOMATIC_POSIX
+#ifdef DCPOMATIC_LINUX
bindtextdomain ("libdcpomatic", POSIX_LOCALE_PREFIX);
#endif
}
string
dependency_version_summary ()
{
- stringstream s;
+ SafeStringStream s;
s << N_("libopenjpeg ") << opj_version () << N_(", ")
<< N_("libavcodec ") << ffmpeg_version_to_string (avcodec_version()) << N_(", ")
<< N_("libavfilter ") << ffmpeg_version_to_string (avfilter_version()) << N_(", ")