Append to file with NSString writeToFile:
Append to file with NSString writeToFile:
- Subject: Append to file with NSString writeToFile:
- From: <email@hidden>
- Date: Mon, 28 Feb 2005 7:06:12 +0000
In my application, I have an NSTask run a program to process some files. The process will spit out some information that I'm trapping using NSPipe and NSFileHandle (for reading). All of this is working fine. I basically have a method that takes an array of file names (absolute paths here). Each run through the loop launches the task with the appropriate switches and filenames, and produces output.
The problem I'm running into is for every file's output that is produced, I want to write it to a file. So what I'm doing is creating an NSString from the NSData object returned by readDataToEndOfFile: from my NSFileHandle. I do some string manipulation to tag on some info at the beginning of the string (filename, actually), and then I write it to file:
[fingerpring writeToFile:filePath atomically:YES];
This works for the most part, but after the loop is done processing all the files, I open the file only to see the last file's output. So it's obvious that each write action is overwriting the contents.
How can I have it simply append the new information to the file, not write over what's already there? Thanks.
James
_______________________________________________
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