FileExistenceEvaluator.cpp 943 B

12345678910111213141516171819202122232425262728293031323334
  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-23
  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. using ls::std::core::Class;
  14. using ls::std::core::FileNotFoundException;
  15. using ls::std::io::File;
  16. using ls::std::io::FileExistenceEvaluator;
  17. using std::move;
  18. using std::string;
  19. FileExistenceEvaluator::FileExistenceEvaluator(string _filePath) : Class("FileExistenceEvaluator"), filePath(::move(_filePath))
  20. {}
  21. FileExistenceEvaluator::~FileExistenceEvaluator() noexcept = default;
  22. void FileExistenceEvaluator::evaluate()
  23. {
  24. if (!File{this->filePath}.exists())
  25. {
  26. string message = "\"" + this->filePath + "\" does not exist!";
  27. throw FileNotFoundException{message};
  28. }
  29. }