max size of [NSString stringWithContentsOfFile:] ?
-
hi all,
i am using the (convenient) stringWithContentsOfFile: function to read in text files;
in the documentation i see that length: returns an unsigned int, meaning that the maximum length of a string is 65535 characters, am i getting this right?
therefore, related to the "scannerWithString" thread of last week, if i want to read in a really large file (is 65k already really large?) in an array of lines (each line shorter than maximum string length), how can i do this?
right now i am reading the whole file and using jerome laurens "splitLines" function, hoping that the file fits into the string.
btw, what happens if it does not fit? does it get cut, or do i get an error?
--
cheers, martin.
_______________________________________________
cocoa-dev mailing list | <cocoa-dev...>
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored. -
An int is 32 bits not 16 bits so the maximum value of an unsigned int is
2^32. I can hear the sound of your palm hitting your forehead from here.
On Wednesday, May 29, 2002, at 07:14 PM, Martin Bauer wrote:> i am using the (convenient) stringWithContentsOfFile: function to read_______________________________________________
> in text files;
> in the documentation i see that length: returns an unsigned int,
> meaning that the maximum length of a string is 65535 characters, am i
> getting this right?
>
> therefore, related to the "scannerWithString" thread of last week, if i
> want to read in a really large file (is 65k already really large?) in
> an array of lines (each line shorter than maximum string length), how
> can i do this?
>
> right now i am reading the whole file and using jerome laurens
> "splitLines" function, hoping that the file fits into the string.
cocoa-dev mailing list | <cocoa-dev...>
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored. -
On Wednesday, May 29, 2002, at 11:44 , Martin Bauer wrote:> i am using the (convenient) stringWithContentsOfFile: function to read in
> text files;
> in the documentation i see that length: returns an unsigned int, meaning
> that the maximum length of a string is 65535 characters, am i getting
> this right?
You are not: we happily live in 32-bit world, making so the biggest
unsigned it four milliards (billions if you are from U.S.).> therefore, related to the "scannerWithString" thread of last week, if i
> want to read in a really large file
If you wanted to read a *really* large file (milliards of bytes) you have
to go other API anyway, for there would be problems with available address
space. Though, up to hundreds of thousands bytes you don't need to worry
the slightest bit. Millions is a zone which can be loaded into RAM without
real problems, but it might be somewhat inefficient (depends, of course,
also on what you want to do with the data).
---
Ondra Cada
OCSoftware: <ocs...> http://www.ocs.cz
2K Development: <o.cada...> http://www.2kdevelopment.cz
private <ondra...> http://www.ocs.cz/oc
_______________________________________________
cocoa-dev mailing list | <cocoa-dev...>
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.


