return mode
}
+func (fi headerFileInfo) String() string {
+ return fs.FormatFileInfo(fi)
+}
+
// sysStat, if non-nil, populates h from system-dependent fields of fi.
var sysStat func(fi fs.FileInfo, h *Header) error
func (f *fileListEntry) Info() (fs.FileInfo, error) { return f, nil }
+func (f *fileListEntry) String() string {
+ return fs.FormatDirEntry(f)
+}
+
// toValidName coerces name to be a valid name for fs.FS.Open.
func toValidName(name string) string {
name = strings.ReplaceAll(name, `\`, `/`)
func (fi headerFileInfo) Info() (fs.FileInfo, error) { return fi, nil }
+func (fi headerFileInfo) String() string {
+ return fs.FormatFileInfo(fi)
+}
+
// FileInfoHeader creates a partially-populated FileHeader from an
// fs.FileInfo.
// Because fs.FileInfo's Name method returns only the base name of
func (i fileInfo) Size() int64 { return i.f.Size }
func (i fileInfo) Sys() any { return nil }
+func (i fileInfo) String() string {
+ return fs.FormatFileInfo(i)
+}
+
// NewArchive returns a new Archive containing all the files in the directory dir.
// The archive can be amended afterward using methods like Add and Filter.
func NewArchive(dir string) (*Archive, error) {
func (f fakeFile) IsDir() bool { return f.real.IsDir() }
func (f fakeFile) Sys() any { return f.real.Sys() }
+func (f fakeFile) String() string {
+ return fs.FormatFileInfo(f)
+}
+
// missingFile provides an fs.FileInfo for an overlaid file where the
// destination file in the overlay doesn't exist. It returns zero values
// for the fileInfo methods other than Name, set to the file's name, and Mode
func (f missingFile) IsDir() bool { return false }
func (f missingFile) Sys() any { return nil }
+func (f missingFile) String() string {
+ return fs.FormatFileInfo(f)
+}
+
// fakeDir provides an fs.FileInfo implementation for directories that are
// implicitly created by overlaid files. Each directory in the
// path of an overlaid file is considered to exist in the overlay filesystem.
func (f fakeDir) IsDir() bool { return true }
func (f fakeDir) Sys() any { return nil }
+func (f fakeDir) String() string {
+ return fs.FormatFileInfo(f)
+}
+
// Glob is like filepath.Glob but uses the overlay file system.
func Glob(pattern string) (matches []string, err error) {
Trace("Glob", pattern)
func (fi dataFileInfo) IsDir() bool { return false }
func (fi dataFileInfo) Sys() any { return nil }
+func (fi dataFileInfo) String() string {
+ return fs.FormatFileInfo(fi)
+}
+
// hasPathPrefix reports whether the path s begins with the
// elements in prefix.
func hasPathPrefix(s, prefix string) bool {
func (d *statDirEntry) IsDir() bool { return d.info.IsDir() }
func (d *statDirEntry) Type() fs.FileMode { return d.info.Mode().Type() }
func (d *statDirEntry) Info() (fs.FileInfo, error) { return d.info, nil }
+
+func (d *statDirEntry) String() string {
+ return fs.FormatDirEntry(d)
+}
return nil
}
+func (f *FakeFile) String() string {
+ return fs.FormatFileInfo(f)
+}
+
// Special helpers.
func (f *FakeFile) Entry() *archive.Entry {
return 0444
}
+func (f *file) String() string {
+ return fs.FormatFileInfo(f)
+}
+
// dotFile is a file for the root directory,
// which is omitted from the files list in a FS.
var dotFile = &file{name: "./"}
return di.fileInfo.Name()
}
+func (di dirInfo) String() string {
+ return FormatDirEntry(di)
+}
+
// FileInfoToDirEntry returns a DirEntry that returns information from info.
// If info is nil, FileInfoToDirEntry returns nil.
func FileInfoToDirEntry(info FileInfo) DirEntry {
func (d *statDirEntry) IsDir() bool { return d.info.IsDir() }
func (d *statDirEntry) Type() FileMode { return d.info.Mode().Type() }
func (d *statDirEntry) Info() (FileInfo, error) { return d.info, nil }
+
+func (d *statDirEntry) String() string {
+ return FormatDirEntry(d)
+}
return 0644
}
+func (f *fakeFileInfo) String() string {
+ return fs.FormatFileInfo(f)
+}
+
type fakeFile struct {
io.ReadSeeker
fi *fakeFileInfo
import (
"io"
+ "io/fs"
"syscall"
)
func (de dirEntry) IsDir() bool { return de.fs.IsDir() }
func (de dirEntry) Type() FileMode { return de.fs.Mode().Type() }
func (de dirEntry) Info() (FileInfo, error) { return de.fs, nil }
+
+func (de dirEntry) String() string {
+ return fs.FormatDirEntry(de)
+}
import (
"internal/syscall/windows"
"io"
+ "io/fs"
"runtime"
"sync"
"syscall"
func (de dirEntry) IsDir() bool { return de.fs.IsDir() }
func (de dirEntry) Type() FileMode { return de.fs.Mode().Type() }
func (de dirEntry) Info() (FileInfo, error) { return de.fs, nil }
+
+func (de dirEntry) String() string {
+ return fs.FormatDirEntry(de)
+}
import (
"internal/poll"
"internal/syscall/unix"
+ "io/fs"
"runtime"
"syscall"
)
return lstat(d.parent + "/" + d.name)
}
+func (d *unixDirent) String() string {
+ return fs.FormatDirEntry(d)
+}
+
func newUnixDirent(parent, name string, typ FileMode) (DirEntry, error) {
ude := &unixDirent{
parent: parent,
func (d *statDirEntry) Type() fs.FileMode { return d.info.Mode().Type() }
func (d *statDirEntry) Info() (fs.FileInfo, error) { return d.info, nil }
+func (d *statDirEntry) String() string {
+ return fs.FormatDirEntry(d)
+}
+
// Walk walks the file tree rooted at root, calling fn for each file or
// directory in the tree, including root.
//
func (d *statDirEntry) Type() fs.FileMode { return d.info.Mode().Type() }
func (d *statDirEntry) Info() (fs.FileInfo, error) { return d.info, nil }
+func (d *statDirEntry) String() string {
+ return fs.FormatDirEntry(d)
+}
+
func TestWalkDir(t *testing.T) {
testWalk(t, filepath.WalkDir, 2)
}
func (i *mapFileInfo) Sys() any { return i.f.Sys }
func (i *mapFileInfo) Info() (fs.FileInfo, error) { return i, nil }
+func (i *mapFileInfo) String() string {
+ return fs.FormatFileInfo(i)
+}
+
// An openMapFile is a regular (non-directory) fs.File open for reading.
type openMapFile struct {
path string