SectionPairFileExtensionValidator.cpp 1.1 KB

12345678910111213141516171819202122232425
  1. /*
  2. * Author: Patrick-Christopher Mattulat
  3. * Company: Lynar Studios
  4. * E-Mail: webmaster@lynarstudios.com
  5. * Created: 2023-02-21
  6. * Changed: 2023-02-22
  7. *
  8. * */
  9. #include <ls-std/io/section-pair/validator/SectionPairFileExtensionValidator.hpp>
  10. ls::std::io::SectionPairFileExtensionValidator::SectionPairFileExtensionValidator(::std::string _fileName) : ls::std::core::Class("SectionPairFileExtensionValidator"), fileName(::std::move(_fileName))
  11. {}
  12. ls::std::io::SectionPairFileExtensionValidator::~SectionPairFileExtensionValidator() noexcept = default;
  13. bool ls::std::io::SectionPairFileExtensionValidator::isValid()
  14. {
  15. ::std::string textFileExtension = ".txt";
  16. ::std::string sectionPairFileExtension = ".sp";
  17. bool endsWithTextFileExtension = this->fileName.rfind(textFileExtension) == (this->fileName.size() - textFileExtension.size());
  18. bool endsWithSectionPairFileExtension = this->fileName.rfind(sectionPairFileExtension) == (this->fileName.size() - sectionPairFileExtension.size());
  19. return endsWithTextFileExtension || endsWithSectionPairFileExtension;
  20. }