Hmm... I find your various "XYZDescriptor" variables to be rather confusing. If something is a file descriptor, then a descriptor suffix makes sense. Otherwise, it doesn't. It seems to me that you're working with two files, with corresponding descriptors openDescriptorOriginal and openDescriptorNew. As such, I would expect something like:
Code:
while (total_bytes_read < partSize && (bytes_read = read(openDescriptorOriginal, BUFFER, partSize)) > 0)
{
total_bytes_read += bytes_read;
write(openDescriptorNew, BUFFER, bytes_read);
}
So the idea is that you keep track of the total bytes read, then keep reading until that value reaches the partSize. After each read, you write exactly the number of bytes just read.