source

package
v0.15.0 Latest Latest
Warning

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

Go to latest
Published: Nov 25, 2015 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ByteSource

type ByteSource struct {
	Name    string
	Content []byte
}

func (*ByteSource) String

func (b *ByteSource) String() string

type File

type File struct {
	Contents io.Reader
	// contains filtered or unexported fields
}

func NewFile

func NewFile(relpath string) *File

func NewFileFromAbs

func NewFileFromAbs(base, fullpath string, content io.Reader) (f *File, err error)

func NewFileWithContents

func NewFileWithContents(relpath string, content io.Reader) *File

func (*File) BaseFileName

func (f *File) BaseFileName() string

Filename without extension

func (*File) Bytes

func (f *File) Bytes() []byte

func (*File) Dir

func (f *File) Dir() string

func (*File) Ext

func (f *File) Ext() string

func (*File) Extension

func (f *File) Extension() string

func (*File) LogicalName

func (f *File) LogicalName() string

func (*File) Path

func (f *File) Path() string

func (*File) Section

func (f *File) Section() string

func (*File) SetDir

func (f *File) SetDir(dir string)

func (*File) String

func (f *File) String() string

func (*File) UniqueID

func (f *File) UniqueID() string

type Filesystem

type Filesystem struct {
	Base       string
	AvoidPaths []string
	// contains filtered or unexported fields
}

func (*Filesystem) Files

func (f *Filesystem) Files() []*File

func (*Filesystem) FilesByExts

func (f *Filesystem) FilesByExts(exts ...string) []*File

type InMemorySource

type InMemorySource struct {
	ByteSource []ByteSource
}

func (*InMemorySource) Files

func (i *InMemorySource) Files() (files []*File)

type Input

type Input interface {
	Files() []*File
}

type LazyFileReader

type LazyFileReader struct {
	// contains filtered or unexported fields
}

LazyFileReader is an io.Reader implementation to postpone reading the file contents until it is really needed. It keeps filename and file contents once it is read.

func NewLazyFileReader

func NewLazyFileReader(filename string) (*LazyFileReader, error)

NewLazyFileReader creates and initializes a new LazyFileReader of filename. It checks whether the file can be opened. If it fails, it returns nil and an error.

func (*LazyFileReader) Filename

func (l *LazyFileReader) Filename() string

Filename returns a file name which LazyFileReader keeps

func (*LazyFileReader) Read

func (l *LazyFileReader) Read(p []byte) (n int, err error)

Read reads up to len(p) bytes from the LazyFileReader's file and copies them into p. It returns the number of bytes read and any error encountered. If the file is once read, it returns its contents from cache, doesn't re-read the file.

func (*LazyFileReader) Seek

func (l *LazyFileReader) Seek(offset int64, whence int) (pos int64, err error)

Seek implements the io.Seeker interface. Once reader contents is consumed by Read, WriteTo etc, to read it again, it must be rewinded by this function

func (*LazyFileReader) WriteTo

func (l *LazyFileReader) WriteTo(w io.Writer) (n int64, err error)

WriteTo writes data to w until all the LazyFileReader's file contents is drained or an error occurs. If the file is once read, it just writes its read cache to w, doesn't re-read the file but this method itself doesn't try to keep the contents in cache.

Jump to

Keyboard shortcuts

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