in src/ios/CDVFileTransfer.m [57:78]
static CFIndex WriteDataToStream(NSData* data, CFWriteStreamRef stream)
{
UInt8* bytes = (UInt8*)[data bytes];
long long bytesToWrite = [data length];
long long totalBytesWritten = 0;
while (totalBytesWritten < bytesToWrite) {
CFIndex result = CFWriteStreamWrite(stream,
bytes + totalBytesWritten,
bytesToWrite - totalBytesWritten);
if (result < 0) {
CFStreamError error = CFWriteStreamGetError(stream);
NSLog(@"WriteStreamError domain: %ld error: %ld", error.domain, (long)error.error);
return result;
} else if (result == 0) {
return result;
}
totalBytesWritten += result;
}
return totalBytesWritten;
}