// Copyright (2019-2024) Paul Scherrer Institute #ifndef JFJOCH_CHECKPATH_H #define JFJOCH_CHECKPATH_H #include #include "JFJochException.h" inline void CheckPath(const std::string &s) { if (s.front() == '/') throw JFJochException(JFJochExceptionCategory::InputParameterInvalid, "Path cannot start with slash"); if (s.substr(0,3) == "../") throw JFJochException(JFJochExceptionCategory::InputParameterInvalid, "Path cannot start with ../"); if (s.find("/../") != std::string::npos) throw JFJochException(JFJochExceptionCategory::InputParameterInvalid, "Path cannot contain /../"); } #endif //JFJOCH_CHECKPATH_H