ZipForge 本机错误
我遇到问题的存档都是通过将工作存档与不存在的存档合并而创建的,从而有效地将一个存档的内容复制到另一个存档中。这是我们合并过程的一部分。就像这样......
ZipDestination := TZipForge.Create(nil);
if FileExists(DestinationZipFileName) then
ZipDestination.OpenArchive(fmOpenReadWrite + fmShareDenyWrite)
else
ZipDestination.OpenArchive(fmCreate);
ZipDestination.Zip64Mode := zmAuto;
ZipDestination.MergeWith(SourceZipFileName);
ZipDestination.CloseArchive;
这是从存档中获取 blob、解压缩它并使其准备好供查看者使用的代码。
CompressedStream := TMemoryStream.Create;
UnCompressedStream := TMemoryStream.Create;
GetCompressedStream(CompressedStream); // this fetches the blob from the zipfile
ZipForge.InMemory := True;
// Native Error 00035 on next line (sometimes)
ZipForge.OpenArchive(CompressedStream, False);
ZipForge.FindFirst('*.*', ArchiveItem, faAnyFile - faDirectory);
sZipFileName := ArchiveItem.FileName;
sZipPath := ArchiveItem.StoredPath;
ZipForge.ExtractToStream(sZipPath + sZipFileName, UnCompressedStream);
ZipForge.CloseArchive;
但我有时会遇到“本机错误 00035”。
现在奇怪的是,当我尝试查看合并存档中的第一个 blob 时遇到这些错误(即尝试查看合并存档中的其他 blob 不会引发任何异常)
这可能是我没有考虑到的 ZipForge.MergeWith 的问题,也可能是我的 GetCompressedStream 中的错误(但如果我切换存档中 Blob 的顺序,它总是只发生在第一个 Blob 上)。 看起来是时候进行一个测试项目来看看到底发生了什么。
编辑
最初的问题只是询问有关这些本机错误的指导,对此我很满意我选择的答案。至于我的问题,我确信这是我传递到 OpenArchive 的 CompressedStream 的问题。
The archives I'm having trouble with were all created by merging a working archive with a non-existant archive, thereby effectively copying the contents of one into the other. It's part of a merging process we do. Like this...
ZipDestination := TZipForge.Create(nil);
if FileExists(DestinationZipFileName) then
ZipDestination.OpenArchive(fmOpenReadWrite + fmShareDenyWrite)
else
ZipDestination.OpenArchive(fmCreate);
ZipDestination.Zip64Mode := zmAuto;
ZipDestination.MergeWith(SourceZipFileName);
ZipDestination.CloseArchive;
and this is the code that gets a blob from the archive, uncompresses it, and makes it ready for the viewer.
CompressedStream := TMemoryStream.Create;
UnCompressedStream := TMemoryStream.Create;
GetCompressedStream(CompressedStream); // this fetches the blob from the zipfile
ZipForge.InMemory := True;
// Native Error 00035 on next line (sometimes)
ZipForge.OpenArchive(CompressedStream, False);
ZipForge.FindFirst('*.*', ArchiveItem, faAnyFile - faDirectory);
sZipFileName := ArchiveItem.FileName;
sZipPath := ArchiveItem.StoredPath;
ZipForge.ExtractToStream(sZipPath + sZipFileName, UnCompressedStream);
ZipForge.CloseArchive;
but I'm encountering "Native error 00035" sometimes.
Now the strange thing is that I'm getting these errors when I try to view the first blob within the merged archive (ie. trying to view other blobs within the merged archive doesn't raise any exception)
It could be something about ZipForge.MergeWith that I haven't catered for, or it could be a bug in my GetCompressedStream (but if I switch the order of blobs within the archive, it always happens to the first one only). Look like it's time for a test project to see what's really going on.
EDIT
Original question was simply asking for guidance on these Native Errors, for which I'm satisfied with the answer I've chosen. As for my problem, well I'm convinced it's an issue with the CompressedStream I'm passing into OpenArchive.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
本机错误 00035 是“无效的存档文件”。当 ZipForge 找不到本地或中央目录头时(即,当您尝试打开不是 zip 的文件时),就会发生这种情况。
我认为它们没有记录在帮助中,但本机错误到错误代码的转换表出现在 ZFConst.pas 中。有一个 NativeToErrorCode 表,可将“本机”错误转换为错误字符串数组中的索引。如果这还不足以告诉您问题所在,只需在 ZipForge.pas 中查找
raise
语句中的错误代码即可。他们始终使用完整的 5 位数代码,因此您可以搜索00035
而不仅仅是35
以避免虚假结果。Native error 00035 is "Invalid archive file". It occurs when ZipForge can't find either the local or central directory headers (that is, when you try to open a file that isn't a zip).
I don't think they're documented in the help, but the translation tables for native error to error code occur in ZFConst.pas. There's a NativeToErrorCode table that converts from the "native" error into an index in the error string array. If that isn't enough to tell you what the problem is just look through ZipForge.pas for the error code in a
raise
statement. They consistently use the full 5-digit code, so you can search for00035
instead of just35
to avoid spurious results.ZipForge 供应商提供的免费支持 http://componentace.com/help/zf_guide/gettinghelpfromtechnicalsu.htm< /a>
Free support offered from the ZipForge vendor http://componentace.com/help/zf_guide/gettinghelpfromtechnicalsu.htm