NSData & zcat
Is there an easy way to turn an NSData into a zipped version of that NSData and more importantly to turn a zipped NSData into a decompressed version,
the NSData I have is viewable with zcat, but I was hoping there would be a better way than using pipes and process and hopefully not having to get zlib.
the NSData I have is viewable with zcat, but I was hoping there would be a better way than using pipes and process and hopefully not having to get zlib.
Sir, e^iπ + 1 = 0, hence God exists; reply!
ugh looks like zlib doesnt even do it
any ideas?
Quote:# Can zlib handle .Z files?
No, sorry. You have to spawn an uncompress or gunzip subprocess, or adapt the code of uncompress on your own.
any ideas?
Sir, e^iπ + 1 = 0, hence God exists; reply!
.Z is a file compressed with the UNIX compress utility - you're more likely to be using gzip or bzip, which I believe should be handled by zlib or libbz2 respectively.
Did you ever wonder why we had to run for shelter when the promise of a brave new world unfurled beneath the clear blue sky?
no.. I am dealing with .Z files. the kind that you can read with zcat.
Sir, e^iπ + 1 = 0, hence God exists; reply!
Well, zcat reads .gz files too, so I misunderstood. 
You're probably stuck with the suggestions it gave - namely piping or finding a library that does it.

You're probably stuck with the suggestions it gave - namely piping or finding a library that does it.
Did you ever wonder why we had to run for shelter when the promise of a brave new world unfurled beneath the clear blue sky?
oh well, Ill get coding then
Thanks for the advice.
Thanks for the advice.
Sir, e^iπ + 1 = 0, hence God exists; reply!
I was hoping to just write the data into the stdin of the process and read stdout but I cant get popen to work
Is there anything obviously wrong im doing here?
Is there anything obviously wrong im doing here?
Code:
#include <stdio.h>
#include <stdlib.h>
int main(int argc, char ** argv) {
FILE * proc;
char myeof = EOF;
proc = popen("banner", "a+");
if(!proc) {
printf("!proc\n");
return 0;
}
printf("wrote\n");
fwrite("hello world", 11, 1, proc);
printf("reading\n");
while(1) {
printf(":%c\n", fgetc(proc));
}
return 0;
}Sir, e^iπ + 1 = 0, hence God exists; reply!
man popen Wrote:The type argument is a pointer to a null-terminated string which must be`r' for reading, `w' for writing, or `r+' for reading and writing.proc = popen("banner", "r+");
Possibly Related Threads...
| Thread: | Author | Replies: | Views: | Last Post | |
| Cannot load NSData from NSUserDefaults | groffhibbitz | 1 | 2,917 |
Jun 25, 2009 10:25 PM Last Post: SethWillits |
|

