I am reading a very large file using a NSInputStream and sending them to a device in packets. If the receiver does not get a packet, I can send back to the sender with a packet number, representing the starting location in bytes of the packet missing.
I know an NSInputStream cannot rewind and grab the packet, but is there another way to grab the requested byte range without loading the entire large file into memory?
If there was a [NSData dataWithContentsOfFileAtPath:inRange] method, it would be perfect.
You can rewind with NSInputStream:
[stream setProperty:[NSNumber numberWithInt:offset]
forKey:NSStreamFileCurrentOffsetKey];