| 895 | |
| 896 | |
| 897 | static int final_read_and_write(FILE_DESC input_file_desc, |
| 898 | FILE_DESC output_fl_desc, |
| 899 | const TEXT* file_name, |
| 900 | SLONG io_size, |
| 901 | UCHAR** io_buffer, |
| 902 | bool* end_of_input) |
| 903 | { |
| 904 | |
| 905 | /******************************************************************** |
| 906 | ** |
| 907 | ** f i n a l _ r e a d _ a n d _ w r i t e |
| 908 | ** |
| 909 | ********************************************************************* |
| 910 | ** |
| 911 | ** Functional description: |
| 912 | ** |
| 913 | ** Read all data from input file and write the data out to output |
| 914 | ** file. |
| 915 | ** |
| 916 | ********************************************************************* |
| 917 | */ |
| 918 | |
| 919 | const SLONG read_cnt = read_platf(input_file_desc, *io_buffer, io_size); |
| 920 | |
| 921 | switch (read_cnt) |
| 922 | { |
| 923 | case 0: // no more data to be read |
| 924 | close_platf(output_fl_desc); |
| 925 | *end_of_input = true; |
| 926 | return FB_SUCCESS; |
| 927 | |
| 928 | case -1: // read failed |
| 929 | close_platf(output_fl_desc); |
| 930 | fprintf(stderr, "problem when reading input file, errno = %d\n", errno); |
| 931 | return FB_FAILURE; |
| 932 | |
| 933 | default: // read ok |
| 934 | break; |
| 935 | } |
| 936 | |
| 937 | const SLONG write_cnt = write_platf(output_fl_desc, *io_buffer, read_cnt); |
| 938 | |
| 939 | switch (write_cnt) |
| 940 | { |
| 941 | case -1: // write failed |
| 942 | close_platf(output_fl_desc); |
| 943 | return FB_FAILURE; |
| 944 | |
| 945 | default: |
| 946 | if (write_cnt == read_cnt) // write ok |
| 947 | return FB_SUCCESS; |
| 948 | |
| 949 | fprintf(stderr, "There is no enough space to write to back up file %s\n", file_name); |
| 950 | close_platf(output_fl_desc); |
| 951 | return FB_FAILURE; |
| 952 | } |
| 953 | } |
| 954 |
no test coverage detected