github.com/lmorg/murex@v0.0.0-20240217211045-e081c89cd4ef/builtins/pipes/file/struct.go (about)

     1  package file
     2  
     3  import (
     4  	"context"
     5  	"io"
     6  	"os"
     7  	"sync"
     8  
     9  	"github.com/lmorg/murex/config"
    10  	"github.com/lmorg/murex/lang/stdio"
    11  	"github.com/lmorg/murex/lang/types"
    12  )
    13  
    14  // File Io interface
    15  type File struct {
    16  	mutex      sync.Mutex
    17  	bWritten   uint64
    18  	dependents int
    19  	file       *os.File
    20  }
    21  
    22  // Read is an empty method because file devices are write only
    23  func (f *File) Read([]byte) (int, error) { return 0, io.EOF }
    24  
    25  // ReadLine is an empty method because file devices are write only
    26  func (f *File) ReadLine(func([]byte)) error { return nil }
    27  
    28  // ReadArray is an empty method because file devices are write only
    29  func (f *File) ReadArray(context.Context, func([]byte)) error { return nil }
    30  
    31  // ReadArrayWithType is an empty method because file devices are write only
    32  func (f *File) ReadArrayWithType(context.Context, func(interface{}, string)) error { return nil }
    33  
    34  // ReadMap is an empty method because file devices are write only
    35  func (f *File) ReadMap(*config.Config, func(*stdio.Map)) error { return nil }
    36  
    37  // ReadAll is an empty method because file devices are write only
    38  func (f *File) ReadAll() ([]byte, error) { return []byte{}, nil }
    39  
    40  // WriteTo is an empty method because file devices are write only
    41  func (f *File) WriteTo(io.Writer) (int64, error) { return 0, io.EOF }
    42  
    43  // GetDataType is an empty method because file devices are write only
    44  func (f *File) GetDataType() string { return types.Null }
    45  
    46  // SetDataType is an empty method because file devices are write only
    47  func (f *File) SetDataType(string) {}
    48  
    49  // DefaultDataType is an empty method because file devices are write only
    50  func (f *File) DefaultDataType(bool) {}
    51  
    52  // IsTTY returns false because the file writer is not a pseudo-TTY
    53  func (f *File) IsTTY() bool { return false }