How can I update a file incrementally in iOS. (File patching) - ios

I have a huge text file in my application (version 1.0).
Lets assume that a new version (2.0) of this file was just released.
Most of the file remained the same but the new (2.0) version has a few modifications (some lines removed, others added).
I now wish to update the file (1.0) to the new version (2.0), but do not wish to download the whole file again.
I would love to just patch the file with the changes of the new file, thus saving bandwith from downloading the WHOLE new file from my server.
(Similar to the way versioning systems like git or svn act)
How can I do this programmatically? Are there any iOS libraries available?
Thank you

You need to implement some kind of Binary delta compression such as zdelta, or Remote Differential Compression such as the one in rsync.
Personally I'm not aware of such algorithm implemented specifically for iOS, but I'm sure it's possible to find one that is implemented in C/C++ which can be seamlessly used in the iOS environment.
Edit: I also recommend you to read this.

It's actually a big problem... if your API let you ask the data of a file in a specific range, you can just a ask the data range that you need to replace, and seek the file at the range and overwrite the specific data... this mean that you have to take trace about the changes every time you update the files... and your app update has to know the ranges to request... this is not a solution... I hope will be a start point to implement your own solution
to try to get partial conent in a range you need to add to your request header something like this:
Range: bytes=0-999

I think, you can do this by yourself without third party libraries. To achieve this, all you need is 1)Piece of code which will generate the metadata for joining versions of your file (offsets, lengths, and pointers to the data to be changed in older version); 2)piece of code which will do the hard work: read meta and put the parts on right places. Several days of struggling with offsets, and you are done ;) Good luck!

Related

Steps to develop an iOS app to open PSL files?

In this project I've to develop an iOS application which reads the .psl files and arranges the data in the relevant section. For eg: the inbox messages from the psl file into the app's inbox folder and so on.
Can anyone guide me regarding the steps? And how would my project proceed also tell the workflow of this whole process.
The first thing you're going to have to tackle is to figure out how to get the file onto the phone. If you're getting it from the web; you could register as a sharable-target for that file type, or you could potentially integrate the DropBox api or something similar.
Once you have the file; you'll have to develop something to parse the file and use it as a datafile. Depending on the size and complexity of the file there will be different possible approaches to this, and you'll need to figure out what's going to be performant for you.
Then you'll build view controllers that leverage your model and make awesome things happen on the phone.
Your question is extremely general; so this is a very general answer. To me; the immediate critical questions are: how to get the file to the phone; and how to read the file format without loading the whole thing into RAM at one time?

27MB IPA with just GStreamer iOS Framework... how do I make much smaller?

I'm very interested in using GStreamer's iOS framework http://docs.gstreamer.com/display/GstSDK/Installing+for+iOS+development for video streaming, but when I add the framework to a blank project and add a few lines of code to take advantage of its powerful features, the final IPA is 27MB. This is just way to big to be adding to my project, what is the best way to go about stripping this down the the bare necessities as I'm sure I'm only using a small percent of the code that is included in the SDK.
Here's a pic showing the package contents of the IPA:
Thanks!
In the gst_ios_main.h you can disable all the plugins that you don't need (make sure to enable linker optimizations so that unused code is removed). If that's not enough, you can build your own stripped down version of the iOS binaries with http://cgit.freedesktop.org/gstreamer/cerbero/ (you need to remove things from the .package and .recipe files to only build what you need). Just disabling things from gst_ios_main.h should be enough in 99% of the cases though.
Note that by default you'll build applications for multiple architectures, as such the resulting application will be rather large. Depending on your use case you can drop some architectures.
On another note, gstreamer.com is providing an completely outdated version of GStreamer and is in no way related to the GStreamer project. The official website is http://gstreamer.freedesktop.org .
SDKs have their source code encapsulated away from you, the user. You get access only to header files. Thus you just can't extract some class from it because you don't have access to the implementation file.
Of course if this library is opensource you can attempt to isolate one class, but sometimes everything is so deeply connected, that it is close to impossible.

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.

Xcode save code folding?

I know it's not directly related to programming, but what better place then stackoverflow right?
So code folding is an awesome feature which I love, but does anyone know if there is a way to get Xcode to remember where you have certain sections collapsed whenever you open a file?
BTW, I'm coding ruby on rails using git version control.
Code folding for a source file is saved in the user file of the project. So if you're just editing a naked Ruby source file, there's no place to store the information. You might just make a dummy Empty Project and add the Ruby files to it just to persist the folding state, scroll position, etc. even if you don't use the project for building or version control.

BlackBerry - Unpack Zip File

I'm developing a BlackBerry application in which I need to unpack a zip file compressed with PKZIP. The package could have one file in it, or it could have 10; it will vary in each case. I know that the BlackBerry API has native support for GZip and Zlib, although I'm pretty sure that these methods aren't going to be helpful in my case. It doesn't look as if I can extract the individual files using these calls.
I've tried JZlib (http://www.jcraft.com/jzlib/), which compiled fine, but again it doesn't look as if the methods contained therein are going to allow me to pull the individual files.
It appears as if this is possible, as there's an application called Ziplorer (http://www.s4bb.com/software/ziplorer/) that claims to do perform this exact procedure. How they're doing it, however, escapes me.
So here I am after hours of Googling. I'm welcoming any insight into my problem with open arms.
"zip" algorithms are typically offshoots of the Lempel-Ziv-Welch algorithm. They are a fairly efficient stream compression algorithms, but because of how they function, you can't start to decompress at random points in the file, you have to start from the start.
Any product that claims to be able to decompress one file from a zip still has to decompress everything before it in the zip file in order to know how to decrypt the given file, or even, for that matter, where the file is in the archive.
If you can tolerate GPL code in your application, then this library http://jazzme.sourceforge.net/ that might work. However the project (and its parent project http://sourceforge.net/projects/jazzlib/) don't look like they're being developed.

Resources