summaryrefslogtreecommitdiff
path: root/src/util.cc
diff options
context:
space:
mode:
authorCarl Hetherington <cth@carlh.net>2013-11-25 11:23:07 +0000
committerCarl Hetherington <cth@carlh.net>2013-11-25 11:23:07 +0000
commit6b8fdf76aa221f037140bbf0ee1aa835df60778f (patch)
tree7798c30001a4fea8af5ba9e19c9ad5fd62d6ce17 /src/util.cc
parent331045156161a30ee74e734c7c14dd602ebbbbc9 (diff)
Remove a possibly dodgy use of fstream.
Diffstat (limited to 'src/util.cc')
-rw-r--r--src/util.cc17
1 files changed, 17 insertions, 0 deletions
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
+}