mirror of
https://github.com/restic/restic.git
synced 2025-01-21 06:48:35 +00:00
2a5bbf170d
The implementations are 90% copy&paste from the go standard library as the existing code does not offer any way to read the symlink target based on a filehandle. Fall back to a standard readlink on platforms other than Linux and Windows as those either don't even provide the necessary syscall or in case of macOS are not yet available in Go.
35 lines
619 B
Go
35 lines
619 B
Go
//go:build darwin || linux || windows
|
|
|
|
package fs
|
|
|
|
import "os"
|
|
|
|
type fdMetadataHandle struct {
|
|
name string
|
|
f *os.File
|
|
}
|
|
|
|
var _ metadataHandle = &fdMetadataHandle{}
|
|
|
|
func newFdMetadataHandle(name string, f *os.File) *fdMetadataHandle {
|
|
return &fdMetadataHandle{
|
|
name: name,
|
|
f: f,
|
|
}
|
|
}
|
|
|
|
func (p *fdMetadataHandle) Name() string {
|
|
return p.name
|
|
}
|
|
|
|
func (p *fdMetadataHandle) Stat() (*ExtendedFileInfo, error) {
|
|
fi, err := p.f.Stat()
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
return extendedStat(fi), nil
|
|
}
|
|
|
|
func (p *fdMetadataHandle) Readlink() (string, error) {
|
|
return Freadlink(p.f.Fd(), fixpath(p.name))
|
|
}
|