Documentation
¶
Index ¶
- Constants
- func NewFs(w *tar.Writer) afero.Fs
- func NewReader(r io.Reader) *tar.Reader
- func NewWriter(w io.Writer) *tar.Writer
- type File
- func (f *File) Close() error
- func (f *File) Name() string
- func (f *File) Read(p []byte) (n int, err error)
- func (f *File) ReadAt(p []byte, off int64) (n int, err error)
- func (f *File) Readdir(count int) ([]os.FileInfo, error)
- func (f *File) Readdirnames(n int) ([]string, error)
- func (f *File) Seek(offset int64, whence int) (int64, error)
- func (f *File) Stat() (os.FileInfo, error)
- func (f *File) Sync() error
- func (f *File) Truncate(size int64) error
- func (f *File) Write(p []byte) (n int, err error)
- func (f *File) WriteAt(p []byte, off int64) (n int, err error)
- func (f *File) WriteString(s string) (ret int, err error)
- type FileInfo
- type Fs
- func (f *Fs) Chmod(name string, mode os.FileMode) error
- func (f *Fs) Chown(name string, uid int, gid int) error
- func (f *Fs) Chtimes(name string, atime time.Time, mtime time.Time) error
- func (f *Fs) Create(name string) (afero.File, error)
- func (f *Fs) Mkdir(name string, perm os.FileMode) error
- func (f *Fs) MkdirAll(path string, perm os.FileMode) error
- func (f *Fs) Name() string
- func (f *Fs) Open(name string) (afero.File, error)
- func (f *Fs) OpenFile(name string, flag int, perm os.FileMode) (afero.File, error)
- func (f *Fs) Remove(name string) error
- func (f *Fs) RemoveAll(path string) error
- func (f *Fs) Rename(oldname string, newname string) error
- func (f *Fs) Stat(name string) (os.FileInfo, error)
Constants ¶
const ( TypeReg = tar.TypeReg TypeLink = tar.TypeLink TypeSymlink = tar.TypeSymlink TypeChar = tar.TypeChar TypeBlock = tar.TypeBlock TypeDir = tar.TypeDir TypeFifo = tar.TypeFifo TypeCont = tar.TypeCont TypeXHeader = tar.TypeXHeader TypeXGlobalHeader = tar.TypeXGlobalHeader TypeGNUSparse = tar.TypeGNUSparse TypeGNULongName = tar.TypeGNULongName TypeGNULongLink = tar.TypeGNULongLink )
Variables ¶
This section is empty.
Functions ¶
func NewFs ¶
NewFs returns an afero.Fs implementation that writes its contents to the provided tar.Writer. The returned filesystem is write-only and exposes a subset of operations that add files and directories to the underlying tar stream.
The caller retains ownership of the tar.Writer: NewFs does not close or flush the writer, and it does not perform any synchronization. The caller is responsible for calling Close on the tar.Writer when all filesystem operations are complete.
Example:
tw := tar.NewWriter(dst)
defer tw.Close()
fs := NewFs(tw)
// Use any afero helpers with fs, for example:
// afero.WriteFile(fs, "path/to/file.txt", []byte("data"), 0o644)
func NewReader ¶
NewReader returns a new tar.Reader that reads a tar archive from r.
This function is a thin wrapper around archive/tar.NewReader and is provided to mirror NewWriter and keep tar I/O behind this package's API. Using this constructor instead of archive/tar.NewReader directly helps keep callers decoupled from the underlying tar implementation.
func NewWriter ¶
NewWriter returns a new tar.Writer that writes a tar archive to w.
This function is a thin wrapper around archive/tar.NewWriter and exists to provide a stable, package-local API for tar output. Callers should prefer using this constructor instead of archive/tar.NewWriter directly so that tar handling can be centralized in this package and extended in the future without requiring changes at call sites.
Types ¶
type File ¶
type File struct {
// contains filtered or unexported fields
}
func (*File) ReadAt ¶
ReadAt implements afero.File.
func (*File) Readdir ¶
Readdir implements afero.File.
func (*File) Readdirnames ¶
Readdirnames implements afero.File.
func (*File) Seek ¶
Seek implements afero.File.
func (*File) WriteAt ¶
WriteAt implements afero.File.
func (*File) WriteString ¶
WriteString implements afero.File.
type Fs ¶
type Fs struct {
// contains filtered or unexported fields
}
Fs implements afero.Fs as a write-only filesystem backed by an archive/tar.Writer.
It is intended for creating tar archive entries via standard filesystem-style calls such as Create and OpenFile. Read, stat-based modification, and mutating operations (for example Chmod, Chown, Chtimes, Remove, RemoveAll, and Rename) are not supported on the underlying tar stream and will return appropriate permission or read-only filesystem errors (for example syscall.EPERM or syscall.EROFS).
Callers should treat Fs as an append-only view of a tar archive and should not expect to be able to read back or modify previously written entries through this interface.