(Documents, FileBased) Saving to a Server
1615790
Dec 29 1996 11:44AM
It was written earlier: >Hello, > >We have a MacApp 3.1.5 program under CW8. When we are trying to save >our document via temp, we do not have enough rights on the server. >The user has enough rights to do anything, only save via temp >generates a access denied (-5000) error. >We absolutly need the save via temp, because original file is used in >construction of the new file. The file is to large to read in memory >completely ( 1 - 200Mb) >Everything works if you run it on an AFP-server (AppleShare 4.0 >Server) but on a Novel 3.12 or 4.1 it says access denied. Everything >else, other programs, copying etc... work fine. > >I debugged the problem and it seems that in TFileHandler the Save via >temp function uses a FindFolder toolbox routine. It is finding and >trying to create a temporary folder so that the temporaty file can me >saved inside the temporary folder. In one way or the other it wants to >create the tempraryfolder at the root of the system-Volume of the >server. The root level is only accessable for the administrator. And >indeed if we log in as Admin, we can save via temp. But a normal user >with Read/Write/Create/Erase/Modify rights cannot save a document via >temp. > >We could ofcourse overwrite this function and write our own piece of >FileHandler. But I prefer that this stays MacApp original for future >compatibiliry. >Do you have any clues or ideas that would give us an (easy) solution >for this problem, keep in mind that we MUST save via temp. //---------------------------------------------------------------------------- // TFileHandler::SaveViaTemp: //---------------------------------------------------------------------------- #pragma segment MAWriteFile void TFileHandler::SaveViaTemp(CommandNumber itsCommandNumber, Boolean makingCopy, Boolean copyFInfo, TFile* itsFile) { // snip // If we are using the folder manager, put in the temporary folder, // creating if necessary if (qNeedsFolderMgr || gConfiguration.hasFolderMgr) { // Start change short tmpVRefNum; long tmpDirID; OSErr err; err = FindFolder(saveFileSpec.vRefNum, kTemporaryFolderType, kCreateFolder, &tmpVRefNum, &tmpDirID); if (err == noErr) FailOSErr(volatileItsFile->SpecifyWithTrio(tmpVRefNum, tmpDirID, tmpName)); else volatileItsFile->SetName(tmpName); // End change } else volatileItsFile->SetName(tmpName); FailInfo fi; Try(fi) { // Start change if (volatileItsFile->CreateFile() != noErr) { // If we can't create a file in the temporary folder (e.g. we don't have access // priviledges) we create one in the saved file's folder FailOSErr(volatileItsFile->SpecifyWithTrio(saveFileSpec.vRefNum, saveFileSpec.parID, tmpName)); FailOSErr(volatileItsFile->CreateFile()); } // End change if (validInfo) // Change attributes of volatileItsFile?? FailOSErr(volatileItsFile->SetCatInfo(cInfo)); FailOSErr(volatileItsFile->OpenFile()); // snip
Fixed by providing alternative folder resolution in SaveViaTemp in FileBasedDocument.cp.
If we can not save file in a folder, MacApp will promote a "GetFile" dialog to let user select new folder.