1 // Copyright 2020 CUE Authors 2 // 3 // Licensed under the Apache License, Version 2.0 (the "License"); 4 // you may not use this file except in compliance with the License. 5 // You may obtain a copy of the License at 6 // 7 // http://www.apache.org/licenses/LICENSE-2.0 8 // 9 // Unless required by applicable law or agreed to in writing, software 10 // distributed under the License is distributed on an "AS IS" BASIS, 11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 // See the License for the specific language governing permissions and 13 // limitations under the License. 14 15 // Copyright 2010 The Go Authors. All rights reserved. 16 // Use of this source code is governed by a BSD-style 17 // license that can be found in the LICENSE file. 18 19 package path 20 21 import "strings" 22 23 const plan9Separator = '/' 24 const plan9ListSeparator = '\000' 25 26 type plan9Info struct{} 27 28 var _ osInfo = plan9Info{} 29 30 func (o plan9Info) IsPathSeparator(b byte) bool { 31 return b == plan9Separator 32 } 33 34 // IsAbs reports whether the path is absolute. 35 func (o plan9Info) IsAbs(path string) bool { 36 return strings.HasPrefix(path, "/") || strings.HasPrefix(path, "#") 37 } 38 39 // volumeNameLen returns length of the leading volume name on Windows. 40 // It returns 0 elsewhere. 41 func (o plan9Info) volumeNameLen(path string) int { 42 return 0 43 } 44 45 // HasPrefix exists for historical compatibility and should not be used. 46 // 47 // Deprecated: HasPrefix does not respect path boundaries and 48 // does not ignore case when required. 49 func (o plan9Info) HasPrefix(p, prefix string) bool { 50 return strings.HasPrefix(p, prefix) 51 } 52 53 func (o plan9Info) splitList(path string) []string { 54 if path == "" { 55 return []string{} 56 } 57 return strings.Split(path, string(plan9ListSeparator)) 58 } 59 60 func (o plan9Info) join(elem []string) string { 61 // If there's a bug here, fix the logic in ./path_unix.go too. 62 for i, e := range elem { 63 if e != "" { 64 return clean(strings.Join(elem[i:], string(plan9Separator)), plan9) 65 } 66 } 67 return "" 68 } 69 70 func (o plan9Info) sameWord(a, b string) bool { 71 return a == b 72 } 73