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

Function cwrite

src/split.c:681–703  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

679 Return true if successful. */
680
681static bool
682cwrite (bool new_file_flag, char const *bp, idx_t bytes)
683{
684 if (new_file_flag)
685 {
686 if (!bp && bytes == 0 && elide_empty_files)
687 return true;
688 closeout (NULL, output_desc, filter_pid, outfile);
689 next_file_name ();
690 output_desc = create (outfile);
691 if (output_desc < 0)
692 error (EXIT_FAILURE, errno, "%s", quotef (outfile));
693 }
694
695 if (full_write (output_desc, bp, bytes) == bytes)
696 return true;
697 else
698 {
699 if (! ignorable (errno))
700 error (EXIT_FAILURE, errno, "%s", quotef (outfile));
701 return false;
702 }
703}
704
705/* Split into pieces of exactly N_BYTES bytes.
706 However, the first REM_BYTES pieces should be 1 byte longer.

Callers 4

bytes_splitFunction · 0.85
lines_splitFunction · 0.85
line_bytes_splitFunction · 0.85
lines_chunk_splitFunction · 0.85

Calls 4

closeoutFunction · 0.85
next_file_nameFunction · 0.85
createFunction · 0.85
ignorableFunction · 0.85

Tested by

no test coverage detected