Documentation
¶
Overview ¶
Package fs provides various file functions.
Index ¶
- Variables
- func IsExist(path string) bool
- func IsHidden(path string) bool
- type File
- type FileReader
- func (reader *FileReader) Close()
- func (reader *FileReader) CopyNTo(path string, n int64) bool
- func (reader *FileReader) CopyTo(path string) bool
- func (reader *FileReader) IsOpen() bool
- func (reader *FileReader) Open(path string) bool
- func (reader *FileReader) Read(keepN int) bool
- func (reader *FileReader) Seek(offset int64) bool
- type FileWriter
- func (writer *FileWriter) Close()
- func (writer *FileWriter) CopyFrom(path string) bool
- func (writer *FileWriter) CopyNFrom(path string, n int64) bool
- func (writer *FileWriter) IsOpen() bool
- func (writer *FileWriter) Open(path string) bool
- func (writer *FileWriter) Seek(offset int64) bool
- func (writer *FileWriter) StdoutWrite(bytes []byte) bool
- func (writer *FileWriter) Write(bytes []byte) bool
Constants ¶
This section is empty.
Variables ¶
var (
ErrBufferOutOfMemory = errors.New("buffer out of memory")
)
Functions ¶
Types ¶
type File ¶
func (*File) IsEmpty ¶
IsEmpty returns whether directory or file is empty. A directory is empty if it has only empty directories and empty files. A file is empty if it is a regular file with size 0.
type FileReader ¶
type FileReader struct {
File
Offset int64
Buffer []byte
NRead int
// contains filtered or unexported fields
}
FileReader reads files into buffer.
func (*FileReader) Close ¶
func (reader *FileReader) Close()
Close closes the file. Err is set only if it was previously nil.
func (*FileReader) CopyNTo ¶
func (reader *FileReader) CopyNTo(path string, n int64) bool
CopyTo copies n bytes from FileReader to path. Error is stored in Err.
func (*FileReader) CopyTo ¶
func (reader *FileReader) CopyTo(path string) bool
CopyTo copies all bytes from FileReader to path. Error is stored in Err.
func (*FileReader) IsOpen ¶
func (reader *FileReader) IsOpen() bool
IsOpen returns whether file is open.
func (*FileReader) Open ¶
func (reader *FileReader) Open(path string) bool
Open opens file for reading and initializes Info. Returns true if file was successfully opened. Error is stored in Err.
func (*FileReader) Read ¶
func (reader *FileReader) Read(keepN int) bool
Read copies the last keepN bytes to the beginning of the buffer and then reads from the file into the buffer. Buffer is starting at offset keepN. Returns true if any bytes have been read and no error encountered. Error is stored in Err unless it is io.EOF.
func (*FileReader) Seek ¶
func (reader *FileReader) Seek(offset int64) bool
Seek sets the offset for the next Read on file. Returns true when seek was successful. Error is stored in Err.
type FileWriter ¶
FileWriter writes files.
func (*FileWriter) Close ¶
func (writer *FileWriter) Close()
Close closes the file. Err is set only if it was previously nil.
func (*FileWriter) CopyFrom ¶
func (writer *FileWriter) CopyFrom(path string) bool
CopyFrom copies all bytes from path to FileWriter. Error is stored in Err.
func (*FileWriter) CopyNFrom ¶
func (writer *FileWriter) CopyNFrom(path string, n int64) bool
CopyFrom copies n bytes from path to FileWriter. Error is stored in Err.
func (*FileWriter) IsOpen ¶
func (writer *FileWriter) IsOpen() bool
IsOpen returns whether file is open.
func (*FileWriter) Open ¶
func (writer *FileWriter) Open(path string) bool
Open opens file with FileMode 0666 for writing and initializes Info. Returns true when file was successfully opened. Error is stored in Err.
func (*FileWriter) Seek ¶
func (writer *FileWriter) Seek(offset int64) bool
Seek sets the offset for the next Write on file. Returns true when seek was successful. Error is stored in Err.
func (*FileWriter) StdoutWrite ¶
func (writer *FileWriter) StdoutWrite(bytes []byte) bool
Write writes bytes to file. Error is stored in Err.
func (*FileWriter) Write ¶
func (writer *FileWriter) Write(bytes []byte) bool
Write writes bytes to file. Error is stored in Err.