• 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: writing huge C-array to a file
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: writing huge C-array to a file


  • Subject: Re: writing huge C-array to a file
  • From: PGM <email@hidden>
  • Date: Sun, 23 Jul 2006 22:40:51 -0400

Thanks for your suggestions. I had already looked into the documentation of NSFileHandle and NSFileManager, but not being familiar with fileDescriptors, I did not see any obvious way to do standard C fprintf writing with the help of those classes.

For the archives, I now use the following code in NSDocument's "writeToFile:ofType:":

//create new file if it does not yet exist
if(![[NSFileManager defaultManager] fileExistsAtPath:fileName]){
[[NSFileManager defaultManager] createFileAtPath:fileName contents:[NSData data] attributes:nil];
}


FILE *writing;
NSFileHandle *handle = [NSFileHandle fileHandleForUpdatingAtPath:fileName];
int descriptor = [handle fileDescriptor];
writing = fdopen(descriptor, "w");


//Now use fprintf for all the writing

fclose(writing);
[handle closeFile];

Best, Patrick

_______________________________________________
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: Re: writing huge C-array to a file
      • From: "Michael Ash" <email@hidden>
    • Re: writing huge C-array to a file
      • From: Jakob Olesen <email@hidden>
References: 
 >writing huge C-array to a file (From: PGM <email@hidden>)
 >Re: writing huge C-array to a file (From: Bill Bumgarner <email@hidden>)
 >Re: writing huge C-array to a file (From: Steve Bird <email@hidden>)
 >Re: writing huge C-array to a file (From: Bill Bumgarner <email@hidden>)

  • Prev by Date: Re: writing huge C-array to a file
  • Next by Date: how do I run my NSStatusItem app outside of Xcode?
  • Previous by thread: Re: writing huge C-array to a file
  • Next by thread: Re: writing huge C-array to a file
  • Index(es):
    • Date
    • Thread