X-Git-Url: https://git.carlh.net/gitweb/?a=blobdiff_plain;f=src%2Flib%2Fstring_text_file.cc;h=8c2c5651854e08a625f2d9602bfc9aaede91cf43;hb=6e93ff6ac5b514d1b8dd9ccb2d6372576a52761a;hp=793619003aab29cfdee6ec0170ef440c4b63ad3d;hpb=6fa9748f382302fa88292b4219598bb81edc7bd0;p=dcpomatic.git diff --git a/src/lib/string_text_file.cc b/src/lib/string_text_file.cc index 793619003..8c2c56518 100644 --- a/src/lib/string_text_file.cc +++ b/src/lib/string_text_file.cc @@ -35,7 +35,7 @@ using std::vector; using std::cout; using std::string; -using boost::shared_ptr; +using std::shared_ptr; using boost::scoped_array; using boost::optional; using dcp::ArrayData; @@ -46,15 +46,15 @@ StringTextFile::StringTextFile (shared_ptr content) string ext = content->path(0).extension().string(); transform (ext.begin(), ext.end(), ext.begin(), ::tolower); - sub::Reader* reader = 0; + std::unique_ptr reader; if (ext == ".stl") { - FILE* f = fopen_boost (content->path(0), "rb"); + auto f = fopen_boost (content->path(0), "rb"); if (!f) { throw OpenFileError (content->path(0), errno, OpenFileError::READ); } try { - reader = new sub::STLBinaryReader (f); + reader.reset(new sub::STLBinaryReader(f)); } catch (...) { fclose (f); throw; @@ -100,17 +100,15 @@ StringTextFile::StringTextFile (shared_ptr content) ucnv_close (to_utf8); if (ext == ".srt") { - reader = new sub::SubripReader (utf8.get()); + reader.reset(new sub::SubripReader(utf8.get())); } else if (ext == ".ssa" || ext == ".ass") { - reader = new sub::SSAReader (utf8.get()); + reader.reset(new sub::SSAReader(utf8.get())); } } if (reader) { - _subtitles = sub::collect > (reader->subtitles ()); + _subtitles = sub::collect>(reader->subtitles()); } - - delete reader; } /** @return time of first subtitle, if there is one */