MCPcopy Create free account
hub / github.com/apache/brpc / IsPathAbsolute

Function IsPathAbsolute

src/butil/files/file_path.cc:80–95  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

78#endif // defined(FILE_PATH_USES_DRIVE_LETTERS)
79
80bool IsPathAbsolute(const StringType& path) {
81#if defined(FILE_PATH_USES_DRIVE_LETTERS)
82 StringType::size_type letter = FindDriveLetter(path);
83 if (letter != StringType::npos) {
84 // Look for a separator right after the drive specification.
85 return path.length() > letter + 1 &&
86 FilePath::IsSeparator(path[letter + 1]);
87 }
88 // Look for a pair of leading separators.
89 return path.length() > 1 &&
90 FilePath::IsSeparator(path[0]) && FilePath::IsSeparator(path[1]);
91#else // FILE_PATH_USES_DRIVE_LETTERS
92 // Look for a separator in the first position.
93 return path.length() > 0 && FilePath::IsSeparator(path[0]);
94#endif // FILE_PATH_USES_DRIVE_LETTERS
95}
96
97bool AreAllSeparators(const StringType& input) {
98 for (StringType::const_iterator it = input.begin();

Callers 2

AppendMethod · 0.85
IsAbsoluteMethod · 0.85

Calls 2

FindDriveLetterFunction · 0.85
lengthMethod · 0.45

Tested by

no test coverage detected