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 aix || darwin || dragonfly || freebsd || (js && wasm) || linux || netbsd || openbsd || solaris
     6  
     7  package filepath
     8  
     9  import "strings"
    10  
    11  // IsAbs reports whether the path is absolute.
    12  func IsAbs(path string) bool {
    13  	return strings.HasPrefix(path, "/")
    14  }
    15  
    16  // volumeNameLen returns length of the leading volume name on Windows.
    17  // It returns 0 elsewhere.
    18  func volumeNameLen(path string) int {
    19  	return 0
    20  }
    21  
    22  // HasPrefix exists for historical compatibility and should not be used.
    23  //
    24  // Deprecated: HasPrefix does not respect path boundaries and
    25  // does not ignore case when required.
    26  func HasPrefix(p, prefix string) bool {
    27  	return strings.HasPrefix(p, prefix)
    28  }
    29  
    30  func splitList(path string) []string {
    31  	if path == "" {
    32  		return []string{}
    33  	}
    34  	return strings.Split(path, string(ListSeparator))
    35  }
    36  
    37  func abs(path string) (string, error) {
    38  	return unixAbs(path)
    39  }
    40  
    41  func join(elem []string) string {
    42  	// If there's a bug here, fix the logic in ./path_plan9.go too.
    43  	for i, e := range elem {
    44  		if e != "" {
    45  			return Clean(strings.Join(elem[i:], string(Separator)))
    46  		}
    47  	}
    48  	return ""
    49  }
    50  
    51  func sameWord(a, b string) bool {
    52  	return a == b
    53  }
    54  

View as plain text