Add support for static files
This commit is contained in:
parent
ce668ab5ad
commit
23d9ff7e00
16
goldsmith.go
16
goldsmith.go
@ -30,6 +30,10 @@ import (
|
|||||||
"path/filepath"
|
"path/filepath"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
const (
|
||||||
|
FILE_FLAG_STATIC = 1 << iota
|
||||||
|
)
|
||||||
|
|
||||||
type stage struct {
|
type stage struct {
|
||||||
input, output chan *File
|
input, output chan *File
|
||||||
}
|
}
|
||||||
@ -149,7 +153,7 @@ func (gs *goldsmith) chain(s stage, c Chainer) {
|
|||||||
go c.Chain(gs, allowed, s.output)
|
go c.Chain(gs, allowed, s.output)
|
||||||
|
|
||||||
for file := range s.input {
|
for file := range s.input {
|
||||||
if f.Filter(file.Path) {
|
if file.flags&FILE_FLAG_STATIC != 0 || f.Filter(file.Path) {
|
||||||
s.output <- file
|
s.output <- file
|
||||||
} else {
|
} else {
|
||||||
allowed <- file
|
allowed <- file
|
||||||
@ -171,6 +175,16 @@ func (gs *goldsmith) NewFile(path string) (*File, error) {
|
|||||||
return file, nil
|
return file, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (gs *goldsmith) NewFileStatic(path string) (*File, error) {
|
||||||
|
file, err := gs.NewFile(path)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
file.flags |= FILE_FLAG_STATIC
|
||||||
|
return file, nil
|
||||||
|
}
|
||||||
|
|
||||||
func (gs *goldsmith) RefFile(path string) error {
|
func (gs *goldsmith) RefFile(path string) error {
|
||||||
if filepath.IsAbs(path) {
|
if filepath.IsAbs(path) {
|
||||||
return fmt.Errorf("absolute paths are not supported: %s", path)
|
return fmt.Errorf("absolute paths are not supported: %s", path)
|
||||||
|
4
types.go
4
types.go
@ -42,10 +42,14 @@ type File struct {
|
|||||||
Meta map[string]interface{}
|
Meta map[string]interface{}
|
||||||
Buff *bytes.Buffer
|
Buff *bytes.Buffer
|
||||||
Err error
|
Err error
|
||||||
|
|
||||||
|
flags uint32
|
||||||
}
|
}
|
||||||
|
|
||||||
type Context interface {
|
type Context interface {
|
||||||
|
NewFileStatic(path string) (*File, error)
|
||||||
NewFile(path string) (*File, error)
|
NewFile(path string) (*File, error)
|
||||||
|
|
||||||
RefFile(path string) error
|
RefFile(path string) error
|
||||||
|
|
||||||
SrcDir() string
|
SrcDir() string
|
||||||
|
Loading…
Reference in New Issue
Block a user