X-Git-Url: https://git.carlh.net/gitweb/?a=blobdiff_plain;f=src%2Flib%2Futil.cc;h=38451e9314e9bbd67da2afeb9a226115727ead83;hb=00b60f52add041a36fa62118baf4b5ac78993980;hp=704d4aa9dbb5744e0d1d16af8cb8594fa656ac9c;hpb=03c5a8155043613c01e0e151735a7fcf8ab84415;p=dcpomatic.git diff --git a/src/lib/util.cc b/src/lib/util.cc index 704d4aa9d..38451e931 100644 --- a/src/lib/util.cc +++ b/src/lib/util.cc @@ -53,6 +53,7 @@ extern "C" { #include #include #include +#include #include #include #ifdef DCPOMATIC_WINDOWS @@ -422,7 +423,7 @@ digest_head_tail (vector files, boost::uintmax_t size) while (i < int64_t (files.size()) && to_do > 0) { FILE* f = fopen_boost (files[i], "rb"); if (!f) { - throw OpenFileError (files[i].string()); + throw OpenFileError (files[i].string(), errno, true); } boost::uintmax_t this_time = min (to_do, boost::filesystem::file_size (files[i])); @@ -442,7 +443,7 @@ digest_head_tail (vector files, boost::uintmax_t size) while (i >= 0 && to_do > 0) { FILE* f = fopen_boost (files[i], "rb"); if (!f) { - throw OpenFileError (files[i].string()); + throw OpenFileError (files[i].string(), errno, true); } boost::uintmax_t this_time = min (to_do, boost::filesystem::file_size (files[i])); @@ -485,8 +486,7 @@ audio_channel_name (int c) DCPOMATIC_ASSERT (MAX_DCP_AUDIO_CHANNELS == 16); /// TRANSLATORS: these are the names of audio channels; Lfe (sub) is the low-frequency - /// enhancement channel (sub-woofer). HI is the hearing-impaired audio track and - /// VI is the visually-impaired audio track (audio describe). + /// enhancement channel (sub-woofer). string const channels[] = { _("Left"), _("Right"), @@ -509,6 +509,38 @@ audio_channel_name (int c) return channels[c]; } +string +short_audio_channel_name (int c) +{ + DCPOMATIC_ASSERT (MAX_DCP_AUDIO_CHANNELS == 16); + + /// TRANSLATORS: these are short names of audio channels; Lfe is the low-frequency + /// enhancement channel (sub-woofer). HI is the hearing-impaired audio track and + /// VI is the visually-impaired audio track (audio describe). DBP is the D-BOX + /// primary channel and DBS is the D-BOX secondary channel. + string const channels[] = { + _("L"), + _("R"), + _("C"), + _("Lfe"), + _("Ls"), + _("Rs"), + _("HI"), + _("VI"), + _("Lc"), + _("Rc"), + _("BsL"), + _("BsR"), + _("DBP"), + _("DBS"), + _(""), + _("") + }; + + return channels[c]; +} + + bool valid_image_file (boost::filesystem::path f) { @@ -536,16 +568,8 @@ valid_j2k_file (boost::filesystem::path f) string tidy_for_filename (string f) { - string t; - for (size_t i = 0; i < f.length(); ++i) { - if (isalnum (f[i]) || f[i] == '_' || f[i] == '-') { - t += f[i]; - } else { - t += '_'; - } - } - - return t; + boost::replace_if (f, boost::is_any_of ("\\/:"), '_'); + return f; } dcp::Size @@ -651,9 +675,3 @@ relaxed_string_to_float (string s) return lexical_cast (s); } } - -bool -string_not_empty (string s) -{ - return !s.empty (); -}