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

     1  package source
     2  
     3  import (
     4  	"github.com/mgoltzsche/ctnr/pkg/fs"
     5  )
     6  
     7  var _ fs.Source = &sourceFifo{}
     8  
     9  type sourceFifo struct {
    10  	attrs fs.DeviceAttrs
    11  }
    12  
    13  func NewSourceFifo(attrs fs.DeviceAttrs) *sourceFifo {
    14  	return &sourceFifo{attrs}
    15  }
    16  
    17  func (s *sourceFifo) Attrs() fs.NodeInfo {
    18  	return fs.NodeInfo{fs.TypeFifo, s.attrs.FileAttrs}
    19  }
    20  
    21  func (s *sourceFifo) DeriveAttrs() (fs.DerivedAttrs, error) {
    22  	return fs.DerivedAttrs{}, nil
    23  }
    24  
    25  func (s *sourceFifo) Write(path, name string, w fs.Writer, written map[fs.Source]string) (err error) {
    26  	if linkDest, ok := written[s]; ok {
    27  		err = w.Link(path, linkDest)
    28  	} else {
    29  		written[s] = path
    30  		err = w.Fifo(path, s.attrs)
    31  	}
    32  	return
    33  }