File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -16,8 +16,11 @@ fn main_0() -> i32 {
1616 . chain ( std:: iter:: once ( 0 ) )
1717 . collect :: < Vec < u8 > > ( ) ,
1818 ) ) ;
19+ let file: Value < Box < [ u8 ] > > = Rc :: new ( RefCell :: new ( Box :: < [ u8 ] > :: from (
20+ b"test_stdcopy_ostream.txt\0 " . as_slice ( ) ,
21+ ) ) ) ;
1922 let ofs: Value < :: std:: fs:: File > = Rc :: new ( RefCell :: new (
20- :: std:: fs:: File :: create ( Ptr :: from_string_literal ( "test.txt" ) . to_string ( ) )
23+ :: std:: fs:: File :: create ( ( file . as_pointer ( ) as Ptr < u8 > ) . to_string ( ) )
2124 . expect ( "Failed to open file" ) ,
2225 ) ) ;
2326 {
@@ -28,5 +31,6 @@ fn main_0() -> i32 {
2831 ) ;
2932 ( * ofs. borrow_mut ( ) ) . try_clone ( ) . unwrap ( )
3033 } ;
34+ libc:: unlink ( ( file. as_pointer ( ) as Ptr < u8 > ) as * const i8 ) ;
3135 return 0 ;
3236}
Original file line number Diff line number Diff line change @@ -16,8 +16,9 @@ unsafe fn main_0() -> i32 {
1616 let s = b"Hello, world!\n \0 " . as_ptr ( ) ;
1717 std:: slice:: from_raw_parts ( s, ( 0 ..) . take_while ( |& i| * s. add ( i) != 0 ) . count ( ) + 1 ) . to_vec ( )
1818 } ;
19+ let file: [ u8 ; 25 ] = * b"test_stdcopy_ostream.txt\0 " ;
1920 let mut ofs: :: std:: fs:: File = :: std:: fs:: File :: create (
20- :: std:: ffi:: CStr :: from_ptr ( b"test.txt \0 " . as_ptr ( ) as * const i8 )
21+ :: std:: ffi:: CStr :: from_ptr ( file . as_ptr ( ) as * const i8 )
2122 . to_str ( )
2223 . unwrap ( ) ,
2324 )
@@ -29,5 +30,6 @@ unsafe fn main_0() -> i32 {
2930 ofs. write_all ( :: std:: slice:: from_raw_parts ( __start, __len) ) ;
3031 ofs. try_clone ( ) . unwrap ( )
3132 } ;
33+ libc:: unlink ( file. as_ptr ( ) as * const i8 ) ;
3234 return 0 ;
3335}
Original file line number Diff line number Diff line change 11// Copyright (c) 2022-present INESC-ID.
22// Distributed under the MIT license that can be found in the LICENSE file.
33
4+ // XFAIL: refcount
5+
46#include < algorithm>
57#include < fstream>
68#include < iterator>
79#include < string>
10+ #include < unistd.h>
811
912int main () {
1013 std::string str = " Hello, world!\n " ;
11- std::ofstream ofs (" test.txt" , std::ios::binary);
12- std::copy (str.begin (), str.end (), std::ostream_iterator<char >(ofs));
14+ const char file[] = " test_stdcopy_ostream.txt" ;
15+ {
16+ std::ofstream ofs (file, std::ios::binary);
17+ std::copy (str.begin (), str.end (), std::ostream_iterator<char >(ofs));
18+ }
19+ unlink (file);
1320 return 0 ;
1421}
You can’t perform that action at this time.
0 commit comments