File tree Expand file tree Collapse file tree 1 file changed +18
-0
lines changed
library/std/src/sys/unix/kernel_copy Expand file tree Collapse file tree 1 file changed +18
-0
lines changed Original file line number Diff line number Diff line change @@ -65,6 +65,24 @@ fn copy_specialization() -> Result<()> {
6565 result. and ( rm1) . and ( rm2)
6666}
6767
68+ #[ test]
69+ fn copies_append_mode_sink ( ) -> Result < ( ) > {
70+ let tmp_path = tmpdir ( ) ;
71+ let source_path = tmp_path. join ( "copies_append_mode.source" ) ;
72+ let sink_path = tmp_path. join ( "copies_append_mode.sink" ) ;
73+ let mut source =
74+ OpenOptions :: new ( ) . create ( true ) . truncate ( true ) . write ( true ) . read ( true ) . open ( & source_path) ?;
75+ write ! ( source, "not empty" ) ?;
76+ source. seek ( SeekFrom :: Start ( 0 ) ) ?;
77+ let mut sink = OpenOptions :: new ( ) . create ( true ) . append ( true ) . open ( & sink_path) ?;
78+
79+ let copied = crate :: io:: copy ( & mut source, & mut sink) ?;
80+
81+ assert_eq ! ( copied, 9 ) ;
82+
83+ Ok ( ( ) )
84+ }
85+
6886#[ bench]
6987fn bench_file_to_file_copy ( b : & mut test:: Bencher ) {
7088 const BYTES : usize = 128 * 1024 ;
You can’t perform that action at this time.
0 commit comments