this repo has no description
at master 66 lines 1.7 kB view raw
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 23type unixInfo struct{} 24 25var _ osInfo = unixInfo{} 26 27const ( 28 unixListSeparator = ':' 29 unixSeparator = '/' 30) 31 32func (o unixInfo) IsPathSeparator(b byte) bool { 33 return b == unixSeparator 34} 35 36// IsAbs reports whether the path is absolute. 37func (o unixInfo) IsAbs(path string) bool { 38 return strings.HasPrefix(path, "/") 39} 40 41// volumeNameLen returns length of the leading volume name on Windows. 42// It returns 0 elsewhere. 43func (o unixInfo) volumeNameLen(path string) int { 44 return 0 45} 46 47func (o unixInfo) splitList(path string) []string { 48 if path == "" { 49 return []string{} 50 } 51 return strings.Split(path, string(unixListSeparator)) 52} 53 54func (o unixInfo) join(elem []string) string { 55 // If there's a bug here, fix the logic in ./path_plan9.go too. 56 for i, e := range elem { 57 if e != "" { 58 return clean(strings.Join(elem[i:], string(unixSeparator)), unix) 59 } 60 } 61 return "" 62} 63 64func (o unixInfo) sameWord(a, b string) bool { 65 return a == b 66}