Source File
path.go
Belonging Package
path/filepath
package filepath
import (
)
type lazybuf struct {
path string
buf []byte
w int
volAndPath string
volLen int
}
func ( *lazybuf) ( int) byte {
if .buf != nil {
return .buf[]
}
return .path[]
}
func ( *lazybuf) ( byte) {
if .buf == nil {
if .w < len(.path) && .path[.w] == {
.w++
return
}
.buf = make([]byte, len(.path))
copy(.buf, .path[:.w])
}
.buf[.w] =
.w++
}
func ( *lazybuf) () string {
if .buf == nil {
return .volAndPath[:.volLen+.w]
}
return .volAndPath[:.volLen] + string(.buf[:.w])
}
const (
Separator = os.PathSeparator
ListSeparator = os.PathListSeparator
)
func ( string) string {
:=
:= volumeNameLen()
= [:]
if == "" {
return FromSlash()
}
return + "."
}
:= os.IsPathSeparator([0])
++
++
+= 2
switch {
for ; < && !os.IsPathSeparator([]); ++ {
.append([])
}
}
}
func ( string) (, string) {
:= VolumeName()
:= len() - 1
for >= len() && !os.IsPathSeparator([]) {
--
}
return [:+1], [+1:]
}
func ( string) string {
for := len() - 1; >= 0 && !os.IsPathSeparator([]); -- {
if [] == '.' {
return [:]
}
}
return ""
}
func ( string) (string, error) {
return evalSymlinks()
}
func ( string, fs.WalkDirFunc) error {
, := os.Lstat()
if != nil {
= (, nil, )
} else {
= walkDir(, &statDirEntry{}, )
}
if == SkipDir {
return nil
}
return
}
type statDirEntry struct {
info fs.FileInfo
}
func ( *statDirEntry) () string { return .info.Name() }
func ( *statDirEntry) () bool { return .info.IsDir() }
func ( *statDirEntry) () fs.FileMode { return .info.Mode().Type() }
func ( *statDirEntry) () (fs.FileInfo, error) { return .info, nil }
for len() > 0 && os.IsPathSeparator([len()-1]) {
= [0 : len()-1]
:= len() - 1
for >= 0 && !os.IsPathSeparator([]) {
--
}
if >= 0 {
= [+1:]
func ( string) string {
:= VolumeName()
:= len() - 1
for >= len() && !os.IsPathSeparator([]) {
--
}
:= Clean([len() : +1])
return
}
return +
}
func ( string) string {
return [:volumeNameLen()]
![]() |
The pages are generated with Golds v0.3.2-preview. (GOOS=darwin GOARCH=amd64) Golds is a Go 101 project developed by Tapir Liu. PR and bug reports are welcome and can be submitted to the issue list. Please follow @Go100and1 (reachable from the left QR code) to get the latest news of Golds. |