github.com/mgoltzsche/ctnr@v0.7.1-alpha/pkg/fs/source/sourcelink.go (about)

     1  package source
     2  
     3  import (
     4  	"github.com/mgoltzsche/ctnr/pkg/fs"
     5  )
     6  
     7  type SourceUpperLink struct {
     8  	fs.Source
     9  }
    10  
    11  func NewSourceUpperLink(s fs.Source) fs.Source {
    12  	return &SourceUpperLink{s}
    13  }
    14  
    15  func (f *SourceUpperLink) Write(path, name string, w fs.Writer, written map[fs.Source]string) (err error) {
    16  	if linkDest, ok := written[f.Source]; ok {
    17  		err = w.Link(path, linkDest)
    18  	} else {
    19  		err = f.Source.Write(path, name, w, written)
    20  	}
    21  	return
    22  }