6

Don't know how to ask it so I will explain situation.

I need to store a few compressed files. The original idea was to create a folder and store as many compressed files as were needed and also create a file that holds data about every compressed file.

However, I was not allowed to create many files and must only have one. I decided to create a compressed file which has a header about further data and after header keep compressed data. But this option has disadvantages, e.g. editing such file after it is created takes long time because it must be fully rewritten even if I want to add one more little file.

So, as I imagine, I need to create folder with some specific attributes and create as many files inside. Is this even possible?

I'm creating an app for Windows, so I can use any stuff that works on Windows, and I'm coding with C++.

NOTE: A single file is needed because, for example, it will be sent through e-mail and attaching many files is not an ideal solution.

NOTE: I don't need an algorithm for compression, I need some way to efficiently store everything in single file.

4

3 回答 3

1

您可以创建一个SQLite数据库或一个 SQL Server Compact Edition 数据库(驻留在单个.sdf文件中),并将所有数据作为 BLOB 存储在其中。数据库管理系统应该很容易与应用程序的其他二进制文件一起部署。

对于 SQL Server Compact,我不确定从非托管代码 (C++) 中使用它是否容易。在 .NET 中这很容易,但我很确定它也可以在 C++ 中完成,不过 &mdash 需要一些研究。

至少,这个 Stack Overflow 问题涉及如何通过 OLE DB 提供程序从 C++ 连接到这样的数据库。

于 2013-08-24T07:47:19.297 回答
0

使用 7zip SDK 并将所有内容保存在一个 zip 文件中怎么样?

http://www.7-zip.org/sdk.html

于 2013-08-24T21:50:20.313 回答
0

作为另一种选择,您可以使用 tar 文件:自定义标头的文件条目以及其他条目(压缩等)的信息,并将所有文件作为 tar 文件中的条目。我不知道用库函数替换条目是如何工作的(在这里我获得了至少可以使用 gnu tar http://www.karkomaonline.com/index.php/2005/03/basic- tar-usage-gnu-tar/ linux 上的命令行实用程序),但似乎无需重新创建整个存档也是可能的。我认为您首先必须创建更大的虚拟条目,以便以后有足够的可用空间,以便这些条目可以用所有需要的数据替换。

于 2013-08-25T04:20:29.967 回答