From 01fac8cb96c421c710a609d978596f8bd9f48400 Mon Sep 17 00:00:00 2001 From: Alex Yatskov Date: Wed, 21 Feb 2024 18:59:53 -0800 Subject: [PATCH] Cleanup --- context.go | 36 +++++++++++------------- context_file.go | 75 +------------------------------------------------ 2 files changed, 17 insertions(+), 94 deletions(-) diff --git a/context.go b/context.go index c72bc21..dc4d339 100644 --- a/context.go +++ b/context.go @@ -35,17 +35,15 @@ func (self *Context) CreateFileFromReader(sourcePath string, reader io.Reader) ( return nil, err } - rf := &rawFile{ - relPath: sourcePath, - props: make(map[string]FileProp), - modTime: time.Now(), - size: int64(len(data)), - reader: bytes.NewReader(data), - } - cf := &contextFile{ - file: rf, - index: self.index, + rawFile{ + relPath: sourcePath, + props: make(map[string]FileProp), + modTime: time.Now(), + size: int64(len(data)), + reader: bytes.NewReader(data), + }, + self.index, } return cf, nil @@ -69,17 +67,15 @@ func (self *Context) CreateFileFromAsset(sourcePath, dataPath string) (File, err return nil, errors.New("assets must be files") } - rf := &rawFile{ - relPath: sourcePath, - props: make(map[string]FileProp), - modTime: info.ModTime(), - size: info.Size(), - dataPath: dataPath, - } - cf := &contextFile{ - file: rf, - index: self.index, + rawFile{ + relPath: sourcePath, + props: make(map[string]FileProp), + modTime: info.ModTime(), + size: info.Size(), + dataPath: dataPath, + }, + self.index, } return cf, nil diff --git a/context_file.go b/context_file.go index d477df9..e64864f 100644 --- a/context_file.go +++ b/context_file.go @@ -1,79 +1,6 @@ package goldsmith -import ( - "io" - "time" -) - type contextFile struct { - file File + rawFile 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) -}