forked from mia/Aegisub
Support extensions with multiple dots in agi::fs::HasExtension
This commit is contained in:
parent
b885c2c19d
commit
6cb9665202
5 changed files with 4 additions and 12 deletions
|
@ -100,7 +100,9 @@ namespace agi { namespace fs {
|
|||
}
|
||||
|
||||
bool HasExtension(path const& p, std::string const& ext) {
|
||||
if (!p.has_extension()) return ext.empty();
|
||||
return boost::iequals(p.extension().string().substr(1), ext);
|
||||
auto filename = p.filename().string();
|
||||
if (filename.size() < ext.size() + 1) return false;
|
||||
if (filename[filename.size() - ext.size() - 1] != '.') return false;
|
||||
return boost::iends_with(filename, ext);
|
||||
}
|
||||
} }
|
||||
|
|
|
@ -57,10 +57,6 @@ std::vector<std::string> EncoreSubtitleFormat::GetWriteWildcards() const {
|
|||
return formats;
|
||||
}
|
||||
|
||||
bool EncoreSubtitleFormat::CanWriteFile(agi::fs::path const& filename) const {
|
||||
return boost::iends_with(filename.string(), ".encore.txt");
|
||||
}
|
||||
|
||||
void EncoreSubtitleFormat::WriteFile(const AssFile *src, agi::fs::path const& filename, std::string const&) const {
|
||||
agi::vfr::Framerate fps = AskForFPS(false, true);
|
||||
if (!fps.IsLoaded()) return;
|
||||
|
|
|
@ -38,6 +38,5 @@ class EncoreSubtitleFormat : public SubtitleFormat {
|
|||
public:
|
||||
EncoreSubtitleFormat();
|
||||
std::vector<std::string> GetWriteWildcards() const override;
|
||||
bool CanWriteFile(agi::fs::path const& filename) const override;
|
||||
void WriteFile(const AssFile *src, agi::fs::path const& filename, std::string const&) const override;
|
||||
};
|
||||
|
|
|
@ -61,10 +61,6 @@ std::vector<std::string> TranStationSubtitleFormat::GetWriteWildcards() const {
|
|||
return formats;
|
||||
}
|
||||
|
||||
bool TranStationSubtitleFormat::CanWriteFile(agi::fs::path const& filename) const {
|
||||
return boost::iends_with(filename.string(), ".transtation.txt");
|
||||
}
|
||||
|
||||
void TranStationSubtitleFormat::WriteFile(const AssFile *src, agi::fs::path const& filename, std::string const& encoding) const {
|
||||
agi::vfr::Framerate fps = AskForFPS(false, true);
|
||||
if (!fps.IsLoaded()) return;
|
||||
|
|
|
@ -42,7 +42,6 @@ class TranStationSubtitleFormat : public SubtitleFormat {
|
|||
|
||||
public:
|
||||
TranStationSubtitleFormat();
|
||||
bool CanWriteFile(agi::fs::path const& filename) const override;
|
||||
std::vector<std::string> GetWriteWildcards() const override;
|
||||
void WriteFile(const AssFile *src, agi::fs::path const& filename, std::string const& encoding) const override;
|
||||
};
|
||||
|
|
Loading…
Reference in a new issue