forked from edivando-fpc/BGRABitmap
-
Notifications
You must be signed in to change notification settings - Fork 5
/
bgramemdirectory.pas
634 lines (564 loc) · 20 KB
/
bgramemdirectory.pas
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
{ ***************************************************************************
* *
* This file is part of BGRABitmap library which is distributed under the *
* modified LGPL. *
* *
* See the file COPYING.modifiedLGPL.txt, included in this distribution, *
* for details about the copyright. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. *
* *
************************* BGRABitmap library ******************************
- Drawing routines with transparency and antialiasing with Lazarus.
Offers also various transforms.
- These routines allow to manipulate 32bit images in BGRA format or RGBA
format (depending on the platform).
- This code is under modified LGPL (see COPYING.modifiedLGPL.txt).
This means that you can link this library inside your programs for any purpose.
Only the included part of the code must remain LGPL.
- If you make some improvements to this library, please notify here:
http://www.lazarus.freepascal.org/index.php/topic,12037.0.html
********************* Contact : Circular at operamail.com *******************
******************************* CONTRIBUTOR(S) ******************************
- Edivando S. Santos Brasil | [email protected]
(Compatibility with FPC ($Mode objfpc/delphi) and delphi VCL 11/2018)
***************************** END CONTRIBUTOR(S) *****************************}
Unit BGRAMemDirectory;
{$i bgrabitmap.inc}{$H+}
interface
uses
Classes, SysUtils, BGRATypes,{$IFNDEF FPC}Types, GraphType, BGRAGraphics,{$ENDIF} BGRAMultiFileType, {$IFDEF OBJ}fgl{$ELSE}generics.collections{$ENDIF};
const
MemDirectoryFileHeader = 'TMemDirectory'#26#0#0;
MemDirectoryEntry_FlagDirectory = 1; //entry is a directory
MemDirectoryEntry_FlagCompressed = 2; //the stream is compressed
MemDirectoryEntry_FlagSmallEntryPacked = $8000; //name and size <= 255
type
TMemDirectory = class;
TEntryFilename = BGRAMultiFileType.TEntryFilename;
//type
TMemDirectoryPath = {$IFDEF OBJ}specialize TFPGList{$ELSE}TList{$ENDIF}<TEntryFilename>;
{ TMemDirectoryEntry }
TMemDirectoryEntry = class(TMultiFileEntry)
private
FStream: TStream;
function GetIsCompressed: boolean;
function GetCompressedSize: BGRAInt64;
function GetIsDirectory: boolean;
procedure SetIsCompressed(AValue: boolean);
constructor Create(AContainer: TMultiFileContainer; AFilename: TEntryFilename; AStream: TStream; AOwnStream: boolean; AUncompressedSize: BGRAInt64; AFlags: BGRAWord);overload;
procedure LoadExtraFromEmbeddedStream(ADataStream: TStream; AStartPos: BGRAInt64);
procedure SaveToEmbeddedStream(AEntryStream, ADataStream: TStream; AStartPos: BGRAInt64; out uncompressedSize: BGRAInt64);
protected
FFlags: BGRAWord;
FName,FExtension: utf8String;
FUncompressedSize: BGRAInt64;
FEmbeddedStreamPos: BGRAInt64;
FMemDirectory: TMemDirectory;
function GetName: utf8string; override;
procedure SetName(AValue: utf8string); override;
function GetFileSize: BGRAInt64; override;
function GetExtension: utf8string; override;
function InternalCopyTo({%H-}ADestination: TStream): BGRAInt64;
public
function CopyTo({%H-}ADestination: TStream): BGRAInt64; override;
constructor Create(AContainer: TMultiFileContainer; AFilename: TEntryFilename; AUncompressedStream: TStream; AOwnStream: boolean);overload;
constructor CreateDirectory(AContainer: TMultiFileContainer; AFilename: TEntryFilename);
destructor Destroy; override;
property EmbeddedStreamPos: BGRAInt64 read FEmbeddedStreamPos write FEmbeddedStreamPos;
property IsCompressed: boolean read GetIsCompressed write SetIsCompressed;
property IsDirectory: boolean read GetIsDirectory;
property CompressedSize: BGRAInt64 read GetCompressedSize;
property Flags: BGRAWord read FFlags;
property MemDirectory: TMemDirectory read FMemDirectory;
end;
TMemDirectory = class(TMultiFileContainer)
private
FParentDirectory: TMemDirectory;
function GetEntryCompressed(AIndex: integer): boolean;
function GetIsDirectory(AIndex: integer): boolean;
function GetDirectory(AIndex: integer): TMemDirectory;
procedure SetEntryCompressed(AIndex: integer; AValue: boolean);
protected
function CreateEntry(AName: utf8string; AExtension: utf8string; AContent: TStream): TMultiFileEntry; override;
function SplitPath(APath: utf8string): TMemDirectoryPath;
public
constructor Create(AParentDirectory: TMemDirectory = nil);
procedure LoadFromStream(AStream: TStream); override;
procedure LoadFromEmbeddedStream(ARootStream, ADataStream: TStream; AStartPos: BGRAInt64);
procedure SaveToStream(ADestination: TStream); override;
procedure SaveToEmbeddedStream(ARootDest, ADataDest: TStream; AStartPos: BGRAInt64);
function AddDirectory(AName: utf8string; AExtension: utf8string= ''; ACaseSensitive: boolean= true): integer;
function FindPath(APath: utf8String; ACaseSensitive: boolean = true): TMemDirectory;
function FindEntry(APath: utf8String; ACaseSensitive: boolean = true): TMemDirectoryEntry;
property IsEntryCompressed[AIndex: integer]: boolean read GetEntryCompressed write SetEntryCompressed;
property Directory[AIndex: integer]: TMemDirectory read GetDirectory;
property IsDirectory[AIndex: integer]: boolean read GetIsDirectory;
property ParentDirectory: TMemDirectory read FParentDirectory;
end;
implementation
uses zstream, BGRAUTF8, strutils;
type
TDirEntryRecord = packed record
Flags: BGRAWord;
FilenameSize: BGRAWord;
Offset: BGRAInt64;
end;
{ TMemDirectory }
function TMemDirectory.GetEntryCompressed(AIndex: integer): boolean;
begin
result := (Entry[AIndex] as TMemDirectoryEntry).IsCompressed;
end;
function TMemDirectory.GetIsDirectory(AIndex: integer): boolean;
begin
result := (Entry[AIndex] as TMemDirectoryEntry).IsDirectory;
end;
function TMemDirectory.GetDirectory(AIndex: integer): TMemDirectory;
begin
result := (Entry[AIndex] as TMemDirectoryEntry).MemDirectory;
end;
procedure TMemDirectory.SetEntryCompressed(AIndex: integer; AValue: boolean);
begin
(Entry[AIndex] as TMemDirectoryEntry).IsCompressed := AValue;
end;
function TMemDirectory.CreateEntry(AName: utf8string; AExtension: utf8string;
AContent: TStream): TMultiFileEntry;
begin
result := TMemDirectoryEntry.Create(self, EntryFilename(AName, AExtension), AContent, true);
end;
procedure TMemDirectory.LoadFromStream(AStream: TStream);
var rootPos, rootSize: integer;
header: string;
rootStream: TStream;
startPos: BGRAInt64;
begin
startPos := AStream.Position;
setlength(header, length(MemDirectoryFileHeader));
AStream.ReadBuffer(header[1], length(header));
if header<>MemDirectoryFileHeader then
raise exception.Create('Invalid header');
rootPos := LEReadInt64(AStream);
if rootPos = 0 then
raise exception.Create('Invalid root offset');
rootSize := LEReadInt64(AStream);
if rootSize <= 4 then
raise exception.Create('Invalid root size');
AStream.Position:= rootPos + startPos;
rootStream:= TMemoryStream.Create;
try
rootStream.CopyFrom(AStream, rootSize);
LoadFromEmbeddedStream(rootStream, AStream, startPos);
finally
rootStream.Free;
end;
end;
procedure TMemDirectory.LoadFromEmbeddedStream(ARootStream, ADataStream: TStream;
AStartPos: BGRAInt64);
var
nbEntries,i: BGRALongInt;
entryRec: TDirEntryRecord;
filename: string;
entryData: TStream;
newEntry: TMemDirectoryEntry;
compressedSize, uncompressedSize: BGRAInt64;
begin
Clear;
ARootStream.Position := 0;
nbEntries := LEReadLongint(ARootStream);
for i := 1 to nbEntries do
begin
ARootStream.ReadBuffer({%H-}entryRec, sizeof(entryRec));
{$IFNDEF BDS}entryRec.Offset:= LEtoN(entryRec.Offset);{$ENDIF}
{$IFNDEF BDS}entryRec.Flags:= LEtoN(entryRec.Flags);{$ENDIF}
{$IFNDEF BDS}entryRec.FilenameSize:= LEtoN(entryRec.FilenameSize);{$ENDIF}
if (entryRec.Flags and MemDirectoryEntry_FlagSmallEntryPacked) <> 0 then
begin
entryRec.Flags := entryRec.Flags xor MemDirectoryEntry_FlagSmallEntryPacked;
compressedSize := entryRec.FilenameSize shr 8;
uncompressedSize := compressedSize;
entryRec.FilenameSize := entryRec.FilenameSize and 255;
end else
begin
compressedSize := LEReadInt64(ARootStream);
uncompressedSize := LEReadInt64(ARootStream);
end;
setlength(filename, entryRec.FilenameSize);
if length(filename)> 0 then
ARootStream.ReadBuffer(filename[1], entryRec.FilenameSize);
ADataStream.Position:= entryRec.Offset + AStartPos;
entryData := TMemoryStream.Create;
try
entryData.CopyFrom(ADataStream, compressedSize);
newEntry := TMemDirectoryEntry.Create(self, EntryFilename(filename), entryData, true,
uncompressedSize, entryRec.Flags);
newEntry.LoadExtraFromEmbeddedStream(ADataStream, AStartPos);
AddEntry(newEntry);
entryData := nil;
finally
entryData.Free;
end;
end;
end;
procedure TMemDirectory.SaveToStream(ADestination: TStream);
var rootPos,rootSize: integer;
header: string;
rootRecPos, startPos, endPos: BGRAInt64;
rootStream: TStream;
begin
startPos := ADestination.Position;
header := MemDirectoryFileHeader;
ADestination.WriteBuffer(header[1], length(header));
rootRecPos := ADestination.Position;
LEWriteInt64(ADestination,0); //root pos
LEWriteInt64(ADestination,0); //root size
rootStream := TMemoryStream.Create;
try
SaveToEmbeddedStream(rootStream, ADestination, startPos);
rootStream.Position := 0;
rootPos := ADestination.Position - startPos;
rootSize := rootStream.Size;
ADestination.CopyFrom(rootStream, rootStream.Size);
FreeAndNil(rootStream);
endPos := ADestination.Position;
ADestination.Position := rootRecPos;
LEWriteInt64(ADestination, rootPos);
LEWriteInt64(ADestination, rootSize);
ADestination.Position := endPos;
finally
rootStream.Free;
end;
end;
procedure TMemDirectory.SaveToEmbeddedStream(ARootDest, ADataDest: TStream;
AStartPos: BGRAInt64);
var
entryRec: TDirEntryRecord;
entryStream: TMemoryStream;
curEntry: TMemDirectoryEntry;
filename: string;
i: Integer;
uncompressedSize: BGRAInt64;
begin
LEWriteLongint(ARootDest, Count);
entryStream := TMemoryStream.Create;
try
for i := 0 to Count-1 do
begin
curEntry := Entry[i] as TMemDirectoryEntry;
entryStream.Clear;
curEntry.SaveToEmbeddedStream(entryStream, ADataDest, AStartPos, uncompressedSize);
entryRec.Offset:= ADataDest.Position - AStartPos;
{$IFNDEF BDS}entryRec.Offset:= NtoLE(entryRec.Offset);{$ENDIF}
if curEntry.Extension <> '' then
filename := curEntry.Name+'.'+curEntry.Extension
else
filename := curEntry.Name;
if ((curEntry.Flags and MemDirectoryEntry_FlagCompressed)=0) and
(Length(filename)<=255) and (entryStream.Size<=255) then
begin
entryRec.Flags:= curEntry.Flags or MemDirectoryEntry_FlagSmallEntryPacked;
{$IFNDEF BDS}entryRec.Flags:= NtoLE(entryRec.Flags);{$ENDIF}
entryRec.FilenameSize:= length(filename) + (entryStream.Size shl 8);
{$IFNDEF BDS}entryRec.FilenameSize := NtoLE(entryRec.FilenameSize);{$ENDIF}
ARootDest.WriteBuffer(entryRec, sizeof(entryRec));
end else
begin
entryRec.Flags:= curEntry.Flags;
{$IFNDEF BDS}entryRec.Flags:= NtoLE(entryRec.Flags);{$ENDIF}
entryRec.FilenameSize:= length(filename);
{$IFNDEF BDS}entryRec.FilenameSize := NtoLE(entryRec.FilenameSize);{$ENDIF}
ARootDest.WriteBuffer(entryRec, sizeof(entryRec));
LEWriteInt64(ARootDest, entryStream.Size);
LEWriteInt64(ARootDest, uncompressedSize);
end;
if filename <> '' then
ARootDest.WriteBuffer(filename[1], length(filename));
entryStream.Position:= 0;
ADataDest.CopyFrom(entryStream, entryStream.Size);
end;
finally
entryStream.Free;
end;
end;
function TMemDirectory.AddDirectory(AName: utf8string; AExtension: utf8string;
ACaseSensitive: boolean): integer;
var
newEntry: TMemDirectoryEntry;
begin
result := IndexOf(AName,AExtension,ACaseSensitive);
if result <> -1 then
begin
if not IsDirectory[result] then
raise exception.Create('There is already a file with this name and extension');
exit;
end;
newEntry := TMemDirectoryEntry.CreateDirectory(self, EntryFilename(AName, AExtension));
result := AddEntry(newEntry);
end;
function TMemDirectory.FindPath(APath: utf8String; ACaseSensitive: boolean): TMemDirectory;
var
path: TMemDirectoryPath;
idxPath: integer;
idxSub: BGRALongInt;
begin
path := SplitPath(APath);
result := self;
if path.Items[0].IsEmpty then
begin
idxPath := 1;
while Assigned(result.ParentDirectory) do result := result.ParentDirectory;
end
else
idxPath := 0;
while idxPath < path.Count do
begin
idxSub := result.IndexOf(path[idxPath], ACaseSensitive);
if idxSub= -1 then
begin
result := nil;
break;
end;
result := result.Directory[idxSub];
inc(idxPath);
end;
path.Free;
end;
function TMemDirectory.FindEntry(APath: utf8String; ACaseSensitive: boolean): TMemDirectoryEntry;
var
path: TMemDirectoryPath;
idxPath: integer;
idxSub, idxEntry: BGRALongInt;
curDir: TMemDirectory;
begin
path := SplitPath(APath);
curDir := self;
if path.Items[0].IsEmpty then
begin
idxPath := 1;
while Assigned(curDir.ParentDirectory) do curDir := curDir.ParentDirectory;
end
else
idxPath := 0;
while idxPath < path.Count-1 do
begin
idxSub := curDir.IndexOf(path[idxPath], ACaseSensitive);
if idxSub= -1 then
begin
curDir := nil;
break;
end;
curDir := curDir.Directory[idxSub];
inc(idxPath);
end;
if Assigned(curDir) and (idxPath < path.Count) then
begin
idxEntry := curDir.IndexOf(path[idxPath], ACaseSensitive);
if idxEntry = -1 then
result := nil
else
result := curDir.Entry[idxEntry] as TMemDirectoryEntry;
end
else
result := nil;
path.Free;
end;
function TMemDirectory.SplitPath(APath: utf8string): TMemDirectoryPath;
var idx,idxSlash: integer;
begin
result := TMemDirectoryPath.Create;
idx := 1;
repeat
idxSlash := PosEx('/',APath,idx);
if idxSlash = 0 then
begin
result.Add(EntryFilename(copy(APath, idx, length(APath)-idx+1)));
break;
end else
begin
result.Add(EntryFilename(copy(APath, idx, idxSlash-idx)));
idx := idxSlash+1;
end;
until false;
end;
constructor TMemDirectory.Create(AParentDirectory: TMemDirectory);
begin
inherited Create;
FParentDirectory := AParentDirectory;
end;
{ TMemDirectoryEntry }
function TMemDirectoryEntry.GetIsCompressed: boolean;
begin
result := (FFlags and MemDirectoryEntry_FlagCompressed) <> 0;
end;
function TMemDirectoryEntry.GetCompressedSize: BGRAInt64;
begin
if not IsDirectory and Assigned(FStream) then
result := FStream.Size
else
result := 0;
end;
function TMemDirectoryEntry.GetIsDirectory: boolean;
begin
result := (FFlags and MemDirectoryEntry_FlagDirectory) <> 0;
end;
procedure TMemDirectoryEntry.SetIsCompressed(AValue: boolean);
var compressedStream,decompressed: TMemoryStream;
compression: Tcompressionstream;
begin
if AValue = IsCompressed then exit;
if Assigned(FStream) then
begin
if AValue then //compress
begin
compressedStream := TMemoryStream.Create;
compression := nil;
try
compression := Tcompressionstream.create(cldefault, compressedStream, true);
FStream.Position := 0;
compression.CopyFrom(FStream,FStream.Size);
FStream.Free;
FStream := compressedStream;
compressedStream := nil;
FFlags := FFlags xor MemDirectoryEntry_FlagCompressed;
finally
compression.Free;
compressedStream.Free;
end;
end else
begin //decompress
decompressed := TMemoryStream.Create;
try
InternalCopyTo(decompressed);
FStream.Free;
FStream := decompressed;
decompressed := nil;
FFlags := FFlags xor MemDirectoryEntry_FlagCompressed;
finally
decompressed.Free;
end;
end;
end else
FFlags := FFlags xor MemDirectoryEntry_FlagCompressed;
end;
function TMemDirectoryEntry.GetName: utf8string;
begin
result := FName;
end;
procedure TMemDirectoryEntry.SetName(AValue: utf8string);
begin
while AValue[length(AValue)] = '.' do delete(AValue, length(AValue), 1);
FName := AValue;
end;
function TMemDirectoryEntry.GetFileSize: BGRAInt64;
begin
if IsDirectory then
result := 0
else
Result:= FUncompressedSize;
end;
function TMemDirectoryEntry.GetExtension: utf8string;
begin
Result:= FExtension;
end;
function TMemDirectoryEntry.InternalCopyTo(ADestination: TStream): BGRAInt64;
var
decomp: Tdecompressionstream;
begin
if not Assigned(FStream) then exit(0);
if IsCompressed then
begin
FStream.Position := 0;
decomp := Tdecompressionstream.Create(FStream,true);
try
result := ADestination.CopyFrom(decomp,FUncompressedSize);
finally
decomp.Free;
end;
end else
begin
FStream.Position := 0;
result := ADestination.CopyFrom(FStream, FStream.Size);
end;
end;
function TMemDirectoryEntry.CopyTo(ADestination: TStream): BGRAInt64;
begin
if IsDirectory then exit(0);
result := InternalCopyTo(ADestination);
end;
constructor TMemDirectoryEntry.Create(AContainer: TMultiFileContainer; AFilename: TEntryFilename;
AUncompressedStream: TStream; AOwnStream: boolean);
begin
inherited Create(AContainer);
Create(AContainer, AFilename, AUncompressedStream, AOwnStream, AUncompressedStream.Size, 0);
end;
constructor TMemDirectoryEntry.Create(AContainer: TMultiFileContainer; AFilename: TEntryFilename;
AStream: TStream; AOwnStream: boolean;
AUncompressedSize: BGRAInt64; AFlags: BGRAWord);
begin
inherited Create(AContainer);
Name := AFilename.Name;
FExtension:= AFilename.Extension;
if AOwnStream then
FStream := AStream
else
begin
FStream := TMemoryStream.Create;
AStream.Position:= 0;
FStream.CopyFrom(AStream, AStream.Size);
end;
FUncompressedSize:= AUncompressedSize;
FFlags:= AFlags;
FMemDirectory := nil;
end;
procedure TMemDirectoryEntry.SaveToEmbeddedStream(AEntryStream, ADataStream: TStream;
AStartPos: BGRAInt64; out uncompressedSize: BGRAInt64);
var
entryStartPos: BGRAInt64;
begin
if IsDirectory then
begin
if not Assigned(FMemDirectory) then
raise exception.Create('Directory not allocated');
FreeAndNil(FStream);
IsCompressed:= false;
entryStartPos := AEntryStream.Position;
FMemDirectory.SaveToEmbeddedStream(AEntryStream, ADataStream, AStartPos);
uncompressedSize:= AEntryStream.Position - entryStartPos;
end else
if Assigned(FStream) then
begin
FStream.Position:= 0;
AEntryStream.CopyFrom(FStream, FStream.Size);
uncompressedSize:= FUncompressedSize;
end;
end;
procedure TMemDirectoryEntry.LoadExtraFromEmbeddedStream(ADataStream: TStream;
AStartPos: BGRAInt64);
begin
if IsDirectory and Assigned(FStream) then
begin
IsCompressed:= false;
if not Assigned(FMemDirectory) then
FMemDirectory := TMemDirectory.Create(Container as TMemDirectory);
FMemDirectory.LoadFromEmbeddedStream(FStream, ADataStream, AStartPos);
FreeAndNil(FStream);
end;
end;
constructor TMemDirectoryEntry.CreateDirectory(AContainer: TMultiFileContainer;
AFilename: TEntryFilename);
begin
Name := AFilename.Name;
FExtension:= AFilename.Extension;
FStream := nil;
FUncompressedSize:= 0;
FFlags := MemDirectoryEntry_FlagDirectory;
FMemDirectory := TMemDirectory.Create(Container as TMemDirectory);
end;
destructor TMemDirectoryEntry.Destroy;
begin
FStream.Free;
FMemDirectory.Free;
inherited Destroy;
end;
end.