Black Lives Matter. Support the Equal Justice Initiative.

Source file src/path/filepath/path_unix.go

Documentation: path/filepath

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

View as plain text