Debian Codegraph @

osfs/os.go

raw symbols SCIP
1 //go:build !js
2
3 // Package osfs provides a billy filesystem for the OS.
4 package osfsscip-go gomod github.com/go-git/go-billy/v6 . `github.com/go-git/go-billy/v6/osfs`/
5
6 import (
7 "errorsscip-go gomod github.com/golang/go/src go1.25.0 errors/"
8 "ioscip-go gomod github.com/golang/go/src go1.25.0 io/"
9 "io/fsscip-go gomod github.com/golang/go/src go1.25.0 `io/fs`/"
10 "osscip-go gomod github.com/golang/go/src go1.25.0 os/"
11 "syncscip-go gomod github.com/golang/go/src go1.25.0 sync/"
12
13 "github.com/go-git/go-billy/v6scip-go gomod github.com/go-git/go-billy/v6 . `github.com/go-git/go-billy/v6`/"
14 )
15
16 const (
17 defaultDirectoryModescip-go gomod github.com/go-git/go-billy/v6 . `github.com/go-git/go-billy/v6/osfs`/defaultDirectoryMode. = 0o777
18 defaultCreateModescip-go gomod github.com/go-git/go-billy/v6 . `github.com/go-git/go-billy/v6/osfs`/defaultCreateMode. = 0o666
19 )
20
21 // Default Filesystem representing the root of the os filesystem.
22 var Defaultscip-go gomod github.com/go-git/go-billy/v6 . `github.com/go-git/go-billy/v6/osfs`/Default. billyscip-go gomod github.com/go-git/go-billy/v6 . `github.com/go-git/go-billy/v6`/.Filesystemscip-go gomod github.com/go-git/go-billy/v6 . `github.com/go-git/go-billy/v6`/Filesystem# = newBoundOSscip-go gomod github.com/go-git/go-billy/v6 . `github.com/go-git/go-billy/v6/osfs`/newBoundOS().(string(osscip-go gomod github.com/golang/go/src go1.25.0 os/.PathSeparatorscip-go gomod github.com/golang/go/src go1.25.0 os/PathSeparator.))
23
24 // New returns a new OS filesystem rooted at baseDir.
25 //
26 // The returned filesystem is always a [BoundOS]: containment is enforced
27 // via [os.Root], opened and closed per operation. For better performance
28 // with caller-managed lifecycle, use [FromRoot] instead.
29 //
30 // [WithMmap] enables an mmap-backed implementation of [BoundOS.Open] on
31 // supported platforms; all other [Option] values are accepted for API
32 // compatibility but have no effect on the returned implementation.
33 func Newscip-go gomod github.com/go-git/go-billy/v6 . `github.com/go-git/go-billy/v6/osfs`/New().(baseDir string, opts ...Optionscip-go gomod github.com/go-git/go-billy/v6 . `github.com/go-git/go-billy/v6/osfs`/Option#) billyscip-go gomod github.com/go-git/go-billy/v6 . `github.com/go-git/go-billy/v6`/.Filesystemscip-go gomod github.com/go-git/go-billy/v6 . `github.com/go-git/go-billy/v6`/Filesystem# {
34 o := &optionsscip-go gomod github.com/go-git/go-billy/v6 . `github.com/go-git/go-billy/v6/osfs`/options#{}
35 for _, opt := range opts {
36 opt(o)
37 }
38
39 fs := newBoundOSscip-go gomod github.com/go-git/go-billy/v6 . `github.com/go-git/go-billy/v6/osfs`/newBoundOS().(baseDir)
40 fs.mmapscip-go gomod github.com/go-git/go-billy/v6 . `github.com/go-git/go-billy/v6/osfs`/BoundOS#mmap. = o.mmapscip-go gomod github.com/go-git/go-billy/v6 . `github.com/go-git/go-billy/v6/osfs`/options#mmap.
41 return fs
42 }
43
44 // WithBoundOS selects the [BoundOS] implementation.
45 //
46 // [BoundOS] is the only OS-backed implementation returned by [New], so this
47 // option is the default and is kept for API compatibility.
48 func WithBoundOSscip-go gomod github.com/go-git/go-billy/v6 . `github.com/go-git/go-billy/v6/osfs`/WithBoundOS().() Optionscip-go gomod github.com/go-git/go-billy/v6 . `github.com/go-git/go-billy/v6/osfs`/Option# {
49 return func(o *optionsscip-go gomod github.com/go-git/go-billy/v6 . `github.com/go-git/go-billy/v6/osfs`/options#) {
50 o.Typescip-go gomod github.com/go-git/go-billy/v6 . `github.com/go-git/go-billy/v6/osfs`/options#Type. = BoundOSFSscip-go gomod github.com/go-git/go-billy/v6 . `github.com/go-git/go-billy/v6/osfs`/BoundOSFS.
51 }
52 }
53
54 type optionsscip-go gomod github.com/go-git/go-billy/v6 . `github.com/go-git/go-billy/v6/osfs`/options# struct {
55 Typescip-go gomod github.com/go-git/go-billy/v6 . `github.com/go-git/go-billy/v6/osfs`/options#Type.
56 mmapscip-go gomod github.com/go-git/go-billy/v6 . `github.com/go-git/go-billy/v6/osfs`/options#mmap. bool
57 }
58
59 // errMmapUnavailable is returned by newMmapFile when the file cannot
60 // be memory-mapped for benign reasons (zero size, size beyond
61 // platform int, mmap rejected by the kernel, platform without mmap
62 // support). Callers in osfs treat this as a fall-through signal and
63 // return the regular *file wrapper instead.
64 var errMmapUnavailablescip-go gomod github.com/go-git/go-billy/v6 . `github.com/go-git/go-billy/v6/osfs`/errMmapUnavailable. = errorsscip-go gomod github.com/golang/go/src go1.25.0 errors/.Newscip-go gomod github.com/golang/go/src go1.25.0 errors/New().("osfs: mmap unavailable for this file")
65
66 // Type identifies an osfs implementation.
67 type Typescip-go gomod github.com/go-git/go-billy/v6 . `github.com/go-git/go-billy/v6/osfs`/Type# int
68
69 const (
70 // BoundOSFS selects the [BoundOS] implementation.
71 BoundOSFSscip-go gomod github.com/go-git/go-billy/v6 . `github.com/go-git/go-billy/v6/osfs`/BoundOSFS. Typescip-go gomod github.com/go-git/go-billy/v6 . `github.com/go-git/go-billy/v6/osfs`/Type# = iota
72 )
73
74 // file is a wrapper for an os.File which adds support for file locking.
75 type filescip-go gomod github.com/go-git/go-billy/v6 . `github.com/go-git/go-billy/v6/osfs`/file# struct {
76 *osscip-go gomod github.com/golang/go/src go1.25.0 os/.Filescip-go gomod github.com/go-git/go-billy/v6 . `github.com/go-git/go-billy/v6/osfs`/file#File.
77 namescip-go gomod github.com/go-git/go-billy/v6 . `github.com/go-git/go-billy/v6/osfs`/file#name. string
78 mscip-go gomod github.com/go-git/go-billy/v6 . `github.com/go-git/go-billy/v6/osfs`/file#m. syncscip-go gomod github.com/golang/go/src go1.25.0 sync/.Mutexscip-go gomod github.com/golang/go/src go1.25.0 sync/Mutex#
79 }
80
81 func (f *filescip-go gomod github.com/go-git/go-billy/v6 . `github.com/go-git/go-billy/v6/osfs`/file#) Namescip-go gomod github.com/go-git/go-billy/v6 . `github.com/go-git/go-billy/v6/osfs`/file#Name().() string {
82 if f.namescip-go gomod github.com/go-git/go-billy/v6 . `github.com/go-git/go-billy/v6/osfs`/file#name. != "" {
83 return f.namescip-go gomod github.com/go-git/go-billy/v6 . `github.com/go-git/go-billy/v6/osfs`/file#name.
84 }
85 return f.Filescip-go gomod github.com/go-git/go-billy/v6 . `github.com/go-git/go-billy/v6/osfs`/file#File..Namescip-go gomod github.com/golang/go/src go1.25.0 os/File#Name().()
86 }
87
88 func (f *filescip-go gomod github.com/go-git/go-billy/v6 . `github.com/go-git/go-billy/v6/osfs`/file#) WriteToscip-go gomod github.com/go-git/go-billy/v6 . `github.com/go-git/go-billy/v6/osfs`/file#WriteTo().(w ioscip-go gomod github.com/golang/go/src go1.25.0 io/.Writerscip-go gomod github.com/golang/go/src go1.25.0 io/Writer#) error {
89 _, err := f.Filescip-go gomod github.com/go-git/go-billy/v6 . `github.com/go-git/go-billy/v6/osfs`/file#File..WriteToscip-go gomod github.com/golang/go/src go1.25.0 os/File#WriteTo().(w)
90 return err
91 }
92
93 type fileInfoscip-go gomod github.com/go-git/go-billy/v6 . `github.com/go-git/go-billy/v6/osfs`/fileInfo# struct {
94 fsscip-go gomod github.com/golang/go/src go1.25.0 `io/fs`/.FileInfoscip-go gomod github.com/go-git/go-billy/v6 . `github.com/go-git/go-billy/v6/osfs`/fileInfo#FileInfo.
95 namescip-go gomod github.com/go-git/go-billy/v6 . `github.com/go-git/go-billy/v6/osfs`/fileInfo#name. string
96 }
97
98 func (fi fileInfoscip-go gomod github.com/go-git/go-billy/v6 . `github.com/go-git/go-billy/v6/osfs`/fileInfo#) Namescip-go gomod github.com/go-git/go-billy/v6 . `github.com/go-git/go-billy/v6/osfs`/fileInfo#Name().() string {
99 return fi.namescip-go gomod github.com/go-git/go-billy/v6 . `github.com/go-git/go-billy/v6/osfs`/fileInfo#name.
100 }