From 6b8fdf76aa221f037140bbf0ee1aa835df60778f Mon Sep 17 00:00:00 2001 From: Carl Hetherington Date: Mon, 25 Nov 2013 11:23:07 +0000 Subject: Remove a possibly dodgy use of fstream. --- src/util.cc | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'src/util.cc') diff --git a/src/util.cc b/src/util.cc index 59078511..8624ae51 100644 --- a/src/util.cc +++ b/src/util.cc @@ -343,3 +343,20 @@ libdcp::ptime_to_string (boost::posix_time::ptime t) struct tm t_tm = boost::posix_time::to_tm (t); return tm_to_string (&t_tm); } + + +/* 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 * +libdcp::fopen_boost (boost::filesystem::path p, string t) +{ +#ifdef LIBDCP_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 +} -- cgit v1.2.3