1
- use std:: fs:: File ;
2
- use std:: io:: { BufReader , Read , Write } ;
3
1
use std:: path:: { Path , PathBuf } ;
4
2
5
3
use crate :: { env_var, Command } ;
@@ -111,18 +109,9 @@ impl LlvmFilecheck {
111
109
Self { cmd }
112
110
}
113
111
114
- /// Pipe a file into standard input containing patterns that will be matched against the .patterns(path) call.
115
- pub fn stdin < P : AsRef < Path > > ( & mut self , path : P ) -> & mut Self {
116
- let file = File :: open ( path) . unwrap ( ) ;
117
- let reader = BufReader :: new ( file) ;
118
- let byte_vec = read_bytes ( reader) . expect ( "failed to read bytes of standard input" ) ;
119
- let byte_slice = byte_vec. as_slice ( ) ;
120
- self . cmd . stdin ( std:: process:: Stdio :: piped ( ) ) ;
121
- let mut child = self . cmd . spawn ( ) . unwrap ( ) ;
122
- let mut stdin = child. stdin . take ( ) . unwrap ( ) ;
123
- stdin. write_all ( byte_slice) . unwrap ( ) ;
124
- stdin. flush ( ) . unwrap ( ) ;
125
- child. wait_with_output ( ) . unwrap ( ) ;
112
+ /// Pipe a read file into standard input containing patterns that will be matched against the .patterns(path) call.
113
+ pub fn stdin < I : AsRef < [ u8 ] > > ( & mut self , input : I ) -> & mut Self {
114
+ self . cmd . set_stdin ( input. as_ref ( ) . to_vec ( ) . into_boxed_slice ( ) ) ;
126
115
self
127
116
}
128
117
@@ -132,9 +121,3 @@ impl LlvmFilecheck {
132
121
self
133
122
}
134
123
}
135
-
136
- fn read_bytes < R : Read > ( mut reader : R ) -> Result < Vec < u8 > , std:: io:: Error > {
137
- let mut buffer = Vec :: new ( ) ;
138
- reader. read_to_end ( & mut buffer) ?;
139
- Ok ( buffer)
140
- }
0 commit comments