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

Function FindDriveLetter

src/butil/files/file_path.cc:47–58  ·  view source on GitHub ↗

If this FilePath contains a drive letter specification, returns the position of the last character of the drive letter specification, otherwise returns npos. This can only be true on Windows, when a pathname begins with a letter followed by a colon. On other platforms, this always returns npos.

Source from the content-addressed store, hash-verified

45// begins with a letter followed by a colon. On other platforms, this always
46// returns npos.
47StringType::size_type FindDriveLetter(const StringType& path) {
48#if defined(FILE_PATH_USES_DRIVE_LETTERS)
49 // This is dependent on an ASCII-based character set, but that's a
50 // reasonable assumption. iswalpha can be too inclusive here.
51 if (path.length() >= 2 && path[1] == L':' &&
52 ((path[0] >= L'A' && path[0] <= L'Z') ||
53 (path[0] >= L'a' && path[0] <= L'z'))) {
54 return 1;
55 }
56#endif // FILE_PATH_USES_DRIVE_LETTERS
57 return StringType::npos;
58}
59
60#if defined(FILE_PATH_USES_DRIVE_LETTERS)
61bool EqualDriveLetterCaseInsensitive(const StringType& a,

Callers 8

IsPathAbsoluteFunction · 0.85
GetComponentsMethod · 0.85
AppendRelativePathMethod · 0.85
DirNameMethod · 0.85
BaseNameMethod · 0.85
AppendMethod · 0.85

Calls 1

lengthMethod · 0.45

Tested by

no test coverage detected