/* Version: 2.5 September 9, 1999 Creation Date: April 14 1998 Author: robin (robin@uberware.net) http://www.uberware.net/mel/ Procedure Name: makeBackup Description: Makes a backup copy of a file (called by FileMenu_SaveItem) Add this line to your userSetup.mel: scriptJob -ro true -cf "busy" "source makeBackup.mel"; Version 2.5: September 10, 1999 Builds a copy command for both IRIX and NT. Tried using sysFile, but it had some weird permission problems on our systems. Version 2.0: July 21, 1999 Hack for FileMenu_SaveItem integrated into script. now just source it once and it works. Input Arguments: None Return Value: None. Use and Modify at your own risk. */ global proc makeBackup() { waitCursor -state on; string $sceneName = `file -q -sceneName`; string $snBuf[]; int $lastSN; int $i; string $cmd; if (`about -os` == "irix") { string $backupName = "/"; $lastSN = tokenize ($sceneName, "/", $snBuf); for ($i=0; $i<$lastSN - 1; $i++) $backupName += $snBuf[$i] + "/"; $backupName += ",," + $snBuf[$lastSN-1]; $cmd = "cp " + $sceneName + " " + $backupName; } else { string $origName; string $backupName; // file -q -sn seems to use forward slashes on nt? $lastSN = tokenize ($sceneName, "/\\", $snBuf); for ($i=0; $i<$lastSN - 1; $i++) { $origName += $snBuf[$i] + "\\"; $backupName += $snBuf[$i] + "\\"; } $origName += $snBuf[$lastSN-1]; $backupName += ",," + $snBuf[$lastSN-1]; $cmd = "copy \"" + $origName + "\" \"" + $backupName +"\""; } system $cmd; waitCursor -state off; } //stolen from /usr/aw/maya/scripts/startup/FileMenu.mel global proc FileMenu_SaveItem() // // If the current file is named, save it. If it // is still untitled, then bring up the Save As // dialog. // { string $sceneName = `file -q -sceneName`; // Get the name of the scene File. if ( size($sceneName) == 0 ) { // Then the name can't be set. projectViewer SaveAs; // bug fix 89970 file save } else if ((`file -q -amf`) || (`file -q -ex` == 0)){ // added by rns 7-21-99 for backups makeBackup(); // end addition string $cmd = "file -save"; evalEcho($cmd); } else { warning ("No changes to save.\n"); } }