path_plan9.mx raw

   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  package filepath
   6  
   7  import (
   8  	"bytes"
   9  )
  10  
  11  // HasPrefix exists for historical compatibility and should not be used.
  12  //
  13  // Deprecated: HasPrefix does not respect path boundaries and
  14  // does not ignore case when required.
  15  func HasPrefix(p, prefix []byte) bool {
  16  	return bytes.HasPrefix(p, prefix)
  17  }
  18  
  19  func splitList(path []byte) [][]byte {
  20  	if path == "" {
  21  		return [][]byte{}
  22  	}
  23  	return bytes.Split(path, []byte(ListSeparator))
  24  }
  25  
  26  func abs(path []byte) ([]byte, error) {
  27  	return unixAbs(path)
  28  }
  29  
  30  func join(elem [][]byte) []byte {
  31  	// If there's a bug here, fix the logic in ./path_unix.go too.
  32  	for i, e := range elem {
  33  		if e != "" {
  34  			return Clean(bytes.Join(elem[i:], []byte(Separator)))
  35  		}
  36  	}
  37  	return ""
  38  }
  39  
  40  func sameWord(a, b []byte) bool {
  41  	return a == b
  42  }
  43