Ticket #297: close.patch
File close.patch, 2.8 KB (added by NotFound, 13 years ago) |
---|
-
src/io/win32.c
301 301 Parrot_io_close_win32(PARROT_INTERP, ARGMOD(PMC *filehandle)) 302 302 { 303 303 ASSERT_ARGS(Parrot_io_close_win32) 304 UINTVAL result = 0; 304 305 PIOHANDLE os_handle = Parrot_io_get_os_handle(interp, filehandle); 305 306 if (os_handle != INVALID_HANDLE_VALUE) { 306 CloseHandle(os_handle); 307 if (CloseHandle(os_handle) == 0) 308 result = GetLastError (); 307 309 Parrot_io_set_os_handle(interp, filehandle, INVALID_HANDLE_VALUE); 308 310 } 309 311 return 0; -
src/io/unix.c
331 331 Parrot_io_close_unix(PARROT_INTERP, ARGMOD(PMC *filehandle)) 332 332 { 333 333 ASSERT_ARGS(Parrot_io_close_unix) 334 INTVAL result = 0; 334 335 PIOHANDLE file_descriptor = Parrot_io_get_os_handle(interp, filehandle); 335 336 /* BSD and Solaris need explicit fsync() */ 336 337 if (file_descriptor >= 0) { 337 338 fsync(file_descriptor); 338 close(file_descriptor); 339 if (close(file_descriptor) != 0) 340 result = errno; 339 341 } 340 342 Parrot_io_set_os_handle(interp, filehandle, -1); 341 return 0;343 return result; 342 344 } 343 345 344 346 /* -
src/io/portable.c
224 224 Parrot_io_close_portable(PARROT_INTERP, ARGMOD(PMC *filehandle)) 225 225 { 226 226 ASSERT_ARGS(Parrot_io_close_portable) 227 INTVAL result = 0; 227 228 FILE * const fptr = (FILE *)Parrot_io_get_os_handle(interp, filehandle); 228 229 229 if (fptr) 230 fclose(fptr); 230 if (fptr) { 231 if (fclose(fptr) != 0) 232 result = errno; 233 } 231 234 232 235 Parrot_io_set_os_handle(interp, filehandle, (PIOHANDLE)NULL); 233 236 234 return 0;237 return result; 235 238 } 236 239 237 240 -
tools/dev/pbc_to_exe.pir
25 25 .local string objfile 26 26 .local string exefile 27 27 .local string out 28 .local int closeresult 28 29 29 30 (infile, cfile, objfile, exefile) = 'handle_args'(argv) 30 31 unless infile > '' goto err_infile … … 77 78 } 78 79 MAIN 79 80 80 close outfh 81 # The close opcode does not return a result code, 82 # use the method instead. 83 closeresult = outfh.'close'() 84 unless closeresult == 0 goto err_close 85 81 86 'compile_file'(cfile, objfile) 82 87 'link_file'(objfile, exefile) 83 88 .return () … … 86 91 die "cannot read infile" 87 92 err_outfh: 88 93 die "cannot write outfile" 94 err_close: 95 die "cannot close outfile" 89 96 .end 90 97 91 98