Use FileReader as var name

This commit is contained in:
Paul Reeves 2023-02-01 20:12:59 +01:00
parent 60206f3b48
commit c092e8fa8f

View File

@ -195,8 +195,9 @@ FB_UDR_EXECUTE_FUNCTION
out->result = 0;
}
ifstream File ( in->afilename.str , ios_base::in | ios_base::binary );
if (! File.is_open()) {
std::ifstream FileReader;
FileReader.open( in->afilename.str , std::ifstream::binary );
if (! FileReader.is_open()) {
out->result = -2;
return;
}
@ -211,21 +212,21 @@ FB_UDR_EXECUTE_FUNCTION
vector<char> Buffer (MaxSegmentSize, 0);
streamsize DataSize;
while ( File.good() ) {
File.read( Buffer.data(), Buffer.size() );
DataSize = File.gcount();
Blob->putSegment( status, DataSize, Buffer.data() );
out->result += DataSize;
// Perhaps test for badbit here?
}
if (File.bad()) { // Something went wrong
// What to do?
out->resultNull = FB_TRUE;
// What do we do with the partially written blob? Is cancel enough?
Blob->cancel( status );
// Should we reset result to 0?
while ( FileReader.good() ) {
FileReader.read( Buffer.data(), Buffer.size() );
DataSize = FileReader.gcount();
Blob->putSegment( status, DataSize, Buffer.data() );
out->result += DataSize;
// Perhaps test for badbit here?
}
if (FileReader.bad()) { // Something went wrong
// What to do?
out->resultNull = FB_TRUE;
// What do we do with the partially written blob? Is cancel enough?
Blob->cancel( status );
// Should we reset result to 0?
}
}
Blob->close( status );
Blob->release();