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
19package path
20
21import "strings"
22
23const plan9Separator = '/'
24const plan9ListSeparator = '\000'
25
26type plan9Info struct{}
27
28var _ osInfo = plan9Info{}
29
30func (o plan9Info) IsPathSeparator(b byte) bool {
31 return b == plan9Separator
32}
33
34// IsAbs reports whether the path is absolute.
35func (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.
41func (o plan9Info) volumeNameLen(path string) int {
42 return 0
43}
44
45func (o plan9Info) splitList(path string) []string {
46 if path == "" {
47 return []string{}
48 }
49 return strings.Split(path, string(plan9ListSeparator))
50}
51
52func (o plan9Info) join(elem []string) string {
53 // If there's a bug here, fix the logic in ./path_unix.go too.
54 for i, e := range elem {
55 if e != "" {
56 return clean(strings.Join(elem[i:], string(plan9Separator)), plan9)
57 }
58 }
59 return ""
60}
61
62func (o plan9Info) sameWord(a, b string) bool {
63 return a == b
64}