@@ -743,24 +743,24 @@ void progress(int p, int eta)
743743// Spill connection contents to a tempfile so R-level fread can treat it like a filename
744744SEXP spillConnectionToFile (SEXP connection , SEXP tempfile_path , SEXP nrows_limit ) {
745745 if (!inherits (connection , "connection" )) {
746- INTERNAL_STOP (_ ("spillConnectionToFile: argument must be a connection" ));
746+ INTERNAL_STOP (_ ("spillConnectionToFile: argument must be a connection" )); // # nocov
747747 }
748748
749749 if (!isString (tempfile_path ) || LENGTH (tempfile_path ) != 1 ) {
750- INTERNAL_STOP (_ ("spillConnectionToFile: tempfile_path must be a single string" ));
750+ INTERNAL_STOP (_ ("spillConnectionToFile: tempfile_path must be a single string" )); // # nocov
751751 }
752752
753753 if (!isReal (nrows_limit ) || LENGTH (nrows_limit ) != 1 ) {
754- INTERNAL_STOP (_ ("spillConnectionToFile: nrows_limit must be a single numeric value" ));
754+ INTERNAL_STOP (_ ("spillConnectionToFile: nrows_limit must be a single numeric value" )); // # nocov
755755 }
756756
757757 Rconnection con = R_GetConnection (connection );
758758 if (con == NULL ) {
759- INTERNAL_STOP (_ ("spillConnectionToFile: invalid connection" ));
759+ INTERNAL_STOP (_ ("spillConnectionToFile: invalid connection" )); // # nocov
760760 }
761761
762762 if (!con -> isopen ) {
763- INTERNAL_STOP (_ ("spillConnectionToFile: connection is not open" ));
763+ INTERNAL_STOP (_ ("spillConnectionToFile: connection is not open" )); // # nocov
764764 }
765765
766766 const char * filepath = CHAR (STRING_ELT (tempfile_path , 0 ));
@@ -775,15 +775,15 @@ SEXP spillConnectionToFile(SEXP connection, SEXP tempfile_path, SEXP nrows_limit
775775
776776 FILE * outfile = fopen (filepath , "wb" );
777777 if (outfile == NULL ) {
778- STOP (_ ("spillConnectionToFile: failed to open temp file '%s' for writing" ), filepath );
778+ STOP (_ ("spillConnectionToFile: failed to open temp file '%s' for writing" ), filepath ); // # nocov
779779 }
780780
781781 // Read and write in chunks // TODO tune chunk size
782782 size_t chunk_size = 256 * 1024 ;
783783 char * buffer = malloc (chunk_size );
784784 if (!buffer ) {
785- fclose (outfile );
786- STOP (_ ("spillConnectionToFile: failed to allocate buffer" ));
785+ fclose (outfile ); // # nocov
786+ STOP (_ ("spillConnectionToFile: failed to allocate buffer" )); // # nocov
787787 }
788788
789789 size_t total_read = 0 ;
@@ -810,9 +810,11 @@ SEXP spillConnectionToFile(SEXP connection, SEXP tempfile_path, SEXP nrows_limit
810810
811811 size_t nwritten = fwrite (buffer , 1 , bytes_to_write , outfile );
812812 if (nwritten != bytes_to_write ) {
813+ // # nocov start
813814 free (buffer );
814815 fclose (outfile );
815816 STOP (_ ("spillConnectionToFile: write error (wrote %zu of %zu bytes)" ), nwritten , bytes_to_write );
817+ // # nocov end
816818 }
817819 total_read += bytes_to_write ;
818820
0 commit comments