MCPcopy Create free account
hub / github.com/docker/cli / volumeNameLen

Function volumeNameLen

cli/compose/loader/windows_path.go:33–67  ·  view source on GitHub ↗

volumeNameLen returns length of the leading volume name on Windows. It returns 0 elsewhere. nolint:gocyclo

(path string)

Source from the content-addressed store, hash-verified

31//
32//nolint:gocyclo
33func volumeNameLen(path string) int {
34 if len(path) < 2 {
35 return 0
36 }
37 // with drive letter
38 c := path[0]
39 if path[1] == ':' && ('a' <= c && c <= 'z' || 'A' <= c && c <= 'Z') {
40 return 2
41 }
42 // is it UNC? https://msdn.microsoft.com/en-us/library/windows/desktop/aa365247(v=vs.85).aspx
43 if l := len(path); l >= 5 && isSlash(path[0]) && isSlash(path[1]) &&
44 !isSlash(path[2]) && path[2] != '.' {
45 // first, leading `\\` and next shouldn't be `\`. its server name.
46 for n := 3; n < l-1; n++ {
47 // second, next '\' shouldn't be repeated.
48 if isSlash(path[n]) {
49 n++
50 // third, following something characters. its share name.
51 if !isSlash(path[n]) {
52 if path[n] == '.' {
53 break
54 }
55 for ; n < l; n++ {
56 if isSlash(path[n]) {
57 break
58 }
59 }
60 return n
61 }
62 break
63 }
64 }
65 }
66 return 0
67}

Callers 1

isAbsFunction · 0.85

Calls 1

isSlashFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…