MCPcopy Create free account
hub / github.com/FirebirdSQL/firebird / read_and_write

Function read_and_write

src/burp/split/spit.cpp:818–894  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

816
817
818static int read_and_write(FILE_DESC input_file_desc,
819 FILE_DESC output_fl_desc,
820 //const TEXT* file_name,
821 SLONG io_size,
822 SINT64 file_size,
823 UCHAR** io_buffer,
824 bool* end_of_input,
825 SINT64* byte_read,
826 SLONG* byte_write)
827{
828
829/********************************************************************
830**
831** r e a d _ a n d _ w r i t e
832**
833*********************************************************************
834**
835** Functional description:
836**
837** Read data from input file and write the data out to output
838** file.
839**
840*********************************************************************
841*/
842
843 SLONG read_cnt, last_read_size;
844
845 // when number of byte read + number of byte goint to
846 // be read is greater then file size, then calculate
847 // the size for the last read and do the last read for
848 // the current backup file. Otherwise read as mush data
849 // as will fit in the current backup file.
850
851 if (*byte_read + io_size > file_size)
852 {
853 last_read_size = (SLONG) (file_size - *byte_read);
854 read_cnt = read_platf(input_file_desc, *io_buffer, last_read_size);
855 }
856 else
857 read_cnt = read_platf(input_file_desc, *io_buffer, io_size);
858
859 switch (read_cnt)
860 {
861 case 0: // no more data to be read
862 close_platf(output_fl_desc);
863 *end_of_input = true;
864 *byte_read = *byte_read + read_cnt;
865 return FB_SUCCESS;
866
867 case -1: // read failed
868 close_platf(output_fl_desc);
869 fprintf(stderr, "fail to read input from stdin, errno = %d\n", errno);
870 return FB_FAILURE;
871
872 default: // read ok
873 *byte_read = *byte_read + read_cnt;
874 break;
875 }

Callers 1

gen_multy_bakup_filesFunction · 0.85

Calls 3

read_platfFunction · 0.85
write_platfFunction · 0.85
close_platfFunction · 0.70

Tested by

no test coverage detected