Looking for ideas about displaying unkown-type data
Looking for ideas about displaying unkown-type data
- Subject: Looking for ideas about displaying unkown-type data
- From: Gerben Wierda <email@hidden>
- Date: Sun, 18 Aug 2002 01:32:39 +0200
My app has an inspector window that can display various files. For
instance, when I select a file foo.tar.bz2, it will run bzcat in a
NSTask and the output will be piped to another task where gnutar is
running. This all works fine.
Now at some point there is a file called foo.gz. I would like to inspect
this file if possible. But foo can be a text file, contain RTF data, be
a binary even. Just for the hack of it, I took the unzip binary,
compressed it and the ran my inspector on it. The inspector ran gzcat on
it and the output was appended to a NSTextView.
A nice stream of undecipherable characters were displayed. Not nice, but
I can live with that for the moment. But what was worse is that the app
did hang when it received this data. I think my app should not hang on
receiving random data. Since I can just open /usr/bin/gunzip in
TextEdit.app fine, I wondered if this ws because of getting the data
through a NSTask and NSNotifications in the default way. Somehow, I
guess, the NSFileHandle or NSPipe are getting in trouble.
Given this situation, how wold people try to make this work? I can
imagine getting the uncompressed data in a NSData first (and not
updating the view as we go along), but then: how do I recognize if the
data is displayable? Some sort of 'file' command, but then inside Cocoa,
maybe? I'd rather not write the uncompressed file somewhere first. And I
do want to be able to display compressed ASCII files just like that (so
running everything through od is not an option).
I am looking for ideas.
G
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.