C++将文件权限添加到 zip 文件
C++ Adding File Permissions to Zip File
我正在C++上开发一个压缩程序。我想添加安全描述符,以便在压缩时保留我的文件权限。我正在使用Zlib的Minizip来压缩文件,我知道Minizip没有保存文件权限的功能。我认为我可能必须手动将安全描述添加到额外的字段中。
如何获取文件的安全权限?
如何格式化 zip 文件的安全描述符?
看看Info-ZIP的zip和解压缩实用程序。 它们为各种操作系统提供了比基本minizip功能更广泛的支持。
要自己动手,您可以参考 Info-ZIP 应用说明。 Windows额外字段定义在那里,复制在这里:
-PKWARE Win95/WinNT Extra Field (0x000a):
=======================================
The following description covers PKWARE's "NTFS" attributes
"extra" block, introduced with the release of PKZIP 2.50 for
Windows. (Last Revision 20001118)
(Note: At this time the Mtime, Atime and Ctime values may
be used on any WIN32 system.)
[Info-ZIP note: In the current implementations, this field has
a fixed total data size of 32 bytes and is only stored as local
extra field.]
Value Size Description
----- ---- -----------
(NTFS) 0x000a Short Tag for this "extra" block type
TSize Short Total Data Size for this block
Reserved Long for future use
Tag1 Short NTFS attribute tag value #1
Size1 Short Size of attribute #1, in bytes
(var.) SubSize1 Attribute #1 data
.
.
.
TagN Short NTFS attribute tag value #N
SizeN Short Size of attribute #N, in bytes
(var.) SubSizeN Attribute #N data
For NTFS, values for Tag1 through TagN are as follows:
(currently only one set of attributes is defined for NTFS)
Tag Size Description
----- ---- -----------
0x0001 2 bytes Tag for attribute #1
Size1 2 bytes Size of attribute #1, in bytes (24)
Mtime 8 bytes 64-bit NTFS file last modification time
Atime 8 bytes 64-bit NTFS file last access time
Ctime 8 bytes 64-bit NTFS file creation time
The total length for this block is 28 bytes, resulting in a
fixed size value of 32 for the TSize field of the NTFS block.
The NTFS filetimes are 64-bit unsigned integers, stored in Intel
(least significant byte first) byte order. They determine the
number of 1.0E-07 seconds (1/10th microseconds!) past WinNT "epoch",
which is "01-Jan-1601 00:00:00 UTC".
相关文章:
- 捕获标准输出以压缩并使用 CTRL-C 中断会给出损坏的 zip 文件
- 使用 Poco::Zip 将文件附加到现有 zip 文件
- 无法在 Cocos2dx 中使用受密码保护的 zip 文件
- 如何使用 Poco::ZIP 压缩/解压缩 zip 文件
- cpp libcurl 在 HTTP post 调用中发送 zip 文件,而不使用 multipart\form-da
- 有谁知道ziplib是否能够在不实际提取所有文件的情况下验证zip库
- 使用 libzip 打开 zip 文件时遇到问题
- 如何使用 "DFLT-X" 方法编写 Zip 文件
- C++ 使用Powershell命令提取zip文件
- 尝试使用 wxWidgets 从 zip 打开不存在的文件时无法捕获的异常
- 如何在 mfc c++ 中流式传输.zip文件夹的二进制表示形式
- 如何解决系统.Zip.TZipFile.ExtractAll无法从.zip文件中提取所有数据的问题
- 如何在视觉工作室中使用C++解压缩压缩文件 (.zip)
- 需要正则表达式来提取zip文件中的所有文件
- 只读二进制zip文件的一部分
- 如何使用 C/C++检查 ZIP 文件(Office Open XML 文件)的完整性
- 如何使用 zlib.h 库将.zip文件解压缩到文件夹中
- 从本地代码访问apk中的压缩文件(从zip中读取zip)
- 使用minizip删除和修改zip中的文件
- 如何使用 zlib 在 zip 文件中添加/删除特定文件