From c092e8fa8f00b2f28af22ffa904426f20575862d Mon Sep 17 00:00:00 2001 From: Paul Reeves Date: Wed, 1 Feb 2023 20:12:59 +0100 Subject: [PATCH] Use FileReader as var name --- src/MyFirstUDRKit.cpp | 33 +++++++++++++++++---------------- 1 file changed, 17 insertions(+), 16 deletions(-) diff --git a/src/MyFirstUDRKit.cpp b/src/MyFirstUDRKit.cpp index 8f2dcde..bb9a1a2 100644 --- a/src/MyFirstUDRKit.cpp +++ b/src/MyFirstUDRKit.cpp @@ -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 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();