Source File
util.go
Belonging Package
github.com/go-git/go-billy/v5/util
package util
import (
)
func ( billy.Basic, string) error {
, = getUnderlyingAndPath(, )
if , := .(removerAll); {
return .RemoveAll()
}
return removeAll(, )
}
type removerAll interface {
RemoveAll(string) error
}
:= .Remove()
if == nil || os.IsNotExist() {
return nil
}
, := .Stat()
if != nil {
if os.IsNotExist() {
return nil
}
return
}
return
}
, := .(billy.Dir)
if ! {
return billy.ErrNotSupported
}
return nil
}
return
}
var rand uint32
var randmu sync.Mutex
func () uint32 {
return uint32(time.Now().UnixNano() + int64(os.Getpid()))
}
func () string {
randmu.Lock()
:= rand
if == 0 {
= reseed()
}
= *1664525 + 1013904223 // constants from Numerical Recipes
rand =
randmu.Unlock()
return strconv.Itoa(int(1e9 + %1e9))[1:]
}
if == "" {
= os.TempDir()
}
:= 0
for := 0; < 10000; ++ {
:= filepath.Join(, +nextSuffix())
= .MkdirAll(, 0700)
if os.IsExist() {
if ++; > 10 {
randmu.Lock()
rand = reseed()
randmu.Unlock()
}
continue
}
if os.IsNotExist() {
if , := os.Stat(); os.IsNotExist() {
return "",
}
}
if == nil {
=
}
break
}
return
}
type underlying interface {
Underlying() billy.Basic
}
func ( billy.Basic, string) (billy.Basic, string) {
, := .(underlying)
if ! {
return ,
}
if , := .(billy.Chroot); {
= .Join(.Root(), )
}
return .Underlying(),
![]() |
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. |