Creating a file set in OSX

For the application, I would like to store a collection of files together and have them in the file system as a single file, so it is easy to manage. I am currently storing everything in a folder.

I would like to keep things accessible so that you can manually edit the internal content if necessary.

One way to do this is to create a zip archive and provide it with an additional extension, and then .zip. Then it is displayed as a file type and, if necessary, you can unzip and access the content, but for normal use, keep it hidden.

I cannot find a convenient way to do this. Boost and zlib can perform compression, but do not work with archives. I found libzip, but it’s hard for me to understand how to use it, and it seems to me that it only reads / writes zip archives, without performing actual compression.

Is there a more convenient way to handle this?

Is it possible to call system functions to create an OSX archive from C ++ / Carbon?

Is there any other way to make a folder as a single file?

+4
source share
2 answers

In OSX, you can create Document Packages (similar to application packages) that are treated as a single file in Finder, but are actually just directories with some internal structure.

Apple does not zip these packages, but they provide the functionality you describe, and they can be created and accessed through CoreFoundation using CFBundleRef .

From the documentation:

... It is important to remember about creating a package of documents, because this is just a directory. As long as the type of document package is registered (as described in "Registering the type of your document" ), all you need to do is create it with the appropriate file name extension. (Finder uses the file name extension as its link to treat the directory as a package.) You can create a directory (and create any files that you want to place in this directory) using standard BSD file system procedures ...

+5
source

As a first step, just rename the folder and add the extension .bundle , for example. Myappdir.bundle

This will show the entire folder as a single file with a leg-like bundle icon.

The next step is to create one Info.plist file inside.

+2
source

All Articles