Skip to content

Commit

Permalink
Windows:NewDirectIOFromFIFOSet
Browse files Browse the repository at this point in the history
Signed-off-by: John Howard <jhoward@microsoft.com>
  • Loading branch information
John Howard committed Jan 15, 2019
1 parent 96f306e commit 90caf6f
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 4 deletions.
4 changes: 4 additions & 0 deletions cio/io.go
Original file line number Diff line number Diff line change
Expand Up @@ -275,3 +275,7 @@ func Load(set *FIFOSet) (IO, error) {
closers: []io.Closer{set},
}, nil
}

func (p *pipes) closers() []io.Closer {
return []io.Closer{p.Stdin, p.Stdout, p.Stderr}
}
4 changes: 0 additions & 4 deletions cio/io_unix.go
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,3 @@ func NewDirectIO(ctx context.Context, fifos *FIFOSet) (*DirectIO, error) {
},
}, err
}

func (p *pipes) closers() []io.Closer {
return []io.Closer{p.Stdin, p.Stdout, p.Stderr}
}
20 changes: 20 additions & 0 deletions cio/io_windows.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
package cio

import (
"context"
"fmt"
"io"
"net"
Expand Down Expand Up @@ -144,3 +145,22 @@ func NewDirectIO(stdin io.WriteCloser, stdout, stderr io.ReadCloser, terminal bo
},
}
}

// NewDirectIOFromFIFOSet returns an IO implementation that exposes the IO streams as io.ReadCloser
// and io.WriteCloser.
func NewDirectIOFromFIFOSet(ctx context.Context, stdin io.WriteCloser, stdout, stderr io.ReadCloser, fifos *FIFOSet) *DirectIO {
_, cancel := context.WithCancel(ctx)
pipes := pipes{
Stdin: stdin,
Stdout: stdout,
Stderr: stderr,
}
return &DirectIO{
pipes: pipes,
cio: cio{
config: fifos.Config,
closers: append(pipes.closers(), fifos),
cancel: cancel,
},
}
}

0 comments on commit 90caf6f

Please sign in to comment.