Open Menu
Close Menu
Apple
Shopping Bag
Apple
Mac
iPad
iPhone
Watch
TV
Music
Support
Search apple.com
Shopping Bag
Lists
Open Menu
Close Menu
Terms and Conditions
Lists hosted on this site
Email the Postmaster
Tips for posting to public mailing lists
NSData, chars, and torrent files
[
Date Prev
][
Date Next
][
Thread Prev
][
Thread Next
][
Date Index
][
Thread Index
]
NSData, chars, and torrent files
Subject
:
NSData, chars, and torrent files
From: Jon Shier <
email@hidden
>
Date: Wed, 24 May 2006 18:27:31 -0500
I'm about at the end of my rope with this. As an attempt to learn Cocoa (and OO programming in general) I'm writing my own BitTorrent client. But I can't seem to get past a basic problem: I can't read the contents of a .torrent file into an easily accessible data structure with any success. I initially read it into an NSString, but that corrupted the SHA1 hashes that are in the file as raw byte strings. Then, on advice from Allan Odgaard (yay IRC!), I switched to using an NSData object to initially read the file, then converting it to a const char * so I can iterate through it and parse the data (which, by the way, worked file when I was using an NSString). However, this doesn't seem to work. The char I get is only a fraction of the NSData object (I can tell the NSData object has all of the file in it because of its length), always terminating at some point in the SHA1 hash data. At the same time, I know chars can handle SHA1 hash data, since I use them elsewhere in the program to get SHA1 hashes (WebKit also uses a char to get the MD5 checksum's of images for their rendering tests, which is where I got this code) and I can then convert that char to an NSData object without data loss.
Now, I know I'm probably doing something wrong, but the only real programming training I've had was simplistic, 5 years ago, and in Fortran, so please humor me. Here is a link to the code of my methods:
http://rafb.net/paste/results/ocdA2a59.html
Thanks,
Jon Shier
P.S. Any algorithmic improvements or ideas you want to offer for .torrent file parsing would also be appreciated.
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden
Follow-Ups
:
Re: NSData, chars, and torrent files
From:
Duncan Anker <email@hidden>
Prev by Date:
Re: Core Data Import
Next by Date:
Re: IB: subclassing NSAnimation problem
Previous by thread:
Re: NSNumber's integer approximation of Positive Infinity
Next by thread:
Re: NSData, chars, and torrent files
Index(es):
Date
Thread