FileExistenceEvaluator.cpp 867 B

123456789101112131415161718192021222324252627
  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/core/exception/FileNotFoundException.hpp>
  10. #include <ls-std/io/File.hpp>
  11. #include <ls-std/io/evaluator/FileExistenceEvaluator.hpp>
  12. #include <string>
  13. ls::std::io::FileExistenceEvaluator::FileExistenceEvaluator(::std::string _filePath) : ls::std::core::Class("FileExistenceEvaluator"), filePath(::std::move(_filePath))
  14. {}
  15. ls::std::io::FileExistenceEvaluator::~FileExistenceEvaluator() noexcept = default;
  16. void ls::std::io::FileExistenceEvaluator::evaluate()
  17. {
  18. if (!ls::std::io::File{this->filePath}.exists())
  19. {
  20. ::std::string message = "\"" + this->filePath + "\" does not exist!";
  21. throw ls::std::core::FileNotFoundException{message};
  22. }
  23. }