Is an NSFileWrapper package similar to a Mac OS X Package (pkg)? - ios

In numerous places, the Apple documentation talks about packages of files (e.g. for iCloud) created by NSFileWrapper. Is this is any way similar to the .pkg format used to hide a folder as a single file on the OS X platform?
I have an app with multiple text files that I'd like to be able to let the user backup. I've used NSFileWrapper to create a single 'file' that does this. I had assumed that this was similar to a .pkg file on OS X, but despite then bringing the file into OS X (via email) I have no way of opening it - despite renaming files, etc.
So, is the NSFileWrapper 'package' completely different to the OS X 'package'?
Thanks,
Richard

No. One works on the filesystem level, while the other is a bunch of files compressed together with a specirfic set of unpacking instructions
NSFileWrapper, From the link you mentioned:
A file wrapper is a runtime representation of a file-system node, which is either a directory, a regular file, or a symbolic link.
While a .pkg would look something like:
A xar-based format used on a number of platforms to install files.
Wikipedia, (un)surprisingly enough, has a decent overview of what exactly a .pkg is.

Related

iOS and OSX Document Packages cross platform

I have a iOS and OSX application which is document based and i am saving complex folder hierarchy inside the document so i change my UTI type to document package.
But the problem is that according to apple Document Package is just a folder. If i open the document package on windows or linux machine it consider it as folder despite of having a .abc extension. I figured out that one solution to this problem is that i zip the folder while saving. But i don't think that it is a good approach because every time i open up the file i will have to decompress the folder and compress it again on re-saving.
Is there any other solution to this problem?
I found another better solution.
Solution is to use SQLite database as your document as long as you have text to save on the file systems. In my case i also had images, so i created a table for all the images and a table for all the files contents that i used to write on files. So the document will have custom extension(.abc) which will only be opened with your application.

Convert a filetype to its original state

How can I change a file type?
A year ago I wrote a few articles that should be viewed in any text type of program. however, I recently opened them and they are viewed in symbols and alphanumeric characters. In linux os, the 'file' is now in an archived folder type that contains .xml files. in windows os it is 'file' as type of file. it has no extension.
Is there any way to recover the original readable alpha-numeric information in these files?
My preference would be to salvage the original information than redo.
First off the extension doesn't actually mean anything for the information of the file, it's only purpose is as a hint to the OS for deciding which application should be used in opening the file. You can prove this by renaming something like an exe to have a txt extension which will then open in notepad as a lot of seemingly random characters; renaming it back to exe will allow it to run again.
Based on your description the files you mention are some form of binary file, the bad news with that is you need to know either what application was used to create the file in order to be able to open it or what the original file extension was (which would be a hint to the former).
If you don't know either of those pieces of information you can of course use trial and error by guessing what extension it might be, renaming it, then opening it with the associated application and seeing if it worked.

CodeModuleManager cannot allocate space for the module

I am trying to write an app that will download and install cod files.
I have the line:
CodeModuleManager.createNewModule(codData.length, codData, codData.length);
which is expected to return a module handle (which is an int). However, it returns 0 that means space cannot be allocated for the module to be intalled. I searched a bit but coulndt really find any info about what may be causing this. Any ideas ?
I found the solution:
I used the COD files inside the deliverables/web directory
When the COD file is above some size it is partitioned into 2 (or more) cod files. In my case there were two COD files. One was named abc.cod and the other one was abc-1.cod. You need to have both cod files in order to make the installation. (which was the real problem)
I noticed that in the deliverables/standard folder there is only 1 cod file which is probably the case that it is not splitted into 2 parts and, thus, the CodeModuleManager is not able to allocate space for it as a whole (thus partitioning is necessary afterall)
However, even after this you can encounter problems such as the icon of your application getting disappeared when you overwrite cod files (ie. when you try to update your app which already exists).
I found it more convenient to work with the .jad file. Just set up the right mime types in your directory and put the jad and cod files in there. Then open your jadfile using the browser and your app should be automatically and smoothly installed/updated by the OS itself.
Hope this proves helpful for someone else

Using shortcuts (alias) in iOS

In my game, rather than copying and pasting the existing images over and over again, I prefer to use shortcuts of images. However, each shortcut is 2.6mb which is bigger than most images. Is there a way to fix this issue? Cheers..
The full explanation is given in the Apple developer document "File System Programming Guide":
https://developer.apple.com/library/ios/#documentation/FileManagement/Conceptual/FileSystemProgrammingGuide/AccessingFilesandDirectories/AccessingFilesandDirectories.html#//apple_ref/doc/uid/TP40010672-CH3-SW10
In short, what the original poster called a shortcut is properly called a bookmark; it is created using methods in class NSURL (or CFURL functions). When written to disk, it is called an alias file, as in the old days of the Mac. Filesystem bookmarks/alias files have a similar function to symbolic links, but they are far from being the same thing.
Symbolic links
are provided at the Unix filesystem level
contain no data other than a pathname
are fragile if the destination file is moved
require no application code to interpret, since the Unix kernel handles them
Alias files
are specific to OS X, implemented by the Core Foundation and Foundation frameworks
can be very large, especially when pointing to image data (on Mac as of OS X 10.7)
are self-repairing if the destination file is moved (within certain limits)
require the use of NSURL or CFURL routines to interpret
If you wish to create a Unix symlink from your code, use the symlink system call. See https://developer.apple.com/library/ios/#documentation/System/Conceptual/ManPages_iPhoneOS/man2/symlink.2.html#//apple_ref/doc/man/2/symlink

Archive format suggestions for exporting iPad app data? Tarball?

I have an nascent iPad application, which stores "documents" internally on the device in the file system as a series of distinct files in a folder.
I'd like to try incorporating an import/export function through iTunes, using the features for OS 3.2 for this. I want to put all the document pieces that I keep internally into one container file for export.
So, smart folks of Stack Overflow: What's the simplest solution that will put a file hierarchy (or could be flat list in a pinch) into one file? There will not in theory need to be manipulation of the "archive"/container outside the app-- so random access isn't super important here, although it would be a bonus of course.
A tar file type thing springs to mind immediately. Roll my own? Any other thoughts or gotchas? (And if anyone can point me to code that reads/writes from a tar file, I'm all ears.)
Thanks!
Update: Made community wiki, since there's no single right answer here.
Try libarchive which is a friendly licensed, BSD derived (easier for iPhone OS) library for handling archive files.

Resources