Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.programming > #2990 > unrolled thread
| Started by | aminer <aminer@toto.ca> |
|---|---|
| First post | 2013-02-09 15:36 -0800 |
| Last post | 2013-02-09 16:04 -0800 |
| Articles | 4 — 1 participant |
Back to article view | Back to comp.programming
About the zipfile component... aminer <aminer@toto.ca> - 2013-02-09 15:36 -0800
Re: About the zipfile component... aminer <aminer@toto.ca> - 2013-02-09 15:36 -0800
Re: About the zipfile component... aminer <aminer@toto.ca> - 2013-02-09 15:57 -0800
Re: About the zipfile component... aminer <aminer@toto.ca> - 2013-02-09 16:04 -0800
| From | aminer <aminer@toto.ca> |
|---|---|
| Date | 2013-02-09 15:36 -0800 |
| Subject | About the zipfile component... |
| Message-ID | <kf6btj$r5l$7@dont-email.me> |
...
[toc] | [next] | [standalone]
| From | aminer <aminer@toto.ca> |
|---|---|
| Date | 2013-02-09 15:36 -0800 |
| Message-ID | <kf6buh$r5l$9@dont-email.me> |
| In reply to | #2990 |
Hello,
We have to be carrefull about Object pascal ccomponents,
for exemple look at the following source code called zipfile:
https://modelbuilder.svn.sourceforge.net/svnroot/modelbuilder/src/trunk/mcl/zipfile/zipfile.pas
First:
In the AppendStream() he is compressing directly
to the memory and that's not good, he must copy the data directly
to the filestream, that's a more optimized method to not use a lot
of memory.
Second:
As you will notice this zipfile component is not Fault tolerant to power
failures etc so what will happen if there is a power failure
and the zip file is corrupt ? your zipfile and data will be lost, and
that's not good, so he must redesign his component to be fault tolerant..
Look at the LoadFromStream method of my ParallelVarFiler source code
here: http://pages.videotron.com/aminer/
Here it is:
==
function TParallelVarFiler.LoadFromStream(Stream : TStream):boolean;
var
VR : PScwVarRecord;
str:string;
a:integer;
delbit:byte;
pos:integer;
Begin
result:=true;
Clear;
Try
While Stream.Position < Stream.Size do
Begin
pos:=stream.position;
New(VR);
Stream.Read(delbit, SizeOf(byte));
Stream.Read(a, SizeOf(integer)); // Name length
SetLength(str, a); // Get memory to the Name
Stream.Read(Pointer(str)^, a); // Name
Stream.Read(VR^.T, SizeOf(VR^.T)); // Variable Type
if (Stream.size-Stream.position)<sizeof(VR^.SL)
then
begin
dispose(VR);
setlength(str,0);
Stream.size:=pos;
result:=false;
exit;
end;
Stream.Read(VR^.SL, SizeOf(VR^.SL)); // Variable Length
if delbit=1
then
begin
if (Stream.size-Stream.position)<VR^.SL
then
begin
dispose(VR);
setlength(str,0);
Stream.size:=pos;
result:=false;
exit;
end;
SetLength(VR^.S, VR^.SL); // Get memory to the
variable
Stream.Read(Pointer(VR^.S)^, VR^.SL); // Variable
hash1.add(str,pointer(vr));
end
else
begin
Stream.position:=Stream.position+VR^.SL;
setLength(str, 0);
dispose(VR);
end;
End;
Except
setlength(str,0);
VR^.s:='';
dispose(VR);
result:=false;
//Stream.size:=pos;
Clear;
End;
End;
==
As you will notice this LoadFromStream() method
brings Fault toleracy to ParallelVarFiler , so it's
fault tolerant to power failure etc. and i think that
the zipfile component must use something like that,
cause Fault tolerancy is very important.
Thank you,
Amine Moulay Ramdane.
[toc] | [prev] | [next] | [standalone]
| From | aminer <aminer@toto.ca> |
|---|---|
| Date | 2013-02-09 15:57 -0800 |
| Message-ID | <kf6d5p$3t5$1@dont-email.me> |
| In reply to | #2991 |
Hello, Question: And how this zipfile component can be fault tolerant ? Answer: Every time you add a file to the zipfile , your must for example use the same method that is using my ParallelVarFiler and verify for example the last file copied to see if it was copied correctly, and if the last file was corrupted you will delete the last file, you must not scan all the files like is doing ParallelVarFiler, just the last file copied to the zip file. And this is how you can bring fault tolerancy to your zip archiver. Thank you, Amine Moulay Ramdane/
[toc] | [prev] | [next] | [standalone]
| From | aminer <aminer@toto.ca> |
|---|---|
| Date | 2013-02-09 16:04 -0800 |
| Message-ID | <kf6dis$6tu$1@dont-email.me> |
| In reply to | #2991 |
Hello, If i have sometime i will implement an archiver that uses my parallel compression library and that will be fault tolerant also and that will support files larger than 4Gb . It will be better than the zipfile component. That's my next project in my list. Thank you, Amine Moulay Ramdane.
[toc] | [prev] | [standalone]
Back to top | Article view | comp.programming
csiph-web