source: oup/rewrite/DataAccess/Access_OniArchive.pas@ 104

Last change on this file since 104 was 101, checked in by alloc, 18 years ago
File size: 19.0 KB
RevLine 
[93]1unit Access_OniArchive;
2interface
3
[101]4uses DataAccess, Classes, TypeDefs;
[93]5
6type
7 TAccess_OniArchive = class(TDataAccess)
8 private
[101]9 Fdat_file: TFileStream;
10 Fraw_file: TFileStream;
11 Fsep_file: TFileStream;
12 Fdat_files: TFiles;
13 Fdat_extensionsmap: TExtensionsMap;
14 FUnloadWhenUnused: Boolean;
15 FDatOpened: Boolean;
16 FRawOpened: Boolean;
17 FSepOpened: Boolean;
[93]18 protected
19 public
20 property UnloadWhenUnused: Boolean Read FUnloadWhenUnused Write FUnloadWhenUnused;
21
[101]22 constructor Create(DatFilename: String; ConnectionID: Integer; var Msg: TStatusMessages); override;
[93]23 procedure Close; override;
24
[101]25 function GetFileInfo(FileID: Integer): TFileInfo; override;
26 function GetFilesList(Ext: String; Pattern: String;
27 NoEmptyFiles: Boolean; SortType: TSortType): TStrings; override;
28 function GetFileCount: Integer; override;
29 function GetExtensionsList(ExtListFormat: TExtensionFormat): TStrings; override;
[93]30
[101]31 procedure LoadDatFile(FileID: Integer; var Target: TStream); overload; override;
32 procedure UpdateDatFile(FileID: Integer; Src: TStream); overload; override;
33 procedure LoadDatFilePart(FileID, Offset, Size: Integer; var Target: TStream); overload; override;
34 procedure UpdateDatFilePart(FileID, Offset, Size: Integer; Src: TStream); overload; override;
[93]35
[101]36 function GetRawList(FileID: Integer): TRawDataList; override;
37 function GetRawInfo(FileID, DatOffset: Integer): TRawDataInfo; override;
38
39 procedure LoadRawOffset(LocSep: Boolean; RawAddr, Size: Integer; target: Pointer);
40 procedure LoadRawFile(FileID, DatOffset: Integer; var Target: TStream); overload; override;
41 procedure UpdateRawFile(FileID, DatOffset: Integer; Src: TStream); overload; override;
42 procedure LoadRawFilePart(FileID, DatOffset, Offset, Size: Integer; var Target: TStream); overload; override;
43 procedure UpdateRawFilePart(FileID, DatOffset, Offset, Size: Integer; Src: TStream); overload; override;
44
45 function AppendRawFile(LocSep: Boolean; Size: Integer; Src: TStream): Integer; overload; override;
[93]46 published
[101]47 end;
[93]48
49implementation
50
[101]51uses
52 SysUtils, StrUtils, Data, Functions, RawList;
[93]53
[101]54
[93]55(*
56================================================================================
57 Implementation of TOniDataDat
58*)
59
[101]60
61constructor TAccess_OniArchive.Create(DatFilename: String; ConnectionID: Integer; var Msg: TStatusMessages);
62type
63 THeader = packed record
64 Ident: array[0..$13] of Byte;
65 Files: Integer;
66 NamedFiles: Integer;
67 Extensions: Integer;
68 DataAddr: Integer;
69 DataSize: Integer;
70 NamesAddr: Integer;
71 NamesSize: Integer;
72 Ident2: array[0..$F] of Byte;
73 end;
74 TFilesMap = array of packed record
75 Extension: array[0..$3] of Char;
76 DataAddr: Integer;
77 NameAddr: Integer;
78 FileSize: Integer;
79 FileType: LongWord;
80 end;
81 TNamedFilesMap = array of packed record
82 FileNumber: Integer;
83 blubb: Integer;
84 end;
[93]85const
86 header_ident1_pc: array[0..$13] of Byte =
87 ($1F, $27, $DC, $33, $DF, $BC, $03, $00, $31, $33, $52, $56, $40, $00,
88 $14, $00, $10, $00, $08, $00);
89 header_ident1_mac: array[0..$13] of Byte =
90 ($61, $30, $C1, $23, $DF, $BC, $03, $00, $31, $33, $52, $56, $40, $00,
91 $14, $00, $10, $00, $08, $00);
92 header_ident1_macbeta: array[0..$13] of Byte =
93 ($81, $11, $8D, $23, $DF, $BC, $03, $00, $31, $33, $52, $56, $40, $00,
94 $14, $00, $10, $00, $08, $00);
95 header_ident2: array[0..$F] of Byte =
96 ($99, $CF, $40, $00, $90, $4F, $63, $00, $F4, $55, $5F, $00, $90, $4F, $63, $00);
97var
[101]98 i: Integer;
99 header_pc, header_mac, header_macbeta: Boolean;
100 Fdat_header: THeader;
101 Fdat_filesmap: TFilesMap;
102 Fdat_namedfilesmap: TNamedFilesMap;
[93]103begin
104 FUnloadWhenUnused := True;
105 FDatOpened := False;
106 FRawOpened := False;
[101]107 Msg := SM_UnknownError;
[93]108 if not FileExists(DatFilename) then
109 begin
[101]110 Msg := SM_FileNotFound;
[93]111 Exit;
112 end;
113 FFileName := DatFilename;
114 Fdat_file := TFileStream.Create(FFileName, fmOpenRead);
115 Fdat_file.Read(Fdat_header, SizeOf(Fdat_header));
116 header_pc := True;
117 header_mac := True;
[101]118 header_macbeta := True;
[93]119 for i := 0 to High(Fdat_header.Ident) do
120 begin
[101]121// FLevelInfo.Ident[i] := Fdat_header.Ident[i];
[93]122 if Fdat_header.Ident[i] <> header_ident1_pc[i] then
123 header_pc := False;
124 if Fdat_header.Ident[i] <> header_ident1_mac[i] then
125 header_mac := False;
[101]126 if Fdat_header.Ident[i] <> header_ident1_macbeta[i] then
127 header_macbeta := False;
[93]128 end;
[101]129 if not (header_pc xor header_mac xor header_macbeta) then
[93]130 begin
[101]131 Msg := SM_IncompatibleFile;
[93]132 Exit;
133 end
134 else
135 begin
[101]136 if (header_pc and not header_mac and not header_macbeta) then
137 FDataOS := DOS_WIN
138 else if (not header_pc and header_mac and not header_macbeta) then
139 FDataOS := DOS_MAC
140 else if (not header_pc and not header_mac and header_macbeta) then
141 FDataOS := DOS_MACBETA;
[93]142 end;
143 SetLength(Fdat_filesmap, Fdat_header.Files);
144 SetLength(Fdat_files, Fdat_header.Files);
145 for i := 0 to Fdat_header.Files - 1 do
146 Fdat_file.Read(Fdat_filesmap[i], SizeOf(Fdat_filesmap[i]));
147 for i := 0 to Fdat_header.Files - 1 do
148 begin
149 Fdat_files[i].ID := i;
150 Fdat_files[i].Extension := Fdat_filesmap[i].Extension;
151 Fdat_files[i].Extension := ReverseString(Fdat_files[i].Extension);
152 Fdat_files[i].Size := Fdat_filesmap[i].FileSize;
153 Fdat_files[i].FileType := Fdat_filesmap[i].FileType;
154 Fdat_files[i].DatAddr := Fdat_filesmap[i].DataAddr - 8 + Fdat_header.DataAddr;
155 if (Fdat_filesmap[i].FileType and $01) = 0 then
156 begin
157 Fdat_file.Seek(Fdat_filesmap[i].NameAddr + Fdat_header.NamesAddr, soFromBeginning);
158 SetLength(Fdat_files[i].Name, 100);
159 Fdat_file.Read(Fdat_files[i].Name[1], 100);
160 Fdat_files[i].Name := MidStr(Fdat_files[i].Name, 1 + 4, Pos(
161 #0, Fdat_files[i].Name) - 1 - 4);
162 end
163 else
164 begin
165 Fdat_files[i].Name := '';
166 end;
167 end;
168 Fdat_file.Seek($40 + Fdat_header.Files * $14, soFromBeginning);
169 SetLength(Fdat_namedfilesmap, Fdat_header.NamedFiles);
170 for i := 0 to Fdat_header.NamedFiles - 1 do
171 Fdat_file.Read(Fdat_namedfilesmap[i], SizeOf(Fdat_namedfilesmap[i]));
172
173 Fdat_file.Seek($40 + Fdat_header.Files * $14 + Fdat_header.NamedFiles * $8, soFromBeginning);
174 SetLength(Fdat_extensionsmap, Fdat_header.Extensions);
175 for i := 0 to Fdat_header.Extensions - 1 do
176 Fdat_file.Read(Fdat_extensionsmap[i], SizeOf(Fdat_extensionsmap[i]));
177
178 Fdat_file.Seek(Fdat_files[0].DatAddr + 7, soFromBeginning);
[101]179 Fdat_file.Read(FLevelNumber, 1);
180 FLevelNumber := FLevelNumber div 2;
[93]181
182 Fdat_file.Free;
183
[101]184 Msg := SM_OK;
185 FBackend := DB_ONI;
186 FChangeRights := [CR_EditDat, CR_EditRaw, CR_AppendRaw];
[93]187end;
188
189
190
191
[101]192procedure TAccess_OniArchive.Close;
[93]193begin
[101]194 if FDatOpened then
[93]195 Fdat_file.Free;
[101]196 if FRawOpened then
[93]197 Fraw_file.Free;
[101]198 if FSepOpened then
[93]199 Fsep_file.Free;
200 Self.Free;
201end;
202
203
204
205
[101]206function TAccess_OniArchive.GetFileInfo(fileid: Integer): TFileInfo;
[93]207begin
208 if fileid = -1 then
209 begin
210 Result := inherited GetFileInfo(fileid);
211 Exit;
212 end;
[101]213 if fileid < Self.GetFileCount then
[93]214 Result := Fdat_files[fileid]
215 else
216 Result.ID := -1;
217end;
218
219
220
221
[101]222function TAccess_OniArchive.GetFilesList(ext: String; pattern: String;
223 NoEmptyFiles: Boolean; SortType: TSortType): TStrings;
[93]224var
[101]225 i: Integer;
226 list: TStringList;
[93]227 id, name, extension: String;
228 fields: TStrings;
229
230 procedure getfields;
231 begin
[101]232 fields.CommaText := StringReplace(AnsiQuotedStr(list.Strings[i], '"'), ';', '","', [rfReplaceAll]);
233 if SortType in [ST_IDAsc, ST_IDDesc] then
[93]234 begin
235 id := fields.Strings[0];
236 name := fields.Strings[1];
237 extension := fields.Strings[2];
238 end;
[101]239 if SortType in [ST_NameAsc, ST_NameDesc] then
[93]240 begin
241 id := fields.Strings[1];
242 name := fields.Strings[0];
243 extension := fields.Strings[2];
244 end;
[101]245 if SortType in [ST_ExtAsc, ST_ExtDesc] then
[93]246 begin
247 id := fields.Strings[1];
248 name := fields.Strings[2];
249 extension := fields.Strings[0];
250 end;
251 end;
252
253begin
254 list := TStringList.Create;
255 list.Sorted := True;
[101]256 for i := 0 to GetFileCount - 1 do
[93]257 begin
258 if ((Length(ext) = 0) or (Pos(Fdat_files[i].Extension, ext) > 0)) and
259 ((Length(pattern) = 0) or
260 (Pos(UpperCase(pattern), UpperCase(Fdat_files[i].Name)) > 0)) then
261 begin
262 if (NoEmptyFiles = False) or ((Fdat_files[i].FileType and $02) = 0) then
263 begin
264 if AppSettings.FilenumbersAsHex then
265 id := IntToHex(Fdat_files[i].ID, 4)
266 else
267 id := FormatNumber(Fdat_files[i].ID, 5, '0');
268 name := Fdat_files[i].Name;
269 extension := Fdat_files[i].Extension;
270
[101]271 case SortType of
272 ST_IDAsc, ST_IDDesc: list.Add(id + ';' + name + ';' + extension);
273 ST_NameAsc, ST_NameDesc: list.Add(name + ';' + id + ';' + extension);
274 ST_ExtAsc, ST_ExtDesc: list.Add(extension + ';' + id + ';' + name);
[93]275 end;
276 end;
277 end;
278 end;
[101]279 Result := TStringList.Create;
280 if list.Count > 0 then
[93]281 begin
282 fields := TStringList.Create;
[101]283 if SortType in [ST_IDAsc, ST_NameAsc, ST_ExtAsc] then
[93]284 for i := 0 to list.Count - 1 do
285 begin
286 getfields;
[101]287 Result.Add(id + '-' + name + '.' + extension);
[93]288 end
289 else
290 for i := list.Count - 1 downto 0 do
291 begin
292 getfields;
[101]293 Result.Add(id + '-' + name + '.' + extension);
[93]294 end;
295 fields.Free;
296 end;
297 list.Free;
298end;
299
300
301
302
[101]303function TAccess_OniArchive.GetFileCount: Integer;
[93]304begin
[101]305 Result := Length(Fdat_files);
[93]306end;
307
308
309
310
[101]311function TAccess_OniArchive.GetExtensionsList(ExtListFormat: TExtensionFormat): TStrings;
[93]312var
[101]313 i: Integer;
[93]314begin
[101]315 Result := TStringList.Create;
316 for i := 0 to Length(Fdat_extensionsmap) - 1 do
[93]317 begin
318 with Fdat_extensionsmap[i] do
319 begin
[101]320 case ExtListFormat of
321 EF_ExtOnly:
322 Result.Add(Extension[3] + Extension[2] + Extension[1] + Extension[0]);
323 EF_ExtCount:
324 Result.Add(Extension[3] + Extension[2] + Extension[1] + Extension[0] +
325 ' (' + IntToStr(ExtCount) + ')');
326 end;
[93]327 end;
328 end;
329end;
330
331
332
[101]333procedure TAccess_OniArchive.LoadDatFile(FileID: Integer; var Target: TStream);
[93]334var
[101]335 streampos: Integer;
[93]336begin
[101]337 if fileid < GetFileCount then
[93]338 begin
[101]339 if not Assigned(Target) then
340 Target := TMemoryStream.Create;
341 if not FDatOpened then
[93]342 Fdat_file := TFileStream.Create(FFileName, fmOpenReadWrite);
343 Fdat_file.Seek(Fdat_files[fileid].DatAddr, soFromBeginning);
[101]344 streampos := Target.Position;
345 Target.CopyFrom(Fdat_file, Fdat_files[fileid].Size);
346 Target.Seek(streampos, soFromBeginning);
[93]347 if UnloadWhenUnused then
[101]348 begin
349 Fdat_file.Free;
350 FDatOpened := False;
351 end
[93]352 else
353 FDatOpened := True;
354 end;
355end;
356
[101]357procedure TAccess_OniArchive.UpdateDatFile(FileID: Integer; Src: TStream);
[93]358begin
[101]359 if fileid < GetFileCount then
[93]360 begin
[101]361 if not FDatOpened then
[93]362 Fdat_file := TFileStream.Create(FFileName, fmOpenReadWrite);
363 Fdat_file.Seek(Fdat_files[fileid].DatAddr, soFromBeginning);
[101]364 Fdat_file.CopyFrom(Src, Fdat_files[fileid].Size);
[93]365 if UnloadWhenUnused then
[101]366 begin
367 Fdat_file.Free;
368 FDatOpened := False;
369 end
[93]370 else
371 FDatOpened := True;
372 end;
373end;
374
[101]375procedure TAccess_OniArchive.LoadDatFilePart(FileID, Offset, Size: Integer; var Target: TStream);
376var
377 streampos: Integer;
[93]378begin
[101]379 if fileid < GetFileCount then
[93]380 begin
[101]381 if not Assigned(Target) then
382 Target := TMemoryStream.Create;
383 if not FDatOpened then
[93]384 Fdat_file := TFileStream.Create(FFileName, fmOpenReadWrite);
385 Fdat_file.Seek(Fdat_files[fileid].DatAddr + offset, soFromBeginning);
[101]386 streampos := Target.Position;
387 Target.CopyFrom(Fdat_file, size);
388 Target.Seek(streampos, soFromBeginning);
[93]389 if UnloadWhenUnused then
[101]390 begin
391 FDatOpened := False;
392 Fdat_file.Free;
393 end
[93]394 else
395 FDatOpened := True;
396 end;
397end;
398
[101]399procedure TAccess_OniArchive.UpdateDatFilePart(FileID, Offset, Size: Integer; Src: TStream);
[93]400begin
[101]401 if fileid < GetFileCount then
[93]402 begin
[101]403 if not FDatOpened then
[93]404 Fdat_file := TFileStream.Create(FFileName, fmOpenReadWrite);
405 Fdat_file.Seek(Fdat_files[fileid].DatAddr + offset, soFromBeginning);
[101]406 Fdat_file.CopyFrom(Src, Size);
[93]407 if UnloadWhenUnused then
[101]408 begin
409 Fdat_file.Free;
410 FDatOpened := False;
411 end
[93]412 else
413 FDatOpened := True;
414 end;
415end;
416
417
418
[101]419function TAccess_OniArchive.GetRawList(FileID: Integer): TRawDataList;
420begin
421 Result := RawLists.GetRawList(FConnectionID, FileID);
422end;
[93]423
[101]424
425function TAccess_OniArchive.GetRawInfo(FileID, DatOffset: Integer): TRawDataInfo;
[93]426begin
[101]427 Result := RawLists.GetRawInfo(FConnectionID, FileID, DatOffset);
[93]428end;
429
430
431
432
[101]433procedure TAccess_OniArchive.LoadRawOffset(LocSep: Boolean; RawAddr, Size: Integer; target: Pointer);
[93]434begin
[101]435 if not LocSep then
[93]436 begin
[101]437 if not FRawOpened then
[93]438 Fraw_file := TFileStream.Create(AnsiReplaceStr(FFileName, '.dat', '.raw'),
439 fmOpenReadWrite);
[101]440 if RawAddr <= Fraw_file.Size then
[93]441 begin
[101]442 Fraw_file.Seek(RawAddr, soFromBeginning);
[93]443 Fraw_file.Read(target^, size);
444 end;
445 if UnloadWhenUnused then
[101]446 begin
447 FRawOpened := False;
448 Fraw_file.Free;
449 end
[93]450 else
451 FRawOpened := True;
452 end
453 else
454 begin
[101]455 if not FSepOpened then
[93]456 Fsep_file := TFileStream.Create(AnsiReplaceStr(FFileName, '.dat', '.sep'),
457 fmOpenReadWrite);
[101]458 if RawAddr <= Fsep_file.Size then
[93]459 begin
[101]460 Fsep_file.Seek(RawAddr, soFromBeginning);
[93]461 Fsep_file.Read(target^, size);
462 end;
463 if UnloadWhenUnused then
[101]464 begin
465 FSepOpened := False;
466 Fsep_file.Free;
467 end
[93]468 else
469 FSepOpened := True;
470 end;
471end;
472
[101]473procedure TAccess_OniArchive.LoadRawFile(FileID, DatOffset: Integer; var Target: TStream);
[93]474var
[101]475 raw_info: TRawDataInfo;
476 streampos: Integer;
[93]477begin
[101]478 if not Assigned(Target) then
479 Target := TMemoryStream.Create;
480 if fileid < GetFileCount then
[93]481 begin
[101]482 raw_info := Self.GetRawInfo(FileID, DatOffset);
483 if not raw_info.LocSep then
[93]484 begin
[101]485 if not FRawOpened then
[93]486 Fraw_file := TFileStream.Create(AnsiReplaceStr(FFileName, '.dat', '.raw'),
487 fmOpenReadWrite);
[101]488 Fraw_file.Seek(raw_info.RawAddr, soFromBeginning);
489 streampos := Target.Position;
490 Target.CopyFrom(Fraw_file, raw_info.RawSize);
491 Target.Seek(streampos, soFromBeginning);
[93]492 if UnloadWhenUnused then
[101]493 begin
494 FRawOpened := False;
495 Fraw_file.Free;
496 end
[93]497 else
498 FRawOpened := True;
499 end
500 else
501 begin
502 if FUnloadWhenUnused or not FSepOpened then
503 Fsep_file := TFileStream.Create(AnsiReplaceStr(FFileName, '.dat', '.sep'),
504 fmOpenReadWrite);
[101]505 Fsep_file.Seek(raw_info.RawAddr, soFromBeginning);
506 streampos := Target.Position;
507 Target.CopyFrom(Fsep_file, raw_info.RawSize);
508 Target.Seek(streampos, soFromBeginning);
[93]509 if UnloadWhenUnused then
[101]510 begin
511 FSepOpened := False;
512 Fsep_file.Free;
513 end
[93]514 else
515 FSepOpened := True;
516 end;
517 end;
518end;
519
[101]520procedure TAccess_OniArchive.UpdateRawFile(FileID, DatOffset: Integer; Src: TStream);
[93]521var
[101]522 raw_info: TRawDataInfo;
[93]523begin
[101]524 if fileid < GetFileCount then
[93]525 begin
[101]526 raw_info := GetRawInfo(FileID, DatOffset);
527 if not raw_info.LocSep then
[93]528 begin
[101]529 if not FRawOpened then
[93]530 Fraw_file := TFileStream.Create(AnsiReplaceStr(FFileName, '.dat', '.raw'),
531 fmOpenReadWrite);
[101]532 Fraw_file.Seek(raw_info.RawAddr, soFromBeginning);
533 Fraw_file.CopyFrom(Src, raw_info.RawSize);
[93]534 if UnloadWhenUnused then
[101]535 begin
536 FRawOpened := False;
537 Fraw_file.Free;
538 end
[93]539 else
540 FRawOpened := True;
541 end
542 else
543 begin
[101]544 if not FSepOpened then
[93]545 Fsep_file := TFileStream.Create(AnsiReplaceStr(FFileName, '.dat', '.sep'),
546 fmOpenReadWrite);
[101]547 Fsep_file.Seek(raw_info.RawAddr, soFromBeginning);
548 Fsep_file.CopyFrom(Src, raw_info.RawSize);
[93]549 if UnloadWhenUnused then
[101]550 begin
551 FSepOpened := False;
552 Fsep_file.Free;
553 end
[93]554 else
555 FSepOpened := True;
556 end;
557 end;
558end;
559
[101]560procedure TAccess_OniArchive.LoadRawFilePart(FileID, DatOffset, Offset, Size: Integer; var Target: TStream);
[93]561var
[101]562 Data: TStream;
563 streampos: Integer;
[93]564begin
[101]565 if not Assigned(Target) then
566 Target := TMemoryStream.Create;
567 if fileid < Self.GetFileCount then
[93]568 begin
[101]569 data := nil;
570 LoadRawFile(FileID, DatOffset, Data);
571 Data.Seek(Offset, soFromBeginning);
572 streampos := Target.Position;
573 Target.CopyFrom(Data, Size);
574 Target.Seek(streampos, soFromBeginning);
[93]575 end;
576end;
577
[101]578procedure TAccess_OniArchive.UpdateRawFilePart(FileID, DatOffset, Offset, Size: Integer; Src: TStream);
[93]579var
[101]580 raw_info: TRawDataInfo;
[93]581begin
[101]582 if fileid < GetFileCount then
[93]583 begin
[101]584 raw_info := GetRawInfo(FileID, DatOffset);
585 if not raw_info.LocSep then
[93]586 begin
[101]587 if not FRawOpened then
[93]588 Fraw_file := TFileStream.Create(AnsiReplaceStr(FFileName, '.dat', '.raw'),
589 fmOpenReadWrite);
[101]590 Fraw_file.Seek(raw_info.RawAddr + Offset, soFromBeginning);
591 Fraw_file.CopyFrom(Src, Size);
[93]592 if UnloadWhenUnused then
[101]593 begin
594 FRawOpened := False;
595 Fraw_file.Free;
596 end
[93]597 else
598 FRawOpened := True;
599 end
600 else
601 begin
[101]602 if not FSepOpened then
[93]603 Fsep_file := TFileStream.Create(AnsiReplaceStr(FFileName, '.dat', '.sep'),
604 fmOpenReadWrite);
[101]605 Fsep_file.Seek(raw_info.RawAddr + Offset, soFromBeginning);
606 Fsep_file.CopyFrom(Src, Size);
[93]607 if UnloadWhenUnused then
[101]608 begin
609 FSepOpened := False;
610 Fsep_file.Free;
611 end
[93]612 else
613 FSepOpened := True;
614 end;
615 end;
616end;
617
[101]618function TAccess_OniArchive.AppendRawFile(LocSep: Boolean; Size: Integer; Src: TStream): Integer;
[93]619begin
[101]620 if not LocSep then
[93]621 begin
[101]622 if not FRawOpened then
[93]623 Fraw_file := TFileStream.Create(AnsiReplaceStr(FFileName, '.dat', '.raw'),
624 fmOpenReadWrite);
625 Result := Fraw_file.Size;
626 Fraw_file.Seek(0, soFromEnd);
[101]627 Fraw_file.CopyFrom(Src, Size);
[93]628 if UnloadWhenUnused then
[101]629 begin
630 FRawOpened := False;
631 Fraw_file.Free;
632 end
[93]633 else
634 FRawOpened := True;
635 end
636 else
637 begin
[101]638 if not FSepOpened then
[93]639 Fsep_file := TFileStream.Create(AnsiReplaceStr(FFileName, '.dat', '.sep'),
640 fmOpenReadWrite);
641 Result := Fsep_file.Size;
642 Fsep_file.Seek(0, soFromEnd);
[101]643 Fsep_file.CopyFrom(Src, Size);
[93]644 if UnloadWhenUnused then
[101]645 begin
646 FSepOpened := False;
647 Fsep_file.Free;
648 end
[93]649 else
650 FSepOpened := True;
651 end;
652end;
653
654end.
Note: See TracBrowser for help on using the repository browser.