MCPcopy Create free account
hub / github.com/coreutils/coreutils / create_output_file

Function create_output_file

src/csplit.c:893–925  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

891/* Create the next output file. */
892
893static void
894create_output_file (void)
895{
896 int nfiles = files_created;
897 bool fopen_ok;
898 int fopen_errno;
899
900 output_filename = make_filename (nfiles);
901
902 if (nfiles == INT_MAX)
903 {
904 fopen_ok = false;
905 fopen_errno = EOVERFLOW;
906 }
907 else
908 {
909 /* Create the output file in a critical section, to avoid races. */
910 sigset_t oldset;
911 sigprocmask (SIG_BLOCK, &caught_signals, &oldset);
912 output_stream = fopen (output_filename, "w");
913 fopen_ok = (output_stream != NULL);
914 fopen_errno = errno;
915 files_created = nfiles + fopen_ok;
916 sigprocmask (SIG_SETMASK, &oldset, NULL);
917 }
918
919 if (! fopen_ok)
920 {
921 error (0, fopen_errno, "%s", quotef (output_filename));
922 cleanup_fatal ();
923 }
924 bytes_written = 0;
925}
926
927/* If requested, delete all the files we have created. This function
928 must be called only from critical sections. */

Callers 3

process_line_countFunction · 0.85
process_regexpFunction · 0.85
split_fileFunction · 0.85

Calls 2

make_filenameFunction · 0.85
cleanup_fatalFunction · 0.85

Tested by

no test coverage detected