2018-05-07 Edward Smith-Rowland <3dw4rd@verizon.net>
[official-gcc.git] / libgo / go / os / path_unix.go
blobbc0f23911972868e5551d30a1da7e5b35ee6c1c3
1 // Copyright 2011 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.
5 // +build aix darwin dragonfly freebsd linux nacl netbsd openbsd solaris
7 package os
9 const (
10 PathSeparator = '/' // OS-specific path separator
11 PathListSeparator = ':' // OS-specific path list separator
14 // IsPathSeparator reports whether c is a directory separator character.
15 func IsPathSeparator(c uint8) bool {
16 return PathSeparator == c
19 // basename removes trailing slashes and the leading directory name from path name
20 func basename(name string) string {
21 i := len(name) - 1
22 // Remove trailing slashes
23 for ; i > 0 && name[i] == '/'; i-- {
24 name = name[:i]
26 // Remove leading directory name
27 for i--; i >= 0; i-- {
28 if name[i] == '/' {
29 name = name[i+1:]
30 break
34 return name