Documentation ¶
Index ¶
- Variables
- type TargetFile
- func (tf *TargetFile) Cleanup() error
- func (tf *TargetFile) HasError() bool
- func (tf *TargetFile) HasFilename() bool
- func (tf *TargetFile) Invalidate()
- func (tf *TargetFile) IsInvalid() bool
- func (tf *TargetFile) Name() string
- func (tf *TargetFile) WithError(err error) *TargetFile
- func (tf *TargetFile) Write(data []byte, cleanup bool) error
Constants ¶
This section is empty.
Variables ¶
var ErrInvalidated = errors.New("target file has been invalidated")
Functions ¶
This section is empty.
Types ¶
type TargetFile ¶
func GetTargetFile ¶
func GetTargetFile(fs vfs.FS, filename string, mode fs.FileMode, removeExisting bool) (tf *TargetFile)
GetTargetFile returns a new TargetFile instance for the given filename. If the filename is "-", the file will be os.Stdout. The file will be opened with the given mode; result.Cleanup() should be called to close the file. If removeExisting is true, the existing file will be removed before creating a new one. If the target directory does not exist, it will be created recursively with mode 0755.
func NewTargetFile ¶
func NewTargetFile(fs vfs.FS, file *os.File, filename string, shouldClose bool) *TargetFile
NewTargetFile returns a new TargetFile instance for the given file. If the filename is "-", then:
- result.File will be os.Stdout
- result.shouldClose will be false.
- result.Filename will be nil.
If the filename is empty, then:
- result.File will be the given file
- result.shouldClose will be false.
- result.Filename will be nil.
func (*TargetFile) Cleanup ¶
func (tf *TargetFile) Cleanup() error
Cleanup closes the file if it should be closed and sets the file to nil. The TargetFile instance should be considered invalid after calling this method.
func (*TargetFile) HasError ¶
func (tf *TargetFile) HasError() bool
func (*TargetFile) HasFilename ¶
func (tf *TargetFile) HasFilename() bool
func (*TargetFile) Invalidate ¶
func (tf *TargetFile) Invalidate()
func (*TargetFile) IsInvalid ¶
func (tf *TargetFile) IsInvalid() bool
func (*TargetFile) Name ¶
func (tf *TargetFile) Name() string
func (*TargetFile) WithError ¶
func (tf *TargetFile) WithError(err error) *TargetFile