This commit is contained in:
Alex Yatskov 2024-02-21 18:59:53 -08:00
parent 8aee72f2c8
commit 01fac8cb96
2 changed files with 17 additions and 94 deletions

View File

@ -35,17 +35,15 @@ func (self *Context) CreateFileFromReader(sourcePath string, reader io.Reader) (
return nil, err return nil, err
} }
rf := &rawFile{ cf := &contextFile{
rawFile{
relPath: sourcePath, relPath: sourcePath,
props: make(map[string]FileProp), props: make(map[string]FileProp),
modTime: time.Now(), modTime: time.Now(),
size: int64(len(data)), size: int64(len(data)),
reader: bytes.NewReader(data), reader: bytes.NewReader(data),
} },
self.index,
cf := &contextFile{
file: rf,
index: self.index,
} }
return cf, nil return cf, nil
@ -69,17 +67,15 @@ func (self *Context) CreateFileFromAsset(sourcePath, dataPath string) (File, err
return nil, errors.New("assets must be files") return nil, errors.New("assets must be files")
} }
rf := &rawFile{ cf := &contextFile{
rawFile{
relPath: sourcePath, relPath: sourcePath,
props: make(map[string]FileProp), props: make(map[string]FileProp),
modTime: info.ModTime(), modTime: info.ModTime(),
size: info.Size(), size: info.Size(),
dataPath: dataPath, dataPath: dataPath,
} },
self.index,
cf := &contextFile{
file: rf,
index: self.index,
} }
return cf, nil return cf, nil

View File

@ -1,79 +1,6 @@
package goldsmith package goldsmith
import (
"io"
"time"
)
type contextFile struct { type contextFile struct {
file File rawFile
index int index int
} }
func (self *contextFile) Path() string {
return self.file.Path()
}
func (self *contextFile) Dir() string {
return self.file.Dir()
}
func (self *contextFile) Name() string {
return self.file.Name()
}
func (self *contextFile) Ext() string {
return self.file.Ext()
}
func (self *contextFile) Rename(path string) error {
return self.file.Rename(path)
}
func (self *contextFile) Size() int64 {
return self.file.Size()
}
func (self *contextFile) ModTime() time.Time {
return self.file.ModTime()
}
func (self *contextFile) Read(data []byte) (int, error) {
return self.file.Read(data)
}
func (self *contextFile) WriteTo(writer io.Writer) (int64, error) {
return self.file.WriteTo(writer)
}
func (self *contextFile) Seek(offset int64, whence int) (int64, error) {
return self.file.Seek(offset, whence)
}
func (self *contextFile) GoString() string {
return self.file.GoString()
}
func (self *contextFile) SetProp(name string, value FileProp) {
self.file.SetProp(name, value)
}
func (self *contextFile) Prop(name string) (FileProp, bool) {
return self.file.Prop(name)
}
func (self *contextFile) PropOrDef(name string, valueDef FileProp) FileProp {
return self.file.PropOrDef(name, valueDef)
}
func (self *contextFile) Props() FileProps {
return self.file.Props()
}
func (self *contextFile) CopyProps(file File) {
self.file.CopyProps(file)
}
func (self *contextFile) RemoveProp(name string) {
self.file.RemoveProp(name)
}