MCPcopy Create free account
hub / github.com/cppcheck-opensource/cppcheck / isAbsolute

Method isAbsolute

lib/path.cpp:176–190  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

174}
175
176bool Path::isAbsolute(const std::string& path)
177{
178#ifdef _WIN32
179 if (path.length() < 2)
180 return false;
181
182 if ((path[0] == '\\' || path[0] == '/') && (path[1] == '\\' || path[1] == '/'))
183 return true;
184
185 // On Windows, 'C:\foo\bar' is an absolute path, while 'C:foo\bar' is not
186 return std::isalpha(path[0]) && path[1] == ':' && (path[2] == '\\' || path[2] == '/');
187#else
188 return !path.empty() && path[0] == '/';
189#endif
190}
191
192bool Path::isRelative(const std::string& path)
193{

Callers 3

startApplicationMethod · 0.45
getCppcheckSettingsMethod · 0.45
analyzeProjectMethod · 0.45

Calls 1

emptyMethod · 0.45

Tested by

no test coverage detected