BAD CRC vorab prüfen?
-
Freitag, 15. Juni 2012 08:35
Hallo @all
wir erstellen relativ viele ZIP Dateien zum Datenaustausch.
Leider kommt es immer wieder vor, dass verschiedene Dateien beim Entpacken einen CRC Fehler aufweisen.Gibt es ein Tool / algo. / FLL mit dem ich die CRC Prüfung vorab durchführen kann, ohne die Komplette ZIP Datei entpacken zu müssen?
Any Tipp wanted ;)
Grüße
Jörg Schneier
Jörg Schneider
Alle Antworten
-
Freitag, 15. Juni 2012 09:25
Hallo Jörg,
ich vermute mal, dass die CRC der unkomprimierten Datei gespeichert ist und man deshalb über ein komplettes Entpacken, wenn auch ohne Speicherung, nicht drum rum kommt.
Aber wieso kommt es überhaupt zu den Fehlern? Ich mache auch viel ZIP-Datenaustausch und hab den Fehler nur im Zusammenhang mit USB-Sticks ohne "sicheres Auswerfen" gehabt und deshalb inzwischen diese Auswurffunktion auch im Programm.
Gruß,
Winfried
-
Freitag, 15. Juni 2012 09:41
Was dagegen doch wohl greifen sollte, wäre eine CRC der Zip-Datei selbst. Vielleicht auch eher das übliche MD5 oder PGP Signatur, natürlich dann separat gespeichert, man könnte das zwar dann auch noch nachträglich ins Archiv hinzufügen, aber das wird sich dann auch bei Entfernung der Datei aus dem ZIP wohl nicht wieder zum Originalzustand ändern.
Hast Du im Fall einer falschen CRC schon mal binärvergleich von Originaldatei und entpackter Datei gemacht? Sind die wirklich unterschiedlich, oder kriegt SYS(2007) nur unterschiedliche CRCs heraus?
Tschüß, Olaf.
-
Montag, 25. Juni 2012 10:12
Hallo,
Habe Dir schon im DFPUG Forum geantwortet ....
wie wäre es damit:
Quelle: http://www.chilkatsoft.com/p/p_512.asp
Private Sub Command15_Click()
Dim zip As New ChilkatZip2
Dim success As Long
success = zip.UnlockComponent("Anything for 30-day trial")
If (success <> 1) Then
MsgBox zip.LastErrorText
Exit Sub
End If
success = zip.NewZip("test.zip")
If (success <> 1) Then
MsgBox zip.LastErrorText
Exit Sub
End If
success = zip.AppendOneFileOrDir("hamlet.xml", 0)
If (success <> 1) Then
MsgBox zip.LastErrorText
Exit Sub
End If
' Write the .zip, but don't close it because we're still going to use it...
success = zip.WriteZip()
If (success <> 1) Then
MsgBox zip.LastErrorText
Exit Sub
End If
' Now we'll compare the CRC stored within the .zip for hamlet.xml against
' a CRC computed by reading hamlet.xml directly. First, get the zip entry object
' for hamlet.xml and access the Crc property:
Dim crcFromZip As Long
Dim entry As ChilkatZipEntry2
Set entry = zip.GetEntryByName("hamlet.xml")
crcFromZip = entry.Crc
' The ChilkatZipCrc is used for calculating CRC's from data or files
' The FileCrc method calculates the CRC by reading a file.
Dim crcCalculator As New ChilkatZipCrc
crcFromFile = crcCalculator.FileCrc("hamlet.xml")
' Compare the CRC's, they should be equal:
If (crcFromFile <> crcFromZip) Then
MsgBox "CRC's are not equal!"
Else
MsgBox "CRC's are equal: " & Str(crcFromFile)
End If
End Sub
Gruss
jk -
Montag, 2. Juli 2012 07:50

