Preserve the filename header when reading attachments
This commit is contained in:
parent
23a21b33b1
commit
29eb7b5e9e
3 changed files with 7 additions and 6 deletions
|
@ -25,8 +25,9 @@
|
|||
#include <boost/range/iterator_range.hpp>
|
||||
#include <fstream>
|
||||
|
||||
AssAttachment::AssAttachment(std::string const& name, AssEntryGroup group)
|
||||
: filename(name)
|
||||
AssAttachment::AssAttachment(std::string const& header, AssEntryGroup group)
|
||||
: entry_data(header + "\r\n")
|
||||
, filename(header.substr(10))
|
||||
, group(group)
|
||||
{
|
||||
}
|
||||
|
@ -35,7 +36,7 @@ AssAttachment::AssAttachment(agi::fs::path const& name, AssEntryGroup group)
|
|||
: filename(name.filename().string())
|
||||
, group(group)
|
||||
{
|
||||
// SSA stuffs some information about the font in the embeded filename, but
|
||||
// SSA stuffs some information about the font in the embedded filename, but
|
||||
// nothing else uses it so just do the absolute minimum (0 is the encoding)
|
||||
if (boost::iends_with(filename.get(), ".ttf"))
|
||||
filename = filename.get().substr(0, filename.get().size() - 4) + "_0" + filename.get().substr(filename.get().size() - 4);
|
||||
|
|
|
@ -50,6 +50,6 @@ public:
|
|||
AssEntryGroup Group() const override { return group; }
|
||||
AssEntry *Clone() const override;
|
||||
|
||||
AssAttachment(std::string const& name, AssEntryGroup group);
|
||||
AssAttachment(std::string const& header, AssEntryGroup group);
|
||||
AssAttachment(agi::fs::path const& name, AssEntryGroup group);
|
||||
};
|
||||
|
|
|
@ -107,12 +107,12 @@ void AssParser::ParseStyleLine(std::string const& data) {
|
|||
|
||||
void AssParser::ParseFontLine(std::string const& data) {
|
||||
if (boost::starts_with(data, "fontname: "))
|
||||
attach.reset(new AssAttachment(data.substr(10), AssEntryGroup::FONT));
|
||||
attach.reset(new AssAttachment(data, AssEntryGroup::FONT));
|
||||
}
|
||||
|
||||
void AssParser::ParseGraphicsLine(std::string const& data) {
|
||||
if (boost::starts_with(data, "filename: "))
|
||||
attach.reset(new AssAttachment(data.substr(10), AssEntryGroup::GRAPHIC));
|
||||
attach.reset(new AssAttachment(data, AssEntryGroup::GRAPHIC));
|
||||
}
|
||||
|
||||
void AssParser::AddLine(std::string const& data) {
|
||||
|
|
Loading…
Reference in a new issue