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