• 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
sychronizeFile Problem
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

sychronizeFile Problem


  • Subject: sychronizeFile Problem
  • From: John Nairn <email@hidden>
  • Date: Mon, 10 Oct 2005 09:42:24 -0600

My code writes a temporary file to the disk and then launches a c++ tool as a separate NSTask. The first thing the task does is to read that temporary file. About half the time the task works, but the other half it fails saying no such file exists. I can check the disk and the file is there. The problem is that the file is not there in time for the task. I tried to "synchronizeFile" (see code snippet below), which according to Apple does the following

"Causes all in-memory data and attributes of the file represented by the receiver to be written to permanent storage.
This method should be invoked by programs that require the file to always be in a known state. An invocation of this
method does not return until memory is flushed."


but it still fails. Perhaps memory is flushed, but not the volume? I could not find method to flush the volume (like I used to use in Carbon) to insure the file will be ready for the NSTask.

BOOL status=[fm createFileAtPath:tempPath contents:[NSData data] attributes:nil];
if(status)
{ NSFileHandle *fileHdl=[NSFileHandle fileHandleForWritingAtPath:tempPath];
if(fileHdl)
{ [fileHdl writeData:[xmlText dataUsingEncoding:NSUTF8StringEncoding]];
[fileHdl synchronizeFile];
[fileHdl closeFile];
}
else
status=NO;
}


---------------
John Nairn (1-801-581-3413, FAX:1-801-581-4816)
Web Page: http://www.mse.utah.edu/~nairn

_______________________________________________
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: sychronizeFile Problem
      • From: Alastair Houghton <email@hidden>
  • Prev by Date: printing question
  • Next by Date: Re: Help with my stream object please
  • Previous by thread: Re: printing question
  • Next by thread: Re: sychronizeFile Problem
  • Index(es):
    • Date
    • Thread