什么是压缩目录到单个文件的方法 [英] What are ways to compress directory into single file

查看:169
本文介绍了什么是压缩目录到单个文件的方法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

不知道怎么问,所以我会解释一下情况。

我需要存储一些压缩文件。最初的想法是创建一个文件夹并存储所需的压缩文件,并创建一个文件来保存每个压缩文件的数据。



然而,我不是允许创建许多文件,只能有一个。我决定创建一个压缩文件,其中包含有关进一步数据的头文件,头文件保存了压缩的数据。但是这个选择有缺点,例如编辑这样的文件后,需要很长的时间,因为它必须完全重写,即使我想再添加一个小文件。

所以,我想,我需要创建具有一些特定属性的文件夹,并在里面创建许多文件。这甚至有可能吗?



我正在为Windows创建一个应用程序,所以我可以使用任何在Windows上工作的东西,而我正在用C ++进行编码。注意:单个文件是必需的,因为,例如,它将通过电子邮件发送,并附加许多文件不是​​一个理想的解决方案。



注意:我不需要压缩算法,我需要某种方式来高效地将所有内容存储在单个文件中。

解决方案

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

是从非托管代码(C ++)使用。在.NET中这很容易,但是我确信它可以用C ++来完成,不过我也需要做一些研究。



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


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.

解决方案

You could create a SQLite database, or a SQL Server Compact Edition database (which resides in a single .sdf file), and store all your data in there as BLOBs. The database management system should be easy enough to deploy along with the other binaries of your application.

In the case of SQL Server Compact, I am not exactly sure how easy this is to use from unmanaged code (C++). It would be easy enough in .NET, but I'm quite sure it could be done for C++, too &mdash would take some research, though.

At least, this Stack Overflow question goes into how to connect to such a database from C++ through an OLE DB provider.

这篇关于什么是压缩目录到单个文件的方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆