windows - 使用 MakeCab.exe & .ddf 文件(即使用指令文件)如何指定 objective-c ab 文件名?

标签 windows compression cmd cab

我决定使用 makecab.exe 来满足在我的应用程序中创建 cab 文件的要求。 http://msdn.microsoft.com/en-us/library/bb417343.aspx#microsoftmakecabusersguide

而且我需要按照给定路径在 cab 中存储文件,无论是相对路径还是绝对路径,并提取保留原始路径的文件。因此,我将为此使用指令文件并将该输入提供给 makecab 命令。

windows command promt zip/compress directory

但 cab 输出存储在文件夹 Disk1\1.cab 中。

请帮助我了解如何将所需的 cab 文件名指定为目标(我将从用户输入中获取 cab 文件名)?

另外,是否可以在第二次运行 makecab 命令时将更多文件附加到现有 cab 文件?

最佳答案

终于找到了解决方案。

您可以在指令文件中设置以下两个变量,它们将标识目标路径和 cab 文件的名称:

DiskDirectoryTemplate=template [输出目录名模板; * 由磁盘编号代替]
CabinetNameTemplate=template [内阁文件名模板; *替换为柜号]

来自 Microsoft MakeCAB User's Guide 的描述

DiskDirectoryTemplate=template

Set the output directory name template. One directory is created for each disk of the layout.

Default: .Set DiskDirectoryTemplate=DISK* ; Default is DISK1, DISK2, etc.

As MakeCAB processes a directive file, it will create one or more disk "images". Rather than using some specific disk format, however, MakeCAB simply creates one subdirectory for each disk and places the files for each disk in the appropriate directory. If a * exists in this variable, then it is replaced with the disk number. If no * is specified, then all files are placed in the single directory specified by this variable.

This variable is used only if no variable DiskDirectoryn exists for disk n.

Examples:

.Set DiskDirectoryTemplate=C:\EXCEL6\DISK*  ; Put files in separate dirs
.Set DiskDirectoryTemplate=C:\EXCEL6        ; Put all files in C:\EXCEL6
.Set DiskDirectoryTemplate=                 ; Put all files in current dir

CabinetNameTemplate=template

Sets the cabinet file name template.

Default: .Set CabinetNameTemplate=*.CAB ; 1.CAB, 2.CAB, ...

This template is used to construct the file name of each cabinet. The * in this template is replaced by the cabinet number (1, 2, etc.). This variable is used only if no variable CabinetNamen exists for cabinet n.

NOTE: Be sure that the expanded cabinet name does not exceed the limits for your file system! For example, if you used "CABINET*.CAB", and MakeCAB had to create 10 or more cabinets, then you would have cabinet names like CABINET10.CAB, which is 9.3, which is an invalid name in the FAT file system. Unfortunately, MakeCAB would not detect this until it had already created 9 cabinets!

Examples:

.Set CabinetNameTemplate=EXCEL*.DIA  ; EXCEL1.DIA, EXCEL2.DIA, etc.

.Set CabinetNameTemplate=*.          ; 1, 2, 3, etc.

此外,当文件跨 cab 拆分时(以防 cabinet 大小超过其限制大小),您还可以使用变量 CabinetNamen 设置后续的 cabinet 文件名:

CabinetNamen=filename [机柜号n的机柜文件名]

CabinetNamen=filename

The cabinet file name for the specified cabinet.

Default: ; By default none of these variables are defined

If this variable is not defined for a particular disk, then MakeCAB uses the CabinetNameTemplate to construct the cabinet name.

Example:

.Set CabinetName2=test2.cab

关于windows - 使用 MakeCab.exe & .ddf 文件(即使用指令文件)如何指定 objective-c ab 文件名?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15843347/

相关文章:

c - 有没有可能获得函数的内存入口点?

c++ - 如何以用户身份在 Windows (Linux TCP_INFO) 上获取 TCP RTT

windows - 如何在 PowerShell 中更改环境变量并启动应用程序

c++ - 为什么 GetErrorMessage 返回 "wrong password",当用户名错误时?

java - 将 Java Deflater/Inflater 与自定义字典一起使用会导致 IllegalArgumentException

python - 将 cmd 命令的过滤输出存储在变量中

ubuntu - zip 存档中是否可以使用硬链接(hard link)?

c# - SevenZipSharp - 如何使用 C# 将多个目录压缩到一个文件中?

batch-file - 更改 WMIC 结果的格式

batch-file - 对 cmd/批处理文件中的所有问题切换为 "yes"