24 |
|
{ Corporation. All Rights Reserved. } |
25 |
|
{ Contributor(s): Jeff Overcash } |
26 |
|
{ } |
27 |
+ |
{ IBX For Lazarus (Firebird Express) } |
28 |
+ |
{ Contributor: Tony Whyman, MWA Software http://www.mwasoftware.co.uk } |
29 |
+ |
{ Portions created by MWA Software are copyright McCallum Whyman } |
30 |
+ |
{ Associates Ltd 2011 } |
31 |
|
{************************************************************************} |
32 |
|
|
33 |
|
unit IBBlob; |
49 |
|
private |
50 |
|
FBase: TIBBase; |
51 |
|
FBlobID: TISC_QUAD; |
52 |
< |
FBlobMaxSegmentSize, |
53 |
< |
FBlobNumSegments, |
54 |
< |
FBlobSize: Long; |
52 |
> |
FBlobMaxSegmentSize: Int64; |
53 |
> |
FBlobNumSegments: Int64; |
54 |
> |
FBlobSize: Int64; |
55 |
|
FBlobType: Short; { 0 = segmented, 1 = streamed } |
56 |
|
FBuffer: PChar; |
57 |
|
FBlobInitialized: Boolean; |
58 |
|
FHandle: TISC_BLOB_HANDLE; |
59 |
|
FMode: TBlobStreamMode; |
60 |
|
FModified: Boolean; |
61 |
< |
FPosition: Long; |
61 |
> |
FPosition: Int64; |
62 |
|
protected |
63 |
|
procedure CloseBlob; |
64 |
|
procedure CreateBlob; |
85 |
|
function Read(var Buffer; Count: Longint): Longint; override; |
86 |
|
procedure SaveToFile(Filename: string); |
87 |
|
procedure SaveToStream(Stream: TStream); |
88 |
< |
function Seek(Offset: Longint; Origin: Word): Longint; override; |
89 |
< |
procedure SetSize(NewSize: Long); override; |
88 |
> |
function Seek(const Offset: Int64; Origin: TSeekOrigin): Int64; override; |
89 |
> |
procedure SetSize(const NewSize: Int64); override; |
90 |
> |
procedure SetSize(NewSize: Longint); override; |
91 |
|
procedure Truncate; |
92 |
|
function Write(const Buffer; Count: Longint): Longint; override; |
93 |
|
property Handle: TISC_BLOB_HANDLE read FHandle; |
94 |
|
property BlobID: TISC_QUAD read FBlobID write SetBlobID; |
95 |
< |
property BlobMaxSegmentSize: Long read FBlobMaxSegmentSize; |
96 |
< |
property BlobNumSegments: Long read FBlobNumSegments; |
97 |
< |
property BlobSize: Long read FBlobSize; |
95 |
> |
property BlobMaxSegmentSize: Int64 read FBlobMaxSegmentSize; |
96 |
> |
property BlobNumSegments: Int64 read FBlobNumSegments; |
97 |
> |
property BlobSize: Int64 read FBlobSize; |
98 |
|
property BlobType: Short read FBlobType; |
99 |
|
property Database: TIBDatabase read GetDatabase write SetDatabase; |
100 |
|
property DBHandle: PISC_DB_HANDLE read GetDBHandle; |
104 |
|
property TRHandle: PISC_TR_HANDLE read GetTRHandle; |
105 |
|
end; |
106 |
|
|
107 |
< |
procedure GetBlobInfo(hBlobHandle: PISC_BLOB_HANDLE; var NumSegments, MaxSegmentSize, |
108 |
< |
TotalSize: Long; var BlobType: Short); |
109 |
< |
procedure ReadBlob(hBlobHandle: PISC_BLOB_HANDLE; Buffer: PChar; BlobSize: Long); |
110 |
< |
procedure WriteBlob(hBlobHandle: PISC_BLOB_HANDLE; Buffer: PChar; BlobSize: Long); |
107 |
> |
procedure GetBlobInfo(hBlobHandle: PISC_BLOB_HANDLE; var NumSegments: Int64; var MaxSegmentSize, |
108 |
> |
TotalSize: Int64; var BlobType: Short); |
109 |
> |
procedure ReadBlob(hBlobHandle: PISC_BLOB_HANDLE; Buffer: PChar; BlobSize: Int64); |
110 |
> |
procedure WriteBlob(hBlobHandle: PISC_BLOB_HANDLE; Buffer: PChar; BlobSize: Int64); |
111 |
|
|
112 |
|
implementation |
113 |
|
|
114 |
|
uses IBIntf; |
115 |
|
|
116 |
< |
procedure GetBlobInfo(hBlobHandle: PISC_BLOB_HANDLE; var NumSegments, MaxSegmentSize, |
117 |
< |
TotalSize: Long; var BlobType: Short); |
116 |
> |
procedure GetBlobInfo(hBlobHandle: PISC_BLOB_HANDLE; var NumSegments: Int64; var MaxSegmentSize, |
117 |
> |
TotalSize: Int64; var BlobType: Short); |
118 |
|
var |
119 |
|
items: array[0..3] of Char; |
120 |
|
results: array[0..99] of Char; |
137 |
|
item_length := isc_vax_integer(@results[i], 2); Inc(i, 2); |
138 |
|
case item of |
139 |
|
isc_info_blob_num_segments: |
140 |
< |
NumSegments := isc_vax_integer(@results[i], item_length); |
140 |
> |
NumSegments := isc_portable_integer(@results[i], item_length); |
141 |
|
isc_info_blob_max_segment: |
142 |
< |
MaxSegmentSize := isc_vax_integer(@results[i], item_length); |
142 |
> |
MaxSegmentSize := isc_portable_integer(@results[i], item_length); |
143 |
|
isc_info_blob_total_length: |
144 |
< |
TotalSize := isc_vax_integer(@results[i], item_length); |
144 |
> |
TotalSize := isc_portable_integer(@results[i], item_length); |
145 |
|
isc_info_blob_type: |
146 |
< |
BlobType := isc_vax_integer(@results[i], item_length); |
146 |
> |
BlobType := isc_portable_integer(@results[i], item_length); |
147 |
|
end; |
148 |
|
Inc(i, item_length); |
149 |
|
end; |
150 |
|
end; |
151 |
|
|
152 |
< |
procedure ReadBlob(hBlobHandle: PISC_BLOB_HANDLE; Buffer: PChar; BlobSize: Long); |
152 |
> |
procedure ReadBlob(hBlobHandle: PISC_BLOB_HANDLE; Buffer: PChar; BlobSize: Int64); |
153 |
|
var |
154 |
< |
CurPos: Long; |
154 |
> |
CurPos: Int64; |
155 |
|
BytesRead, SegLen: UShort; |
156 |
|
LocalBuffer: PChar; |
157 |
|
begin |
173 |
|
end; |
174 |
|
|
175 |
|
procedure WriteBlob(hBlobHandle: PISC_BLOB_HANDLE; Buffer: PChar; |
176 |
< |
BlobSize: Long); |
176 |
> |
BlobSize: Int64); |
177 |
|
var |
178 |
< |
CurPos, SegLen: Long; |
178 |
> |
CurPos: Int64; |
179 |
> |
SegLen: Long; |
180 |
|
begin |
181 |
|
CurPos := 0; |
182 |
|
SegLen := DefaultBlobSegmentSize; |
279 |
|
|
280 |
|
procedure TIBBlobStream.GetBlobInfo; |
281 |
|
var |
282 |
< |
iBlobSize: Long; |
282 |
> |
iBlobSize: Int64; |
283 |
|
begin |
284 |
|
IBBlob.GetBlobInfo(@FHandle, FBlobNumSegments, FBlobMaxSegmentSize, |
285 |
|
iBlobSize, FBlobType); |
385 |
|
end; |
386 |
|
end; |
387 |
|
|
388 |
< |
function TIBBlobStream.Seek(Offset: Longint; Origin: Word): Longint; |
388 |
> |
function TIBBlobStream.Seek(const Offset: Int64; Origin: TSeekOrigin): Int64; |
389 |
|
begin |
390 |
|
EnsureBlobInitialized; |
391 |
|
case Origin of |
392 |
< |
soFromBeginning : FPosition := Offset; |
393 |
< |
soFromCurrent : Inc(FPosition, Offset); |
394 |
< |
soFromEnd : FPosition := FBlobSize + Offset; |
392 |
> |
soBeginning : FPosition := Offset; |
393 |
> |
soCurrent : Inc(FPosition, Offset); |
394 |
> |
soEnd : FPosition := FBlobSize + Offset; |
395 |
|
end; |
396 |
|
result := FPosition; |
397 |
|
end; |
414 |
|
FBlobInitialized := False; |
415 |
|
end; |
416 |
|
|
417 |
< |
procedure TIBBlobStream.SetSize(NewSize: Long); |
417 |
> |
procedure TIBBlobStream.SetSize(const NewSize: Int64); |
418 |
|
begin |
419 |
|
if (NewSize <> FBlobSize) then |
420 |
|
begin |
425 |
|
end; |
426 |
|
end; |
427 |
|
|
428 |
+ |
procedure TIBBlobStream.SetSize(NewSize: Longint); |
429 |
+ |
begin |
430 |
+ |
SetSize(Int64(NewSize)); |
431 |
+ |
end; |
432 |
+ |
|
433 |
|
procedure TIBBlobStream.SetTransaction(Value: TIBTransaction); |
434 |
|
begin |
435 |
|
FBase.Transaction := Value; |