Documentation
¶
Overview ¶
Package tempfile implements a virtual temp files that can be written to (in series) and then read back (series/parallel) and then removed from the filesystem when done if multiple "tempfiles" are needed on the application layer, they are mapped to sections of the same real file on the filesystem
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type FileWriter ¶
type FileWriter struct {
// contains filtered or unexported fields
}
FileWriter allows for creating virtual temp files for reading/writing
func New ¶
func New(dir string) (*FileWriter, error)
New creates a new tempfile in dir, if dir is empty the OS default is used
func (*FileWriter) Close ¶
func (w *FileWriter) Close() error
Close stops the tempfile from accepting new data, closes the file, and removes the temp file from disk works like an abort, unrecoverable
func (*FileWriter) Name ¶
func (w *FileWriter) Name() string
Name returns the full path of the underlying file on the OS
func (*FileWriter) Next ¶
func (w *FileWriter) Next() (int64, error)
Next stops writing the the current section/file and prepares the tempWriter for the next one
func (*FileWriter) Save ¶
func (w *FileWriter) Save() (TempReader, error)
Save stops writing new data/sections to the temp file and returns a reader for reading the data/sections back
func (*FileWriter) Size ¶
func (w *FileWriter) Size() int
Size returns the number of virtual files created
func (*FileWriter) Write ¶
func (w *FileWriter) Write(p []byte) (int, error)
Write writes a byte to the current file section
func (*FileWriter) WriteString ¶
func (w *FileWriter) WriteString(s string) (int, error)
WriteString writes s to the current file section
type MockFileWriter ¶
type MockFileWriter struct {
// contains filtered or unexported fields
}
MockFileWriter allows writing to a temp file(s) that are backed by memory
func (*MockFileWriter) Close ¶
func (w *MockFileWriter) Close() error
Close stops the tempfile from accepting new data, works like an abort, unrecoverable
func (*MockFileWriter) Next ¶
func (w *MockFileWriter) Next() (int64, error)
Next stops writing the the current section/file and prepares the tempWriter for the next one
func (*MockFileWriter) Save ¶
func (w *MockFileWriter) Save() (TempReader, error)
Save stops allowing new writes and returns a TempReader for reading the data back
func (*MockFileWriter) Size ¶
func (w *MockFileWriter) Size() int
Size return the number of "files" saved
func (*MockFileWriter) Write ¶
func (w *MockFileWriter) Write(p []byte) (int, error)
Write writes the byte to the temp file
func (*MockFileWriter) WriteString ¶
func (w *MockFileWriter) WriteString(s string) (int, error)
WriteString writes the string to the temp file
type TempReader ¶
TempReader defines the methods to allow reading the sections from tempfiles