Documentation ¶
Index ¶
- type ByteSource
- type File
- func (f *File) BaseFileName() string
- func (f *File) Bytes() []byte
- func (f *File) Dir() string
- func (f *File) Ext() string
- func (f *File) Extension() string
- func (f *File) Lang() string
- func (f *File) LogicalName() string
- func (f *File) Path() string
- func (f *File) Section() string
- func (f *File) SetDir(dir string)
- func (f *File) String() string
- func (f *File) TranslationBaseName() string
- func (f *File) UniqueID() string
- type Filesystem
- type InMemorySource
- type Input
- type LazyFileReader
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ByteSource ¶
func (*ByteSource) String ¶
func (b *ByteSource) String() string
type File ¶
File represents a source content file. All paths are relative from the source directory base
func NewFileFromAbs ¶
NewFileFromAbs creates a new File pointer with the given full file path path and content.
func NewFileWithContents ¶
NewFileWithContents creates a new File pointer with the given relative path and content. The language defaults to "en".
func (*File) BaseFileName ¶
BaseFileName is a filename without extension.
func (*File) Dir ¶
Dir gets the name of the directory that contains this file. The directory is relative to the content root.
func (*File) LogicalName ¶
LogicalName is filename and extension of the file.
func (*File) Path ¶
Path gets the relative path including file name and extension. The directory is relative to the content root.
func (*File) SetDir ¶
SetDir sets the relative directory where this file lives. TODO(bep) Get rid of this.
func (*File) TranslationBaseName ¶
TranslationBaseName is a filename with no extension, not even the optional language extension part.
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 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(fs afero.Fs, 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.