WIP
This commit is contained in:
parent
3d49fa4f94
commit
9746ae578d
@ -24,13 +24,13 @@
|
||||
*/
|
||||
|
||||
|
||||
#define FB_UDR_STATUS_TYPE ::Firebird::ThrowStatusWrapper
|
||||
|
||||
|
||||
//#include <ibase.h>
|
||||
//#include <firebird/UdrCppEngine.h>
|
||||
#include "MyFirstUDRKit.h"
|
||||
|
||||
#include <ibase.h>
|
||||
#include <firebird/UdrCppEngine.h>
|
||||
#include "UdrCppTemplates.h"
|
||||
|
||||
#include <cassert>
|
||||
#include <cstdio>
|
||||
#include <cstdlib>
|
||||
@ -68,7 +68,6 @@
|
||||
|
||||
#include <limits>
|
||||
|
||||
using namespace std;
|
||||
using namespace Firebird;
|
||||
|
||||
|
||||
@ -185,7 +184,7 @@ FB_UDR_MESSAGE(OutMessage,
|
||||
|
||||
AutoRelease<IAttachment> att;
|
||||
AutoRelease<ITransaction> tra;
|
||||
AutoRelease<IBlob> Blob;
|
||||
AutoRelease<IBlob> blob;
|
||||
|
||||
FB_UDR_EXECUTE_FUNCTION
|
||||
{
|
||||
@ -206,12 +205,9 @@ FB_UDR_EXECUTE_FUNCTION
|
||||
|
||||
att.reset(context->getAttachment(status));
|
||||
tra.reset(context->getTransaction(status));
|
||||
blob.reset(att->openBlob(status, tra, &in->ablob, 0, nullptr));
|
||||
|
||||
// This is wrong - the calling application should pass in a blob handle
|
||||
//AutoRelease<IBlob> Blob(att->openBlob(status, tra, &in->ablob, 0, nullptr));
|
||||
Blob.reset(att->openBlob(status, tra, &in->ablob, 0, nullptr));
|
||||
|
||||
if (Blob == nullptr) {
|
||||
if (blob == nullptr) {
|
||||
out->result = -1;
|
||||
return;
|
||||
}
|
||||
@ -222,7 +218,9 @@ FB_UDR_EXECUTE_FUNCTION
|
||||
while ( FileReader.good() ) {
|
||||
FileReader.read( Buffer.data(), Buffer.size() );
|
||||
DataSize = FileReader.gcount();
|
||||
Blob->putSegment( status, DataSize, Buffer.data() );
|
||||
// fail seems to be here...
|
||||
// Probably need to declare buffer differently.
|
||||
blob->putSegment( status, DataSize, Buffer.data() );
|
||||
out->result += DataSize;
|
||||
// Perhaps test for badbit here?
|
||||
}
|
||||
@ -230,16 +228,17 @@ FB_UDR_EXECUTE_FUNCTION
|
||||
// What to do?
|
||||
out->resultNull = FB_TRUE;
|
||||
// What do we do with the partially written blob? Is cancel enough?
|
||||
Blob->cancel( status );
|
||||
blob->cancel( status );
|
||||
// Should we reset result to 0?
|
||||
|
||||
}
|
||||
Blob->close( status );
|
||||
Blob->release();
|
||||
blob->close( status );
|
||||
blob->release();
|
||||
Buffer.clear();
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
// This generates an unrecognised C++ exception, which is insufficient.
|
||||
throw std::runtime_error("Error writing stream to BLOB.");
|
||||
}
|
||||
|
||||
@ -291,7 +290,7 @@ FB_UDR_EXECUTE_FUNCTION
|
||||
* DOC NOTE - We do not test for existence of the file here!
|
||||
*/
|
||||
|
||||
fstream File ( in->afilename.str , fstream::out | fstream::binary | fstream::app );
|
||||
std::fstream File ( in->afilename.str , std::fstream::out | std::fstream::binary | std::fstream::app );
|
||||
if (! File.is_open()) {
|
||||
out->result = -2;
|
||||
return;
|
||||
@ -305,7 +304,7 @@ FB_UDR_EXECUTE_FUNCTION
|
||||
}
|
||||
|
||||
|
||||
vector<char> Buffer (MaxSegmentSize, 0);
|
||||
std::vector<char> Buffer (MaxSegmentSize, 0);
|
||||
|
||||
unsigned BytesRead = 0;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user