Files
Jungfraujoch/common/CheckPath.h

22 lines
750 B
C++

// Copyright (2019-2024) Paul Scherrer Institute
#ifndef JFJOCH_CHECKPATH_H
#define JFJOCH_CHECKPATH_H
#include <string>
#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