github.com/panjjo/go@v0.0.0-20161104043856-d62b31386338/src/path/filepath/path_unix.go (about)

     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  // +build darwin dragonfly freebsd linux nacl 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: Use strings.HasPrefix instead.
    25  func HasPrefix(p, prefix string) bool {
    26  	return strings.HasPrefix(p, prefix)
    27  }
    28  
    29  func splitList(path string) []string {
    30  	if path == "" {
    31  		return []string{}
    32  	}
    33  	return strings.Split(path, string(ListSeparator))
    34  }
    35  
    36  func abs(path string) (string, error) {
    37  	return unixAbs(path)
    38  }
    39  
    40  func join(elem []string) string {
    41  	// If there's a bug here, fix the logic in ./path_plan9.go too.
    42  	for i, e := range elem {
    43  		if e != "" {
    44  			return Clean(strings.Join(elem[i:], string(Separator)))
    45  		}
    46  	}
    47  	return ""
    48  }
    49  
    50  func sameWord(a, b string) bool {
    51  	return a == b
    52  }