Problem: 1658912

Title: (ACS) CFile_AC::IsSameFile prevents user from saving file in local machine

Received: May 27 1997 5:55PM


I found a problem in the TFile class and I'm wondering if I should be sending this message to you. Please tell me if I should be sending my messages to someone else. Thanks.

In the new version of TFile::IsSameFile there is a new line:

this->UpdateFileSpec();
This method makes a call to ResolveAlias() that gives me a problem in this senario:
  1. In my Tango Editor application I open a file on another machine.
  2. Make changes to the file.
  3. Go the other machine and disconnect myself from sharing.
  4. Now try to save my file.
  5. The Save As dialog comes up but then I get the "Could not complete request because of a program error" message.
In UpdateFileSpec:
...
			anErr = ResolveAlias(NULL, fAlias, &fFileSpec, &wasChanged);

		if (anErr != userCanceledErr)
			FailOSErr(anErr);
...
It turns out that the ResolveAlias call returns an error, -1070, and then the FailOSErr occurs. In MacApp 3.3, the call to UpdateFileSpec is not there and the user is allowed to save his file to the local machine.
This is a good one! The intention of putting the UpdateFileSpec in here as well as in several other places is to catch the situation where the user might have renamed or moved the file being worked on. It looks to me like you are using 3.3.3 or Release 12 (since this version is using FailOSErr rather than Throw...).

After taking a look at this for a little bit I'd suggest that you try installing a try/catch in IsSameFile around UpdateFileSpec which returns a false indicating that it is not the same file. This might cause problems in cases where the target file is supposed to be kept open but that'll take a bit more research.