mimetype 文件有一个长度为 n 的额外字段。mimetype 文件不允许使用 ZIP 格式的额外字段功能

zud*_*dsy 2 c# compression zip epub

我正在使用 C# 库 DotNetZip(Ionic.Zip 和 Ionic.Zlib)从目录生成电子书。目录如下所示:

BookName
|
|___content/
|       images/
|       css/
|       (html pages, .ops, .ncx)
|
|___META-INF/
|       container.xml
|
|___mimetype
Run Code Online (Sandbox Code Playgroud)

生成存档的代码如下所示:

using (ZipFile zip = new ZipFile(pathTemp + ".epub"))
{
    zip.RemoveSelectedEntries("*.*");
    zip.AddFile(mimetype, "").CompressionLevel = CompressionLevel.None;
    zip.AddDirectory(pathTemp + "\\content", "content");
    zip.AddDirectory(pathTemp + "\\META-INF", "META-INF");
    zip.Save();
}
Run Code Online (Sandbox Code Playgroud)

当我通过EPUB Validator运行它时,它会抛出以下错误:

mimetype 文件有一个长度为 36 的额外字段。mimetype 文件不允许使用 ZIP 格式的额外字段功能。

我没有压缩 mimetype 文件,所以我不知道发生了什么。

小智 7

请参阅https://ebooks.stackexchange.com/questions/6258/the-mimetype-file-has-an-extra-field-of-length-n-the-use-of-the-extra-field-fea

从 .epub 文件中删除 .epub 格式不需要的不需要的文件(META-INF/calibre_bookmarks.txt)后,我遇到了同样的错误。重新压缩文件后,我收到上述错误消息。

使用 -X 参数进行压缩:

   -X     Do  not save extra file attributes (Extended Attributes on OS/2,
          uid/gid and file times on Unix).
Run Code Online (Sandbox Code Playgroud)

解决了问题。