Source file src/path/filepath/path_unix.go

     1  // Copyright 2010 The Go Authors. All rights reserved.
     2  // Use of this source code is governed by a BSD-style
     3  // license that can be found in the LICENSE file.
     4  
     5  //go:build unix || (js && wasm) || wasip1
     6  
     7  package filepath
     8  
     9  import "strings"
    10  
    11  func isLocal(path string) bool {
    12  	return unixIsLocal(path)
    13  }
    14  
    15  // IsAbs reports whether the path is absolute.
    16  func IsAbs(path string) bool {
    17  	return strings.HasPrefix(path, "/")
    18  }
    19  
    20  // volumeNameLen returns length of the leading volume name on Windows.
    21  // It returns 0 elsewhere.
    22  func volumeNameLen(path string) int {
    23  	return 0
    24  }
    25  
    26  // HasPrefix exists for historical compatibility and should not be used.
    27  //
    28  // Deprecated: HasPrefix does not respect path boundaries and
    29  // does not ignore case when required.
    30  func HasPrefix(p, prefix string) bool {
    31  	return strings.HasPrefix(p, prefix)
    32  }
    33  
    34  func splitList(path string) []string {
    35  	if path == "" {
    36  		return []string{}
    37  	}
    38  	return strings.Split(path, string(ListSeparator))
    39  }
    40  
    41  func abs(path string) (string, error) {
    42  	return unixAbs(path)
    43  }
    44  
    45  func join(elem []string) string {
    46  	// If there's a bug here, fix the logic in ./path_plan9.go too.
    47  	for i, e := range elem {
    48  		if e != "" {
    49  			return Clean(strings.Join(elem[i:], string(Separator)))
    50  		}
    51  	}
    52  	return ""
    53  }
    54  
    55  func sameWord(a, b string) bool {
    56  	return a == b
    57  }
    58  

View as plain text