Creating zip with __MACOSX/.DS_Store from a non-mac system - macos

There are plenty of questions and answers about how to ignore the __MACOSX/.DS_Store files created by Mac OS X...
I would like to know how to go the other way, and include the __MACOSX/.DS_Store files, specifically when working with zip files created on another platform. Simply zipping up the file structure is not enough; it seems that there is some kind of hidden flag in the zip file that is marking that part of the file structure in the zip as the mac resource fork.
Creating the resource fork on the other platform isn't the issue, I'm specifically trying to generate a zip file that properly includes already existing resources. Any thoughts? Will I need to create my own zip tool?

Related

Script to remove file from a single target

We're building an app that has different versions for different countries.
As part of a localisation effort I'm aiming to write a script that swaps certain asset files with another based on the language parameter.
I've written a python script for this using a python library, but that has a bug where on editing the files xcode doesn't really recognise the structure anymore and we have to restart xcode.
So the newer approach is to use this ruby gem.
I am fetching the project and I can access the files
project = Xcodeproj::Project.open(project_path)
target = project.targets.first
files = target.source_build_phase.files.to_a.map
But I can't find anything in the documentation where it would allow me to remove a file from just one target.
I have thought about creating a new target and adding all the files except the one I want deleted.
But I think that seems overkill for the issue we're trying to solve.

Allowing a Macintosh application to write files

We market an application that runs on multiple platforms, including Macintosh. On the Macintosh the software gets packaged into a .dmg file, and when installed everything goes into the /Applications hierarchy.
Some of the files in our application's hierarchy are samples that users are supposed to be able to modify in place or copy to different files in the same directory. The problem is the permissions that seem to get applied within the /Applications hierarchy prevent our application from doing such operations.
So I either need to change the install so the directories and files in question within /Applications allow modification, or I need to segregate the sample files to a different location on the disk where they can be modified.
I've tried making sure the permissions on the files allow writing at the time the .dmg file is pulled together, but then when the product is installed the permissions get changed to more restrictive ones that don't allow file modification or copying.
I've been able to modify the packaging so the sample files get installed to a different location, but so far I haven't been able to find a suitable area on the Macintosh disk to put them so modification is allowed. I haven't been able to figure out how to tell the packaging that these sample files should be installed into the installer's home directory.
Anyone have any suggestions? I'm afraid I'm a bit of an Apple novice. The procedure to build the .dmg file employs a Makefile that invokes commands like pkgbuild and productbuild. The productbuild command uses a --distribution qualifier that references a .xml file. There don't seem to be any scripts invoked.

Create a folder with a custom extension

So I've been looking around for a bit on a way to do this, and here is my idea:
I want to create a folder, with a custom extension. Similar to how java has their .jar folders, is there any way to package things like this, and still be able to move things between the folders?
For example, I want to use .map, and use it as a folder. So lets say I want to put a ma.png and ma.p inside of a test.map folder, and store all of that inside of a folder named maps, so the reference for the ma.p file would be "maps/test.map/ma.p".
Any ideas?
Windows cannot associate folders with programs the way OS X does. You can name folders with an 'extension', but it doesn't change its behaviour. In OS X, renaming a folder to something.app makes the OS treat the folder as a file (application). Windows doesn't do this.
You mentioned .jar files: Java archives are .zip archives, renamed to .jar.
You can do what you said in your last paragraph, but Windows doesn't care about 'extensions' in directory names. This is an OS X-only thing, if you ever see such a thing, I can almost guarantee it's a renamed .zip, rather than a directory with an extension.

Making folder containing executable into executable

I have a folder which contains an executable file (Exec.exe) and a lot of files that Exec.exe needs to run. Currently, it's pretty ugly having all of those files there when I only need to run the one executable. Is there any way to bundle them all into another executable that runs Exec.exe and also contains all of the files Exec.exe needs to run? Thanks for any help!
Yes, but I would recommend you only do it if you need to.
You can achieve this by adding your files as resources in your exe project, so they are added into the exe's binary at compile time. You can then access the files directly from your exe at runtime by using LoadResource and related functions. I'd recommend reading up on the Portable Executable (PE) file format if you're considering this route.
This is the way to do it if you, and again I stress, need to have only a single binary where you can still access your files. There are obvious downsides to doing this, such as it's much more coding to access the data as it's embedded in your application binary, and you can't easily update the files (check out resource hacker tool) without re-compiling your binary to include the new data.
If the only reason you want to do this is because it's "pretty ugly" seeing the additional files in the same directory as your exe, consider moving them into another directory, for example,
from:
MyExeDir
--myExe.exe
--myFile1.txt
--myFile2.dll
--myFile3.dat
to:
MyExeDir
--myExe.exe
--dat
----myFile1.txt
----myFile2.png
----myFile3.dat
or:
MyExeDir
--bin
----myExe.exe
--dat
----myFile1.txt
----myFile2.png
----myFile3.dat
So all the "ugly" looking files are out of the way.
Why don't you create a shortcut of "Exec.exe" and keep it somewhere handy ? If whats that you want ?
Or if you want to distribute your app, you can use Winrar/Winzip (winrar is the best) to create a compressed .exe of your entire folder, making "Exec.exe" as your startup app. Use the SFX option in winrar.

Creating a file bundle on OSX

For an application I would like to store a collection of files together, and have them appear in the filesystem as a single file so its easy to manage. I am currently storing everything in a folder.
I would like to keep things accessible so you can manually edit the inside contents if neccesary.
One way to do this would be to create a zip archive and give it a custom extension other then .zip. Then it appears as a filetype and if needed you can unpack and access the content, but for normal use keep it hidden.
I can't seem to find a convenient way to do this. Boost and zlib can do the compression but don't work with archives. I found libzip but I have a hard time understanding how to use it and to me it seems that it only reads/writes zip archives without doing the actual compression.
Is there a more convenient way to tackle this?
Can you call system functions for creating an archive on OSX from c++ / Carbon?
Is there another way to make a folder appear as a single file?
In OSX, you can create Document Packages (similar to application bundles) which are treated as a single file in the Finder, but are really just directories with some internal structure.
Apple does not zip these packages, but they do provide the functionality you describe and they can be created and accessed through CoreFoundation by using CFBundleRef .
From the documentation:
... The important thing to remember about creating a document package is that it is just a directory. As long as the type of the document package is registered (as described in “Registering Your Document Type”), all you have to do is create a directory with the appropriate filename extension. (The Finder uses the filename extension as its cue to treat the directory as a package.) You can create the directory (and create any files you want to put inside that directory) using the standard BSD file system routines ...
As 1st step, simple rename the folder and add the extension .bundle, e.g. Myappdir.bundle
That's will show the whole folder as one file with a lego-like bundle icon.
The next step is you must create one Info.plist file inside.

Resources