file

package
v0.0.0-...-d0f7b5f Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 19, 2018 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

Package file implements file devices.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Reader

type Reader struct {
	*bufio.Reader
	// contains filtered or unexported fields
}

Reader is a file used only for reading that satisfies this packages Reader interface.

func NewReader

func NewReader(name string) (*Reader, error)

NewReader attempts to open a file for reading.

func (*Reader) Close

func (f *Reader) Close() error

Close f.

func (*Reader) File

func (f *Reader) File() (fh *os.File, reset func(), err error)

File returns the underlying os.File, and a reset function that must be called to reset the file device after any and all low-level access is completed.

It is the callers responsibility to make sure the file is at the logical "end" where reading may continue and then calling reset.

func (*Reader) Name

func (f *Reader) Name() string

Name returns the file being read.

func (*Reader) Unwrap

func (f *Reader) Unwrap() *bufio.Reader

Unwrap returns the underlying bufio.Reader of this file.

type Writer

type Writer struct {
	*bufio.Writer
	// contains filtered or unexported fields
}

Writer represents a file used for writing.

It is written to a tmp file and renamed on Close.

func NewWriter

func NewWriter(name string) (*Writer, error)

NewWriter creates a temporary file to write to and replaces name on Close.

func (*Writer) Cancel

func (f *Writer) Cancel()

func (*Writer) Close

func (f *Writer) Close() error

Close flushes, syncs, and renames the tmp file to Name().

func (*Writer) File

func (f *Writer) File() (fh *os.File, reset func(), err error)

File flushes the buffer, returns the underlying os.File, and a reset function that must be called to reset the file device after any and all low-level access is completed.

It is the callers responsibility to make sure the file is at the logical "end" where writing may continue and then calling reset.

func (*Writer) Name

func (f *Writer) Name() string

Name reports the name the file will have when closed.

func (*Writer) Unwrap

func (f *Writer) Unwrap() *bufio.Writer

Unwrap returns the underlying bufio.Writer.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL