From a9dd3d27bc52f853309885b1be02d6efd2d2af48 Mon Sep 17 00:00:00 2001 From: Carl Hetherington Date: Mon, 25 Nov 2013 00:28:26 +0000 Subject: Add fopen_boost; remove a couple of defunct usings. --- src/lib/config.cc | 1 - src/lib/cross.cc | 16 ++++++++++++++++ src/lib/cross.h | 1 + src/tools/dcpomatic.cc | 1 - 4 files changed, 17 insertions(+), 2 deletions(-) diff --git a/src/lib/config.cc b/src/lib/config.cc index 4b6455f51..2420ab1b5 100644 --- a/src/lib/config.cc +++ b/src/lib/config.cc @@ -41,7 +41,6 @@ using std::vector; using std::ifstream; using std::string; -using std::ofstream; using std::list; using std::max; using std::exception; diff --git a/src/lib/cross.cc b/src/lib/cross.cc index 41051ee2e..9aa8454c9 100644 --- a/src/lib/cross.cc +++ b/src/lib/cross.cc @@ -269,3 +269,19 @@ openssl_path () #endif } + +/* Apparently there is no way to create an ofstream using a UTF-8 + filename under Windows. We are hence reduced to using fopen + with this wrapper. +*/ +FILE * +fopen_boost (boost::filesystem::path p, string t) +{ +#ifdef DCPOMATIC_WINDOWS + wstring w (t.begin(), t.end()); + /* c_str() here should give a UTF-16 string */ + return _wfopen (p.c_str(), w.c_str ()); +#else + return fopen (p.c_str(), t.c_str ()); +#endif +} diff --git a/src/lib/cross.h b/src/lib/cross.h index 1fe34edbe..931e7d890 100644 --- a/src/lib/cross.h +++ b/src/lib/cross.h @@ -33,3 +33,4 @@ extern boost::filesystem::path openssl_path (); #ifdef DCPOMATIC_OSX extern boost::filesystem::path app_contents (); #endif +extern FILE * fopen_boost (boost::filesystem::path, std::string); diff --git a/src/tools/dcpomatic.cc b/src/tools/dcpomatic.cc index 1d01e4da8..5d2157922 100644 --- a/src/tools/dcpomatic.cc +++ b/src/tools/dcpomatic.cc @@ -62,7 +62,6 @@ using std::map; using std::make_pair; using std::list; using std::exception; -using std::ofstream; using boost::shared_ptr; using boost::dynamic_pointer_cast; -- cgit v1.2.3 From 9e1343fb30df204811e80bfd1387574b9d383a09 Mon Sep 17 00:00:00 2001 From: Carl Hetherington Date: Mon, 25 Nov 2013 00:36:44 +0000 Subject: Remove a couple of uses of ofstream. --- src/lib/dcp_video_frame.cc | 5 +++-- src/lib/film.cc | 1 - src/lib/util.cc | 8 +++++--- 3 files changed, 8 insertions(+), 6 deletions(-) diff --git a/src/lib/dcp_video_frame.cc b/src/lib/dcp_video_frame.cc index 25abd6f0d..679a0490e 100644 --- a/src/lib/dcp_video_frame.cc +++ b/src/lib/dcp_video_frame.cc @@ -59,12 +59,12 @@ #include "scaler.h" #include "image.h" #include "log.h" +#include "cross.h" #include "i18n.h" using std::string; using std::stringstream; -using std::ofstream; using std::cout; using boost::shared_ptr; using boost::lexical_cast; @@ -379,8 +379,9 @@ void EncodedData::write_info (shared_ptr film, int frame, Eyes eyes, libdcp::FrameInfo fin) const { boost::filesystem::path const info = film->info_path (frame, eyes); - ofstream h (info.string().c_str()); + FILE* h = fopen_boost (info, "w"); fin.write (h); + fclose (h); } /** Send this data to a socket. diff --git a/src/lib/film.cc b/src/lib/film.cc index eab91c7d2..a3720c458 100644 --- a/src/lib/film.cc +++ b/src/lib/film.cc @@ -65,7 +65,6 @@ using std::pair; using std::map; using std::vector; using std::ifstream; -using std::ofstream; using std::setfill; using std::min; using std::make_pair; diff --git a/src/lib/util.cc b/src/lib/util.cc index 484c4fb9b..3afd3547f 100644 --- a/src/lib/util.cc +++ b/src/lib/util.cc @@ -89,7 +89,6 @@ using std::multimap; using std::istream; using std::numeric_limits; using std::pair; -using std::ofstream; using std::cout; using boost::shared_ptr; using boost::thread; @@ -260,8 +259,11 @@ seconds (struct timeval t) LONG WINAPI exception_handler(struct _EXCEPTION_POINTERS *) { dbg::stack s; - ofstream f (backtrace_file.string().c_str()); - std::copy(s.begin(), s.end(), std::ostream_iterator(f, "\n")); + FILE* f = fopen_boost (backtrace_file, "w"); + for (dbg::stack_frame::const_iterator i = s.begin(); i != s.end(); ++i) { + fprintf (f, "%p %s %d %s", i->instruction, i->function.c_str(), i->line, i->module.c_str()); + } + fclose (f); return EXCEPTION_CONTINUE_SEARCH; } #endif -- cgit v1.2.3 From 9f3b6e8e71a6158fd8d83e0e34d70531fc3d8634 Mon Sep 17 00:00:00 2001 From: Carl Hetherington Date: Mon, 25 Nov 2013 00:44:12 +0000 Subject: Remove another ifstream. --- src/lib/util.cc | 32 +++++++++++++++----------------- 1 file changed, 15 insertions(+), 17 deletions(-) diff --git a/src/lib/util.cc b/src/lib/util.cc index 3afd3547f..c4a634c08 100644 --- a/src/lib/util.cc +++ b/src/lib/util.cc @@ -80,7 +80,6 @@ using std::endl; using std::vector; using std::hex; using std::setw; -using std::ifstream; using std::ios; using std::min; using std::max; @@ -394,29 +393,28 @@ md5_digest (void const * data, int size) string md5_digest (boost::filesystem::path file) { - ifstream f (file.string().c_str(), std::ios::binary); - if (!f.good ()) { + FILE* f = fopen_boost (file, "rb"); + if (!f) { throw OpenFileError (file.string()); } - - f.seekg (0, std::ios::end); - int bytes = f.tellg (); - f.seekg (0, std::ios::beg); - int const buffer_size = 64 * 1024; + boost::uintmax_t bytes = boost::filesystem::file_size (file); + + boost::uintmax_t const buffer_size = 64 * 1024; char buffer[buffer_size]; MD5_CTX md5_context; MD5_Init (&md5_context); while (bytes > 0) { int const t = min (bytes, buffer_size); - f.read (buffer, t); + fread (buffer, 1, t, f); MD5_Update (&md5_context, buffer, t); bytes -= t; } unsigned char digest[MD5_DIGEST_LENGTH]; MD5_Final (digest, &md5_context); + fclose (f); stringstream s; for (int i = 0; i < MD5_DIGEST_LENGTH; ++i) { @@ -430,7 +428,7 @@ md5_digest (boost::filesystem::path file) string md5_digest_directory (boost::filesystem::path directory, shared_ptr job) { - int const buffer_size = 64 * 1024; + boost::uintmax_t const buffer_size = 64 * 1024; char buffer[buffer_size]; MD5_CTX md5_context; @@ -445,18 +443,16 @@ md5_digest_directory (boost::filesystem::path directory, shared_ptr job) int j = 0; for (boost::filesystem::directory_iterator i(directory); i != boost::filesystem::directory_iterator(); ++i) { - ifstream f (i->path().string().c_str(), std::ios::binary); - if (!f.good ()) { + FILE* f = fopen_boost (i->path(), "rb"); + if (!f) { throw OpenFileError (i->path().string()); } - - f.seekg (0, std::ios::end); - int bytes = f.tellg (); - f.seekg (0, std::ios::beg); + + boost::uintmax_t bytes = boost::filesystem::file_size (i->path ()); while (bytes > 0) { int const t = min (bytes, buffer_size); - f.read (buffer, t); + fread (buffer, 1, t, f); MD5_Update (&md5_context, buffer, t); bytes -= t; } @@ -465,6 +461,8 @@ md5_digest_directory (boost::filesystem::path directory, shared_ptr job) job->set_progress (float (j) / files); ++j; } + + fclose (f); } unsigned char digest[MD5_DIGEST_LENGTH]; -- cgit v1.2.3 From c8223fa45f01bc38d36f368f12454cf6a3375b1b Mon Sep 17 00:00:00 2001 From: Carl Hetherington Date: Mon, 25 Nov 2013 00:45:34 +0000 Subject: Remove another fstream. --- src/lib/log.cc | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/lib/log.cc b/src/lib/log.cc index 86de21bdd..9ddf460d4 100644 --- a/src/lib/log.cc +++ b/src/lib/log.cc @@ -21,9 +21,10 @@ * @brief A very simple logging class. */ -#include #include +#include #include "log.h" +#include "cross.h" #include "i18n.h" @@ -102,7 +103,8 @@ FileLog::FileLog (boost::filesystem::path file) void FileLog::do_log (string m) { - ofstream f (_file.string().c_str(), fstream::app); - f << m << N_("\n"); + FILE* f = fopen_boost (_file, "a"); + fprintf (f, "%s\n", m.c_str ()); + fclose (f); } -- cgit v1.2.3 From 7a7d06be4a2b300dbd0607d321de9d644d665abe Mon Sep 17 00:00:00 2001 From: Carl Hetherington Date: Mon, 25 Nov 2013 00:53:55 +0000 Subject: Add test for serialisation of audio analyses. --- test/audio_analysis_test.cc | 60 +++++++++++++++++++++++++++++++++++++++++++++ test/wscript | 1 + 2 files changed, 61 insertions(+) create mode 100644 test/audio_analysis_test.cc diff --git a/test/audio_analysis_test.cc b/test/audio_analysis_test.cc new file mode 100644 index 000000000..2ebf15fd4 --- /dev/null +++ b/test/audio_analysis_test.cc @@ -0,0 +1,60 @@ +/* + Copyright (C) 2012 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 + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + +*/ + +#include +#include "lib/audio_analysis.h" + +static float +random_float () +{ + return (float (rand ()) / RAND_MAX) * 2 - 1; +} + +/* Check serialisation of audio analyses */ +BOOST_AUTO_TEST_CASE (audio_analysis_test) +{ + int const channels = 3; + int const points = 4096; + + srand (1); + + AudioAnalysis a (3); + for (int i = 0; i < channels; ++i) { + for (int j = 0; j < points; ++j) { + AudioPoint p; + p[AudioPoint::PEAK] = random_float (); + p[AudioPoint::RMS] = random_float (); + a.add_point (i, p); + } + } + + a.write ("build/test/audio_analysis_test"); + + srand (1); + + AudioAnalysis b ("build/test/audio_analysis_test"); + for (int i = 0; i < channels; ++i) { + BOOST_CHECK (b.points(i) == points); + for (int j = 0; j < points; ++j) { + AudioPoint p = b.get_point (i, j); + BOOST_CHECK_CLOSE (p[AudioPoint::PEAK], random_float (), 0.1); + BOOST_CHECK_CLOSE (p[AudioPoint::RMS], random_float (), 0.1); + } + } +} diff --git a/test/wscript b/test/wscript index b40b69475..76de63a52 100644 --- a/test/wscript +++ b/test/wscript @@ -16,6 +16,7 @@ def build(bld): obj.use = 'libdcpomatic' obj.source = """ test.cc + audio_analysis_test.cc scaling_test.cc film_metadata_test.cc frame_rate_test.cc -- cgit v1.2.3 From a562abf85aeed64ce94a2c0c826de3fc9c21ae49 Mon Sep 17 00:00:00 2001 From: Carl Hetherington Date: Mon, 25 Nov 2013 01:00:26 +0000 Subject: Replace fstream with cstdio in audio analysis serialisation. --- src/lib/audio_analysis.cc | 31 ++++++++++++++++--------------- src/lib/audio_analysis.h | 5 ++--- test/audio_analysis_test.cc | 4 ++-- 3 files changed, 20 insertions(+), 20 deletions(-) diff --git a/src/lib/audio_analysis.cc b/src/lib/audio_analysis.cc index bc59bccca..1488f89fc 100644 --- a/src/lib/audio_analysis.cc +++ b/src/lib/audio_analysis.cc @@ -20,15 +20,14 @@ #include #include #include -#include +#include #include #include "audio_analysis.h" +#include "cross.h" using std::ostream; using std::istream; using std::string; -using std::ofstream; -using std::ifstream; using std::vector; using std::cout; using std::max; @@ -41,10 +40,10 @@ AudioPoint::AudioPoint () } } -AudioPoint::AudioPoint (istream& s) +AudioPoint::AudioPoint (FILE* f) { for (int i = 0; i < COUNT; ++i) { - s >> _data[i]; + fscanf (f, "%f", &_data[i]); } } @@ -70,10 +69,10 @@ AudioPoint::operator= (AudioPoint const & other) } void -AudioPoint::write (ostream& s) const +AudioPoint::write (FILE* f) const { for (int i = 0; i < COUNT; ++i) { - s << _data[i] << "\n"; + fprintf (f, "%f\n", _data[i]); } } @@ -85,15 +84,15 @@ AudioAnalysis::AudioAnalysis (int channels) AudioAnalysis::AudioAnalysis (boost::filesystem::path filename) { - ifstream f (filename.string().c_str ()); + FILE* f = fopen_boost (filename, "r"); int channels; - f >> channels; + fscanf (f, "%d", &channels); _data.resize (channels); for (int i = 0; i < channels; ++i) { int points; - f >> points; + fscanf (f, "%d", &points); for (int j = 0; j < points; ++j) { _data[i].push_back (AudioPoint (f)); } @@ -130,17 +129,19 @@ AudioAnalysis::points (int c) const void AudioAnalysis::write (boost::filesystem::path filename) { - string tmp = filename.string() + ".tmp"; + boost::filesystem::path tmp = filename; + tmp.replace_extension (".tmp"); - ofstream f (tmp.c_str ()); - f << _data.size() << "\n"; + FILE* f = fopen_boost (tmp, "w"); + + fprintf (f, "%ld\n", _data.size ()); for (vector >::iterator i = _data.begin(); i != _data.end(); ++i) { - f << i->size () << "\n"; + fprintf (f, "%ld\n", i->size ()); for (vector::iterator j = i->begin(); j != i->end(); ++j) { j->write (f); } } - f.close (); + fclose (f); boost::filesystem::rename (tmp, filename); } diff --git a/src/lib/audio_analysis.h b/src/lib/audio_analysis.h index cfc170c84..824472dda 100644 --- a/src/lib/audio_analysis.h +++ b/src/lib/audio_analysis.h @@ -20,7 +20,6 @@ #ifndef DCPOMATIC_AUDIO_ANALYSIS_H #define DCPOMATIC_AUDIO_ANALYSIS_H -#include #include #include #include @@ -35,11 +34,11 @@ public: }; AudioPoint (); - AudioPoint (std::istream &); + AudioPoint (FILE *); AudioPoint (AudioPoint const &); AudioPoint& operator= (AudioPoint const &); - void write (std::ostream &) const; + void write (FILE *) const; float& operator[] (int t) { return _data[t]; diff --git a/test/audio_analysis_test.cc b/test/audio_analysis_test.cc index 2ebf15fd4..77b2aeaf6 100644 --- a/test/audio_analysis_test.cc +++ b/test/audio_analysis_test.cc @@ -53,8 +53,8 @@ BOOST_AUTO_TEST_CASE (audio_analysis_test) BOOST_CHECK (b.points(i) == points); for (int j = 0; j < points; ++j) { AudioPoint p = b.get_point (i, j); - BOOST_CHECK_CLOSE (p[AudioPoint::PEAK], random_float (), 0.1); - BOOST_CHECK_CLOSE (p[AudioPoint::RMS], random_float (), 0.1); + BOOST_CHECK_CLOSE (p[AudioPoint::PEAK], random_float (), 1); + BOOST_CHECK_CLOSE (p[AudioPoint::RMS], random_float (), 1); } } } -- cgit v1.2.3 From 589abeb702278ec209b4972f6c4c993949fa78ee Mon Sep 17 00:00:00 2001 From: Carl Hetherington Date: Mon, 25 Nov 2013 01:03:30 +0000 Subject: Some comments. --- src/lib/config.cc | 1 + src/lib/cross.cc | 3 +++ 2 files changed, 4 insertions(+) diff --git a/src/lib/config.cc b/src/lib/config.cc index 2420ab1b5..54b9168f2 100644 --- a/src/lib/config.cc +++ b/src/lib/config.cc @@ -181,6 +181,7 @@ Config::read () void Config::read_old_metadata () { + /* XXX: this won't work with non-Latin filenames */ ifstream f (file(true).string().c_str ()); string line; diff --git a/src/lib/cross.cc b/src/lib/cross.cc index 9aa8454c9..7436dbf26 100644 --- a/src/lib/cross.cc +++ b/src/lib/cross.cc @@ -70,6 +70,9 @@ cpu_info () string info; #ifdef DCPOMATIC_LINUX + /* This use of ifstream is ok; the filename can never + be non-Latin + */ ifstream f ("/proc/cpuinfo"); while (f.good ()) { string l; -- cgit v1.2.3 From 4ec1def1154d3d6b305bf556bf227df7b4f74b16 Mon Sep 17 00:00:00 2001 From: Carl Hetherington Date: Mon, 25 Nov 2013 08:38:53 +0000 Subject: Remove another use of fstream. --- src/lib/film.cc | 1 - src/lib/writer.cc | 8 +++++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/src/lib/film.cc b/src/lib/film.cc index a3720c458..b1b868984 100644 --- a/src/lib/film.cc +++ b/src/lib/film.cc @@ -64,7 +64,6 @@ using std::multimap; using std::pair; using std::map; using std::vector; -using std::ifstream; using std::setfill; using std::min; using std::make_pair; diff --git a/src/lib/writer.cc b/src/lib/writer.cc index 103ac2ba1..f4128e6c5 100644 --- a/src/lib/writer.cc +++ b/src/lib/writer.cc @@ -36,13 +36,13 @@ #include "audio_mapping.h" #include "config.h" #include "job.h" +#include "cross.h" #include "i18n.h" using std::make_pair; using std::pair; using std::string; -using std::ifstream; using std::list; using std::cout; using boost::shared_ptr; @@ -141,8 +141,9 @@ Writer::fake_write (int frame, Eyes eyes) { boost::mutex::scoped_lock lock (_mutex); - ifstream ifi (_film->info_path (frame, eyes).string().c_str()); + FILE* ifi = fopen_boost (_film->info_path (frame, eyes), "r"); libdcp::FrameInfo info (ifi); + fclose (ifi); QueueItem qi; qi.type = QueueItem::FAKE; @@ -430,8 +431,9 @@ bool Writer::check_existing_picture_mxf_frame (FILE* mxf, int f, Eyes eyes) { /* Read the frame info as written */ - ifstream ifi (_film->info_path (f, eyes).string().c_str()); + FILE* ifi = fopen_boost (_film->info_path (f, eyes), "r"); libdcp::FrameInfo info (ifi); + fclose (ifi); if (info.size == 0) { _film->log()->log (String::compose ("Existing frame %1 has no info file", f)); return false; -- cgit v1.2.3 From cef589d0d9dc12e14ecaa38eec463e2189f67253 Mon Sep 17 00:00:00 2001 From: Carl Hetherington Date: Mon, 25 Nov 2013 11:23:44 +0000 Subject: Bump libdcp version. --- cscript | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cscript b/cscript index 125a4d34c..fca4f76d2 100644 --- a/cscript +++ b/cscript @@ -1,10 +1,10 @@ -import glob +git import glob import shutil import os def dependencies(target): return (('ffmpeg-cdist', '0b7ef017aca8b572914518c759db1e234d8fc505'), - ('libdcp', 'f38137b21051ce770bbb4d829ae9d6229e97508f')) + ('libdcp', '6b8fdf76aa221f037140bbf0ee1aa835df60778f')) def build(target): cmd = './waf configure --prefix=%s' % target.work_dir_cscript() -- cgit v1.2.3 From 00caaa37c08ca16fb6d8a84a57f5434355a1d586 Mon Sep 17 00:00:00 2001 From: Carl Hetherington Date: Mon, 25 Nov 2013 11:25:00 +0000 Subject: Typo. --- cscript | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cscript b/cscript index fca4f76d2..9d45aa96a 100644 --- a/cscript +++ b/cscript @@ -1,4 +1,4 @@ -git import glob +import glob import shutil import os -- cgit v1.2.3 From bb4a0926cdaaba06285e152ca05faae413267f05 Mon Sep 17 00:00:00 2001 From: Carl Hetherington Date: Mon, 25 Nov 2013 11:47:40 +0000 Subject: Bump libdcp version. --- cscript | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cscript b/cscript index 9d45aa96a..e4f9859b9 100644 --- a/cscript +++ b/cscript @@ -4,7 +4,7 @@ import os def dependencies(target): return (('ffmpeg-cdist', '0b7ef017aca8b572914518c759db1e234d8fc505'), - ('libdcp', '6b8fdf76aa221f037140bbf0ee1aa835df60778f')) + ('libdcp', '2ee05f7ecc1847f1840610090ef3c093cf4a6554')) def build(target): cmd = './waf configure --prefix=%s' % target.work_dir_cscript() -- cgit v1.2.3 From d3df0fb564235b2dd1b7ec9d5d406233b8f793be Mon Sep 17 00:00:00 2001 From: Carl Hetherington Date: Mon, 25 Nov 2013 12:44:34 +0000 Subject: Fix windows build. --- src/lib/util.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/lib/util.cc b/src/lib/util.cc index c4a634c08..4a9998141 100644 --- a/src/lib/util.cc +++ b/src/lib/util.cc @@ -259,7 +259,7 @@ LONG WINAPI exception_handler(struct _EXCEPTION_POINTERS *) { dbg::stack s; FILE* f = fopen_boost (backtrace_file, "w"); - for (dbg::stack_frame::const_iterator i = s.begin(); i != s.end(); ++i) { + for (dbg::stack::const_iterator i = s.begin(); i != s.end(); ++i) { fprintf (f, "%p %s %d %s", i->instruction, i->function.c_str(), i->line, i->module.c_str()); } fclose (f); -- cgit v1.2.3 From 5122ff8a5b7471f94c8610d8bab2f5899b2ba1a1 Mon Sep 17 00:00:00 2001 From: Carl Hetherington Date: Mon, 25 Nov 2013 12:48:46 +0000 Subject: Tweak file structure diagram. --- doc/manual/diagrams/file-structure.svg | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/doc/manual/diagrams/file-structure.svg b/doc/manual/diagrams/file-structure.svg index e72636903..c19a6f023 100644 --- a/doc/manual/diagrams/file-structure.svg +++ b/doc/manual/diagrams/file-structure.svg @@ -15,7 +15,7 @@ id="svg2" version="1.1" inkscape:version="0.48.4 r9939" - sodipodi:docname="New document 1"> + sodipodi:docname="file-structure.svg"> @@ -2542,7 +2542,7 @@ image/svg+xml - + @@ -5736,43 +5736,43 @@ sodipodi:nodetypes="cc" /> DCP-o-matic'sworkingfiles DCP -- cgit v1.2.3 From 0882a398a0737568b49d1bcae6d4d24c4c39492d Mon Sep 17 00:00:00 2001 From: Carl Hetherington Date: Mon, 25 Nov 2013 14:07:06 +0000 Subject: Add voodoo to set locale for boost::filesystem. --- src/lib/util.cc | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/lib/util.cc b/src/lib/util.cc index 4a9998141..d99c3801f 100644 --- a/src/lib/util.cc +++ b/src/lib/util.cc @@ -277,6 +277,13 @@ dcpomatic_setup () backtrace_file /= g_get_user_config_dir (); backtrace_file /= "backtrace.txt"; SetUnhandledExceptionFilter(exception_handler); + + /* Dark voodoo which, I think, gets boost::filesystem::path to + correctly convert UTF-8 strings to paths, and also paths + back to UTF-8 strings (on path::string()). + */ + std::locale::global (boost::locale::generator().generate ("")); + boost::filesystem::path::imbue (std::locale ()); #endif avfilter_register_all (); -- cgit v1.2.3 From 641a0b8158f64bf66780041c0e7b32242ee686d3 Mon Sep 17 00:00:00 2001 From: Carl Hetherington Date: Mon, 25 Nov 2013 14:26:21 +0000 Subject: Missing include. --- src/lib/util.cc | 1 + 1 file changed, 1 insertion(+) diff --git a/src/lib/util.cc b/src/lib/util.cc index d99c3801f..e76b7aa67 100644 --- a/src/lib/util.cc +++ b/src/lib/util.cc @@ -39,6 +39,7 @@ #include #include #include +#include #include #include #include -- cgit v1.2.3 From ea73ac38b9ee0e75a264cec907e6ac99d2f5d54a Mon Sep 17 00:00:00 2001 From: Carl Hetherington Date: Mon, 25 Nov 2013 15:13:40 +0000 Subject: Link boost locale. --- src/lib/wscript | 2 +- wscript | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/src/lib/wscript b/src/lib/wscript index 852bb1aed..e317026f3 100644 --- a/src/lib/wscript +++ b/src/lib/wscript @@ -74,7 +74,7 @@ def build(bld): obj.export_includes = ['..'] obj.uselib = """ AVCODEC AVUTIL AVFORMAT AVFILTER SWSCALE SWRESAMPLE - BOOST_FILESYSTEM BOOST_THREAD BOOST_DATETIME BOOST_SIGNALS2 + BOOST_FILESYSTEM BOOST_THREAD BOOST_DATETIME BOOST_SIGNALS2 BOOST_LOCALE SNDFILE OPENJPEG POSTPROC TIFF MAGICK SSH DCP CXML GLIB LZMA XML++ CURL ZIP QUICKMAIL """ diff --git a/wscript b/wscript index 9d2450d34..138f947e4 100644 --- a/wscript +++ b/wscript @@ -185,6 +185,14 @@ def configure(conf): lib=['boost_date_time%s' % boost_lib_suffix, 'boost_system%s' % boost_lib_suffix], uselib_store='BOOST_DATETIME') + conf.check_cxx(fragment=""" + #include \n + int main() { std::locale::global (boost::locale::generator().generate ("")); }\n + """, msg='Checking for boost locale library', + libpath='/usr/local/lib', + lib=['boost_locale%s' % boost_lib_suffix, 'boost_system%s' % boost_lib_suffix], + uselib_store='BOOST_LOCALE') + conf.check_cxx(fragment=""" #include \n int main() { boost::signals2::signal x; }\n -- cgit v1.2.3 From 7e52c0c76f280c78218fde11906eb1407d360c4b Mon Sep 17 00:00:00 2001 From: Carl Hetherington Date: Mon, 25 Nov 2013 15:57:34 +0000 Subject: Try using utf8_str to convert wx filenames to boost. --- src/wx/film_editor.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/wx/film_editor.cc b/src/wx/film_editor.cc index 9cf840614..201bfa87a 100644 --- a/src/wx/film_editor.cc +++ b/src/wx/film_editor.cc @@ -745,7 +745,7 @@ FilmEditor::content_add_file_clicked () /* XXX: check for lots of files here and do something */ for (unsigned int i = 0; i < paths.GetCount(); ++i) { - _film->examine_and_add_content (content_factory (_film, wx_to_std (paths[i]))); + _film->examine_and_add_content (content_factory (_film, paths[i].utf8_str().data ())); } } -- cgit v1.2.3 From 9a5b74a15a21e4563db6fb083313d0160eb4a12a Mon Sep 17 00:00:00 2001 From: Carl Hetherington Date: Mon, 25 Nov 2013 16:06:24 +0000 Subject: Undo previous guess; try passing UTF-16 to Magick::Image constructor. --- src/lib/still_image_examiner.cc | 2 +- src/wx/film_editor.cc | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/lib/still_image_examiner.cc b/src/lib/still_image_examiner.cc index 5f45d6365..181a52654 100644 --- a/src/lib/still_image_examiner.cc +++ b/src/lib/still_image_examiner.cc @@ -33,7 +33,7 @@ StillImageExaminer::StillImageExaminer (shared_ptr f, shared_ptrpath().string()); + Magick::Image* image = new Magick::Image (_still_image_content->path().c_str ()); _video_size = libdcp::Size (image->columns(), image->rows()); delete image; } diff --git a/src/wx/film_editor.cc b/src/wx/film_editor.cc index 201bfa87a..b3b5242b2 100644 --- a/src/wx/film_editor.cc +++ b/src/wx/film_editor.cc @@ -745,7 +745,7 @@ FilmEditor::content_add_file_clicked () /* XXX: check for lots of files here and do something */ for (unsigned int i = 0; i < paths.GetCount(); ++i) { - _film->examine_and_add_content (content_factory (_film, paths[i].utf8_str().data ())); + _film->examine_and_add_content (content_factory (_film, wx_to_std (d->GetPath ()))); } } -- cgit v1.2.3 From 150b6453c454e6efa993c0f29700bdf74b890737 Mon Sep 17 00:00:00 2001 From: Carl Hetherington Date: Mon, 25 Nov 2013 16:08:23 +0000 Subject: Fix previous. --- src/lib/still_image_examiner.cc | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/lib/still_image_examiner.cc b/src/lib/still_image_examiner.cc index 181a52654..218eb967a 100644 --- a/src/lib/still_image_examiner.cc +++ b/src/lib/still_image_examiner.cc @@ -26,6 +26,7 @@ #include "i18n.h" using std::cout; +using std::string; using boost::shared_ptr; StillImageExaminer::StillImageExaminer (shared_ptr f, shared_ptr c) @@ -33,7 +34,7 @@ StillImageExaminer::StillImageExaminer (shared_ptr f, shared_ptrpath().c_str ()); + Magick::Image* image = new Magick::Image (string (_still_image_content->path().c_str ())); _video_size = libdcp::Size (image->columns(), image->rows()); delete image; } -- cgit v1.2.3 From cadf2d574d144098fffa3c61e0a2be88f496cac6 Mon Sep 17 00:00:00 2001 From: Carl Hetherington Date: Mon, 25 Nov 2013 22:50:02 +0000 Subject: Undo previous guess. --- src/lib/still_image_examiner.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/lib/still_image_examiner.cc b/src/lib/still_image_examiner.cc index 218eb967a..d5e863634 100644 --- a/src/lib/still_image_examiner.cc +++ b/src/lib/still_image_examiner.cc @@ -34,7 +34,7 @@ StillImageExaminer::StillImageExaminer (shared_ptr f, shared_ptrpath().c_str ())); + Magick::Image* image = new Magick::Image (_still_image_content->path().string ()); _video_size = libdcp::Size (image->columns(), image->rows()); delete image; } -- cgit v1.2.3 From 984921524ed4a558b5bcf0a880f6585d1f14f2f9 Mon Sep 17 00:00:00 2001 From: Carl Hetherington Date: Mon, 25 Nov 2013 23:40:06 +0000 Subject: More hacks. --- src/wx/new_film_dialog.cc | 4 ++-- src/wx/new_film_dialog.h | 2 +- src/wx/wx_util.cc | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/wx/new_film_dialog.cc b/src/wx/new_film_dialog.cc index 2612a6afe..be5af999e 100644 --- a/src/wx/new_film_dialog.cc +++ b/src/wx/new_film_dialog.cc @@ -74,11 +74,11 @@ NewFilmDialog::~NewFilmDialog () _directory = wx_to_std (_folder->GetPath ()); } -string +boost::filesystem::path NewFilmDialog::get_path () const { filesystem::path p; p /= wx_to_std (_folder->GetPath ()); p /= wx_to_std (_name->GetValue ()); - return p.string (); + return p; } diff --git a/src/wx/new_film_dialog.h b/src/wx/new_film_dialog.h index 4176b060d..a835c7ceb 100644 --- a/src/wx/new_film_dialog.h +++ b/src/wx/new_film_dialog.h @@ -29,7 +29,7 @@ public: NewFilmDialog (wxWindow *); ~NewFilmDialog (); - std::string get_path () const; + boost::filesystem::path get_path () const; private: wxTextCtrl* _name; diff --git a/src/wx/wx_util.cc b/src/wx/wx_util.cc index 27a4554ca..103d36d00 100644 --- a/src/wx/wx_util.cc +++ b/src/wx/wx_util.cc @@ -105,7 +105,7 @@ confirm_dialog (wxWindow* parent, wxString m) string wx_to_std (wxString s) { - return string (s.mb_str ()); + return string (s.ToUTF8 ()); } /** @param s STL string. -- cgit v1.2.3 From 247b3423fcea1d4d20d797b48cdbaafa8dad1ea1 Mon Sep 17 00:00:00 2001 From: Carl Hetherington Date: Tue, 26 Nov 2013 00:11:54 +0000 Subject: Don't destroy wxFileDialog before reading from it. --- src/wx/film_editor.cc | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/wx/film_editor.cc b/src/wx/film_editor.cc index b3b5242b2..6a2aea18d 100644 --- a/src/wx/film_editor.cc +++ b/src/wx/film_editor.cc @@ -733,9 +733,9 @@ FilmEditor::content_add_file_clicked () { wxFileDialog* d = new wxFileDialog (this, _("Choose a file or files"), wxT (""), wxT (""), wxT ("*.*"), wxFD_MULTIPLE); int const r = d->ShowModal (); - d->Destroy (); if (r != wxID_OK) { + d->Destroy (); return; } @@ -747,6 +747,8 @@ FilmEditor::content_add_file_clicked () for (unsigned int i = 0; i < paths.GetCount(); ++i) { _film->examine_and_add_content (content_factory (_film, wx_to_std (d->GetPath ()))); } + + d->Destroy (); } void -- cgit v1.2.3 From 9cd5745aebdb263bdf24afcc19823340c1809068 Mon Sep 17 00:00:00 2001 From: Carl Hetherington Date: Tue, 26 Nov 2013 04:00:25 +0000 Subject: Work around working directory error on Windows; bump libdcp. --- cscript | 2 +- src/wx/film_editor.cc | 5 ++++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/cscript b/cscript index e4f9859b9..5757164a9 100644 --- a/cscript +++ b/cscript @@ -4,7 +4,7 @@ import os def dependencies(target): return (('ffmpeg-cdist', '0b7ef017aca8b572914518c759db1e234d8fc505'), - ('libdcp', '2ee05f7ecc1847f1840610090ef3c093cf4a6554')) + ('libdcp', '66ea991028e62daf8bae5b6f1ad348c3eabe1da8')) def build(target): cmd = './waf configure --prefix=%s' % target.work_dir_cscript() diff --git a/src/wx/film_editor.cc b/src/wx/film_editor.cc index 6a2aea18d..ef3534939 100644 --- a/src/wx/film_editor.cc +++ b/src/wx/film_editor.cc @@ -731,7 +731,10 @@ FilmEditor::setup_content () void FilmEditor::content_add_file_clicked () { - wxFileDialog* d = new wxFileDialog (this, _("Choose a file or files"), wxT (""), wxT (""), wxT ("*.*"), wxFD_MULTIPLE); + /* The wxFD_CHANGE_DIR here prevents a `could not set working directory' error 123 on Windows when using + non-Latin filenames or paths. + */ + wxFileDialog* d = new wxFileDialog (this, _("Choose a file or files"), wxT (""), wxT (""), wxT ("*.*"), wxFD_MULTIPLE | wxFD_CHANGE_DIR); int const r = d->ShowModal (); if (r != wxID_OK) { -- cgit v1.2.3 From f2c465b7dfedfe845f9599fa98c9722fd86a110e Mon Sep 17 00:00:00 2001 From: Carl Hetherington Date: Tue, 26 Nov 2013 09:40:01 +0000 Subject: Add code to open a console on Win32. Hallelujah. --- src/tools/dcpomatic.cc | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/tools/dcpomatic.cc b/src/tools/dcpomatic.cc index 5d2157922..420d828b0 100644 --- a/src/tools/dcpomatic.cc +++ b/src/tools/dcpomatic.cc @@ -246,6 +246,22 @@ public: : wxFrame (NULL, -1, title) , _servers_list_dialog (0) { +#ifdef DCPOMATIC_WINDOWS_CONSOLE + AllocConsole(); + + HANDLE handle_out = GetStdHandle(STD_OUTPUT_HANDLE); + int hCrt = _open_osfhandle((intptr_t) handle_out, _O_TEXT); + FILE* hf_out = _fdopen(hCrt, "w"); + setvbuf(hf_out, NULL, _IONBF, 1); + *stdout = *hf_out; + + HANDLE handle_in = GetStdHandle(STD_INPUT_HANDLE); + hCrt = _open_osfhandle((intptr_t) handle_in, _O_TEXT); + FILE* hf_in = _fdopen(hCrt, "r"); + setvbuf(hf_in, NULL, _IONBF, 128); + *stdin = *hf_in; +#endif + wxMenuBar* bar = new wxMenuBar; setup_menu (bar); SetMenuBar (bar); -- cgit v1.2.3 From 1be5f1efd6e789812d8866c97ca4deabbcf97731 Mon Sep 17 00:00:00 2001 From: Carl Hetherington Date: Tue, 26 Nov 2013 09:59:32 +0000 Subject: Bump libdcp. --- cscript | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cscript b/cscript index 5757164a9..b80f48c59 100644 --- a/cscript +++ b/cscript @@ -4,7 +4,7 @@ import os def dependencies(target): return (('ffmpeg-cdist', '0b7ef017aca8b572914518c759db1e234d8fc505'), - ('libdcp', '66ea991028e62daf8bae5b6f1ad348c3eabe1da8')) + ('libdcp', 'aaa8fe37ec65ed9db6952d9424bbe0e892fe4dd4')) def build(target): cmd = './waf configure --prefix=%s' % target.work_dir_cscript() -- cgit v1.2.3 From 38add112b389e16d25130ad762eb8c31ca06c977 Mon Sep 17 00:00:00 2001 From: Carl Hetherington Date: Tue, 26 Nov 2013 09:59:39 +0000 Subject: Try to fix UTF-8 failure on Windows. --- src/tools/dcpomatic.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/tools/dcpomatic.cc b/src/tools/dcpomatic.cc index 420d828b0..2a0cb9cd3 100644 --- a/src/tools/dcpomatic.cc +++ b/src/tools/dcpomatic.cc @@ -347,7 +347,7 @@ private: std_to_wx ( String::compose (wx_to_std (_("The directory %1 already exists and is not empty. " "Are you sure you want to use it?")), - d->get_path().c_str()) + d->get_path().string().c_str()) ) )) { return; -- cgit v1.2.3 From acee0fce224b9376c55f2b58f1ff700496b185f3 Mon Sep 17 00:00:00 2001 From: Carl Hetherington Date: Tue, 26 Nov 2013 10:01:08 +0000 Subject: Comment. --- src/lib/util.cc | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/lib/util.cc b/src/lib/util.cc index e76b7aa67..e70440271 100644 --- a/src/lib/util.cc +++ b/src/lib/util.cc @@ -282,6 +282,14 @@ dcpomatic_setup () /* Dark voodoo which, I think, gets boost::filesystem::path to correctly convert UTF-8 strings to paths, and also paths back to UTF-8 strings (on path::string()). + + After this, constructing boost::filesystem::paths from strings + converts from UTF-8 to UTF-16 inside the path. Then + path::string().c_str() gives UTF-8 and + path::c_str() gives UTF-16. + + This is all Windows-only. AFAICT Linux/OS X use UTF-8 everywhere, + so things are much simpler. */ std::locale::global (boost::locale::generator().generate ("")); boost::filesystem::path::imbue (std::locale ()); -- cgit v1.2.3 From 675a5f16100ce60896de5b2049167250b22d01dd Mon Sep 17 00:00:00 2001 From: Carl Hetherington Date: Tue, 26 Nov 2013 10:12:27 +0000 Subject: libdcp version. --- cscript | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cscript b/cscript index b80f48c59..a49d545e0 100644 --- a/cscript +++ b/cscript @@ -4,7 +4,7 @@ import os def dependencies(target): return (('ffmpeg-cdist', '0b7ef017aca8b572914518c759db1e234d8fc505'), - ('libdcp', 'aaa8fe37ec65ed9db6952d9424bbe0e892fe4dd4')) + ('libdcp', '13e2454bc15abf7de6014002a2995fe43b0ed082')) def build(target): cmd = './waf configure --prefix=%s' % target.work_dir_cscript() -- cgit v1.2.3 From 02f33c1a55598848cbe9870d54dd2d4e67d301dc Mon Sep 17 00:00:00 2001 From: Carl Hetherington Date: Tue, 26 Nov 2013 19:17:56 +0000 Subject: Fix windows installers. --- platform/windows/installer.nsi.32.in | 3 ++- platform/windows/installer.nsi.64.in | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/platform/windows/installer.nsi.32.in b/platform/windows/installer.nsi.32.in index 9b719f825..629edd50c 100644 --- a/platform/windows/installer.nsi.32.in +++ b/platform/windows/installer.nsi.32.in @@ -33,6 +33,7 @@ File "%static_deps%/bin/libboost_filesystem-mt.dll" File "%static_deps%/bin/libboost_system-mt.dll" File "%static_deps%/bin/libboost_thread_win32-mt.dll" File "%static_deps%/bin/libboost_date_time-mt.dll" +File "%static_deps%/bin/libboost_locale-mt.dll" File "%static_deps%/bin/libeay32.dll" File "%static_deps%/bin/libgcc_s_sjlj-1.dll" File "%static_deps%/bin/libgio-2.0-0.dll" @@ -40,7 +41,7 @@ File "%static_deps%/bin/libglib-2.0-0.dll" File "%static_deps%/bin/libgobject-2.0-0.dll" File "%static_deps%/bin/libiconv-2.dll" File "%static_deps%/bin/libjpeg-8.dll" -File "%static_deps%/bin/libMagick++-6.Q16-2.dll" +File "%static_deps%/bin/libMagick++-6.Q16-3.dll" File "%static_deps%/bin/libMagickCore-6.Q16-1.dll" File "%static_deps%/bin/libMagickWand-6.Q16-1.dll" File "%static_deps%/bin/libpng15-15.dll" diff --git a/platform/windows/installer.nsi.64.in b/platform/windows/installer.nsi.64.in index c53c2cacc..de1e09107 100644 --- a/platform/windows/installer.nsi.64.in +++ b/platform/windows/installer.nsi.64.in @@ -43,6 +43,7 @@ File "%static_deps%/bin/libboost_filesystem-mt.dll" File "%static_deps%/bin/libboost_system-mt.dll" File "%static_deps%/bin/libboost_thread_win32-mt.dll" File "%static_deps%/bin/libboost_date_time-mt.dll" +File "%static_deps%/bin/libboost_locale-mt.dll" File "%static_deps%/bin/libeay32.dll" File "%static_deps%/bin/libgcc_s_sjlj-1.dll" File "%static_deps%/bin/libgio-2.0-0.dll" @@ -50,7 +51,7 @@ File "%static_deps%/bin/libglib-2.0-0.dll" File "%static_deps%/bin/libgobject-2.0-0.dll" File "%static_deps%/bin/libiconv-2.dll" File "%static_deps%/bin/libjpeg-8.dll" -File "%static_deps%/bin/libMagick++-6.Q16-2.dll" +File "%static_deps%/bin/libMagick++-6.Q16-3.dll" File "%static_deps%/bin/libMagickCore-6.Q16-1.dll" File "%static_deps%/bin/libMagickWand-6.Q16-1.dll" File "%static_deps%/bin/libpng15-15.dll" -- cgit v1.2.3 From c9abaac836384ec50738f437106c0ad62025970b Mon Sep 17 00:00:00 2001 From: Carl Hetherington Date: Tue, 26 Nov 2013 19:28:56 +0000 Subject: Bump libdcp. --- cscript | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cscript b/cscript index a49d545e0..234db1e6b 100644 --- a/cscript +++ b/cscript @@ -4,7 +4,7 @@ import os def dependencies(target): return (('ffmpeg-cdist', '0b7ef017aca8b572914518c759db1e234d8fc505'), - ('libdcp', '13e2454bc15abf7de6014002a2995fe43b0ed082')) + ('libdcp', '6002b39d878fec75881b75dcda1c7d63e4271799')) def build(target): cmd = './waf configure --prefix=%s' % target.work_dir_cscript() -- cgit v1.2.3 From e51a18257d613ea08d0b39c957a4b73d5711daa9 Mon Sep 17 00:00:00 2001 From: Carl Hetherington Date: Tue, 26 Nov 2013 21:01:41 +0000 Subject: Bump libdcp. --- cscript | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cscript b/cscript index 234db1e6b..629688347 100644 --- a/cscript +++ b/cscript @@ -4,7 +4,7 @@ import os def dependencies(target): return (('ffmpeg-cdist', '0b7ef017aca8b572914518c759db1e234d8fc505'), - ('libdcp', '6002b39d878fec75881b75dcda1c7d63e4271799')) + ('libdcp', '6a401d409524d9809760410a51cf3adada77794a')) def build(target): cmd = './waf configure --prefix=%s' % target.work_dir_cscript() -- cgit v1.2.3 From 32777299bee7f452971b4ae47c780796e27afc8e Mon Sep 17 00:00:00 2001 From: Carl Hetherington Date: Tue, 26 Nov 2013 21:40:46 +0000 Subject: Bump libdcp. --- cscript | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cscript b/cscript index 629688347..3830cdc81 100644 --- a/cscript +++ b/cscript @@ -4,7 +4,7 @@ import os def dependencies(target): return (('ffmpeg-cdist', '0b7ef017aca8b572914518c759db1e234d8fc505'), - ('libdcp', '6a401d409524d9809760410a51cf3adada77794a')) + ('libdcp', 'd0b7892cbab3618fca85a4c95d70d8a1c26a5c4d')) def build(target): cmd = './waf configure --prefix=%s' % target.work_dir_cscript() -- cgit v1.2.3