• 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
Re: / NSFileHandle in rtf and mpg files /
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: / NSFileHandle in rtf and mpg files /


  • Subject: Re: / NSFileHandle in rtf and mpg files /
  • From: "Louis C. Sacha" <email@hidden>
  • Date: Tue, 8 Jun 2004 13:01:25 -0700

Hello...

I'm not sure if these things have anything to do with the exact problem you are having, but

1) When you print out fileOffset, you are using the %qu specifier, right?

http://developer.apple.com/documentation/Cocoa/Conceptual/DataFormatting/Tasks/FormatStrings.html


2) Are you printing out the value of fileOffset before or after you subtract 21 from it?

If your file size is less than 21 bytes, or [scriptFileHandle seekToEndOfFile] is returning 0 because something is broken and there is no data there, you're going to munge fileOffset pretty badly.


3) You seem to be attempting to read data past the end of the file handle.

In the line

fileOffset -= off;

you subtract 21 from the end of file offset, and then

[scriptFileHandle seekToFileOffset: fileOffset];
theData = [scriptFileHandle readDataOfLength:30];

attempts to read 30 bytes of data starting at that point...


Hope that helps,

Louis

I'm trying to read a rtf file. My code is more or less like this ((I'm
not including parts of the code like obtaining the file from the panel
and editing the path)):

NSString *scriptFile;
NSFileHandle *scriptFileHandle;
NSData *theData;
unsigned char dataBuffer[40];
unsigned long long fileOffset;
unsigned off = 21;

/* I get the file from a panel */

/* I edit the string of the path. I remove the 'file://localhost' part
*/

scriptFileHandle = [NSFileHandle fileHandleForReadingAtPath:
scriptFile];
fileOffset = [scriptFileHandle seekToEndOfFile];
[bDisplay setDoubleValue: fileOffset];
fileOffset -= off;
[scriptFileHandle seekToFileOffset: fileOffset];
theData = [scriptFileHandle readDataOfLength:30];
[theData getBytes: dataBuffer];

When I print what's in fileOffset ((it should return the size of the
file, right?)), it always returns the same misterious number:
2424892184.

I'm also trying to open video files with the same code ((in another
class, of course)). When it's an avi it works perfectly... but when
it's a mpg file it returns the very same strange number. I assume
there's something wrong when I call fileHandleForReadingAtPath. I've
tried with different paths and it won't work either. What's that
number? Sorry if this mail is too long. It's my first...

:::::::::::::::::::::::::::::::::::::::-)
Luis Enrique Pojan
TM Systems, LLC
Caracas, Venezuela
_______________________________________________
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.


References: 
 >/ NSFileHandle in rtf and mpg files / (From: "TM Systems::Luis Poján" <email@hidden>)

  • Prev by Date: Getting the version string of any program
  • Next by Date: Re: / NSFileHandle in rtf and mpg files /
  • Previous by thread: / NSFileHandle in rtf and mpg files /
  • Next by thread: Re: / NSFileHandle in rtf and mpg files /
  • Index(es):
    • Date
    • Thread