X-Git-Url: https://git.carlh.net/gitweb/?a=blobdiff_plain;f=src%2Flib%2Futil.cc;h=ec8b0f7a52571c18f93c99f48ead29bba668d196;hb=80fafad9c11e0cd8cf9d6ce17deb83be6f680f2d;hp=344a9f97d00d49f539adfcda688799f34322335e;hpb=c6c082c4a8016f85ba4207f4b8ccee1d5770e4a4;p=dcpomatic.git diff --git a/src/lib/util.cc b/src/lib/util.cc index 344a9f97d..ec8b0f7a5 100644 --- a/src/lib/util.cc +++ b/src/lib/util.cc @@ -44,7 +44,12 @@ #include #include #include +#ifdef DCPOMATIC_IMAGE_MAGICK #include +#else +#include +#include +#endif #include #include #include @@ -151,14 +156,11 @@ seconds_to_approximate_hms (int s) if (hours) { if (m > 30 && !minutes) { - ap << (h + 1) << N_(" ") << _("hours"); + /* TRANSLATORS: h here is an abbreviation for hours */ + ap << (h + 1) << _("h"); } else { - ap << h << N_(" "); - if (h == 1) { - ap << _("hour"); - } else { - ap << _("hours"); - } + /* TRANSLATORS: h here is an abbreviation for hours */ + ap << h << _("h"); } if (minutes | seconds) { @@ -169,14 +171,11 @@ seconds_to_approximate_hms (int s) if (minutes) { /* Minutes */ if (s > 30 && !seconds) { - ap << (m + 1) << N_(" ") << _("minutes"); + /* TRANSLATORS: m here is an abbreviation for minutes */ + ap << (m + 1) << _("m"); } else { - ap << m << N_(" "); - if (m == 1) { - ap << _("minute"); - } else { - ap << _("minutes"); - } + /* TRANSLATORS: m here is an abbreviation for minutes */ + ap << m << _("m"); } if (seconds) { @@ -186,12 +185,8 @@ seconds_to_approximate_hms (int s) if (seconds) { /* Seconds */ - ap << s << N_(" "); - if (s == 1) { - ap << _("second"); - } else { - ap << _("seconds"); - } + /* TRANSLATORS: s here is an abbreviation for seconds */ + ap << s << _("s"); } return ap.str (); @@ -287,6 +282,12 @@ LONG WINAPI exception_handler(struct _EXCEPTION_POINTERS *) } #endif +void +set_backtrace_file (boost::filesystem::path p) +{ + backtrace_file = p; +} + /* From http://stackoverflow.com/questions/2443135/how-do-i-find-where-an-exception-was-thrown-in-c */ void terminate () @@ -322,8 +323,9 @@ void dcpomatic_setup () { #ifdef DCPOMATIC_WINDOWS - backtrace_file /= g_get_user_config_dir (); - backtrace_file /= "backtrace.txt"; + boost::filesystem::path p = g_get_user_config_dir (); + p /= "backtrace.txt"; + set_backtrace_file (p); SetUnhandledExceptionFilter(exception_handler); /* Dark voodoo which, I think, gets boost::filesystem::path to @@ -565,7 +567,7 @@ Socket::accept (int port) _acceptor->async_accept (_socket, boost::lambda::var(ec) = boost::lambda::_1); do { _io_service.run_one (); - } while (ec == boost::asio::error::would_block ); + } while (ec == boost::asio::error::would_block); delete _acceptor; _acceptor = 0; @@ -795,6 +797,14 @@ valid_image_file (boost::filesystem::path f) return (ext == ".tif" || ext == ".tiff" || ext == ".jpg" || ext == ".jpeg" || ext == ".png" || ext == ".bmp" || ext == ".tga" || ext == ".dpx"); } +bool +valid_j2k_file (boost::filesystem::path f) +{ + string ext = f.extension().string(); + transform (ext.begin(), ext.end(), ext.begin(), ::tolower); + return (ext == ".j2k" || ext == ".j2c"); +} + string tidy_for_filename (string f) {