github.com/mgoltzsche/ctnr@v0.7.1-alpha/pkg/fs/source/sourcedir.go (about) 1 package source 2 3 import ( 4 "time" 5 6 "github.com/mgoltzsche/ctnr/pkg/fs" 7 ) 8 9 var _ fs.Source = &SourceDir{} 10 11 type SourceDir struct { 12 attrs fs.FileAttrs 13 } 14 15 func NewSourceDir(attrs fs.FileAttrs) fs.Source { 16 if attrs.Mtime.IsZero() { 17 attrs.Mtime = time.Now().UTC() 18 } 19 return &SourceDir{attrs} 20 } 21 22 func (s *SourceDir) Attrs() fs.NodeInfo { 23 return fs.NodeInfo{fs.TypeDir, s.attrs} 24 } 25 26 func (s *SourceDir) DeriveAttrs() (fs.DerivedAttrs, error) { 27 return fs.DerivedAttrs{}, nil 28 } 29 30 func (s *SourceDir) Write(dest, name string, w fs.Writer, _ map[fs.Source]string) error { 31 return w.Dir(dest, name, s.attrs) 32 } 33 34 func (s *SourceDir) String() string { 35 return "sourceDir{" + s.attrs.String() + "}" 36 }