• 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: NSFileWrapper limitation
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: NSFileWrapper limitation


  • Subject: Re: NSFileWrapper limitation
  • From: Dustin Voss <email@hidden>
  • Date: Thu, 4 Sep 2003 08:58:36 -0700

On Wednesday, September 3, 2003, at 02:31 AM, Anthony Cheung wrote:

Dear all,

I would like to know if there is limitation on file size when using
NSFileWrapper?

I have used the following code to check file size in my application:

fileWrapper = [[NSFileWrapper alloc] initWithPath:myfileName];

when the file size of "myfileName" is over 2 GBytes, I got the following error
message:

-[NSConcreteData initWithBytes:length:copy:freeWhenDone:bytesAreVM:]: absurd
length: 2147481258

If I can't use NSFileWrapper for files over 2 GBytes, what should I use?

Many thanks in advance for your reply.

I've noticed that people use NSFileWrapper for things it was not intended for. NSFileWrapper is for embedding a file in another document. I think people use it by default because it is one of the only file-handling classes in AppKit. But they (and you) should be using Foundation classes for file-handling.

If you read the description of NSFileWrapper, it loads the file into memory. I don't think you want to load a 2 GB file into memory. It's absurd, and NSData says as much. That is why you are getting this error.

The proper way to check the file's size would be to use Foundation's NSFileManager class:

unsigned long long myfileSize = [[[NSFileManager defaultManager] fileAttributesAtPath:myfileName traverseLink:YES] fileSize];
_______________________________________________
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: 
 >NSFileWrapper limitation (From: "Anthony Cheung" <email@hidden>)

  • Prev by Date: NSComboBox problem
  • Next by Date: Re: NSFileManager and directories
  • Previous by thread: NSFileWrapper limitation
  • Next by thread: init'ing an NSNotificationQueue
  • Index(es):
    • Date
    • Thread