github.com/grailbio/base@v0.0.11/ioctx/fsctx/fs.go (about)

     1  // fsctx adds context.Context to io/fs APIs.
     2  //
     3  // TODO: Specify policy for future additions to this package. See ioctx.
     4  package fsctx
     5  
     6  import (
     7  	"context"
     8  	"os"
     9  )
    10  
    11  // FS is io/fs.FS with context added.
    12  type FS interface {
    13  	Open(_ context.Context, name string) (File, error)
    14  }
    15  
    16  // File is io/fs.File with context added.
    17  type File interface {
    18  	Stat(context.Context) (os.FileInfo, error)
    19  	Read(context.Context, []byte) (int, error)
    20  	Close(context.Context) error
    21  }
    22  
    23  // DirEntry is io/fs.DirEntry with context added.
    24  type DirEntry interface {
    25  	Name() string
    26  	IsDir() bool
    27  	Type() os.FileMode
    28  	Info(context.Context) (os.FileInfo, error)
    29  }
    30  
    31  // ReadDirFile is io/fs.ReadDirFile with context added.
    32  type ReadDirFile interface {
    33  	File
    34  	ReadDir(_ context.Context, n int) ([]DirEntry, error)
    35  }