summaryrefslogtreecommitdiff
path: root/src/lib/string_text_file.cc
diff options
context:
space:
mode:
authorCarl Hetherington <cth@carlh.net>2022-04-16 22:20:54 +0200
committerCarl Hetherington <cth@carlh.net>2022-05-05 23:38:41 +0200
commit8a8c977c12fc65f1f50ea05099387e0fc8840e7d (patch)
tree2d2c8663652939d643779d1ab1c18a12813fcbd2 /src/lib/string_text_file.cc
parentefe153ab23b54cdbf28c653f2ccb0f25ca6bd015 (diff)
Use dcp::File in DCP-o-matic (#2231).
Diffstat (limited to 'src/lib/string_text_file.cc')
-rw-r--r--src/lib/string_text_file.cc22
1 files changed, 12 insertions, 10 deletions
diff --git a/src/lib/string_text_file.cc b/src/lib/string_text_file.cc
index 8c2c56518..b8ca27e16 100644
--- a/src/lib/string_text_file.cc
+++ b/src/lib/string_text_file.cc
@@ -18,29 +18,33 @@
*/
-#include "string_text_file.h"
+
#include "cross.h"
#include "exceptions.h"
+#include "string_text_file.h"
#include "string_text_file_content.h"
-#include <sub/subrip_reader.h>
+#include <dcp/file.h>
+#include <sub/collect.h>
#include <sub/ssa_reader.h>
#include <sub/stl_binary_reader.h>
-#include <sub/collect.h>
+#include <sub/subrip_reader.h>
#include <unicode/ucsdet.h>
#include <unicode/ucnv.h>
#include <iostream>
#include "i18n.h"
-using std::vector;
+
using std::cout;
-using std::string;
using std::shared_ptr;
+using std::string;
+using std::vector;
using boost::scoped_array;
using boost::optional;
using dcp::ArrayData;
using namespace dcpomatic;
+
StringTextFile::StringTextFile (shared_ptr<const StringTextFileContent> content)
{
string ext = content->path(0).extension().string();
@@ -49,17 +53,15 @@ StringTextFile::StringTextFile (shared_ptr<const StringTextFileContent> content)
std::unique_ptr<sub::Reader> reader;
if (ext == ".stl") {
- auto f = fopen_boost (content->path(0), "rb");
+ dcp::File f(content->path(0), "rb");
if (!f) {
- throw OpenFileError (content->path(0), errno, OpenFileError::READ);
+ throw OpenFileError (f.path(), errno, OpenFileError::READ);
}
try {
- reader.reset(new sub::STLBinaryReader(f));
+ reader.reset(new sub::STLBinaryReader(f.get()));
} catch (...) {
- fclose (f);
throw;
}
- fclose (f);
} else {
/* Text-based file; sort out its character encoding before we try to parse it */