@@ -31,6 +31,7 @@ OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
3131#include <Folders.h>
3232#include <StandardFile.h>
3333#include <Aliases.h>
34+ #include <LowMem.h>
3435
3536#include "nfullpath.h"
3637
@@ -689,6 +690,33 @@ mfs_StandardPutFile(self, args)
689690 return mkvalue ("(Oi)" ,newmfssobject (& reply .sfFile ), reply .sfGood );
690691}
691692
693+ /*
694+ ** Set initial directory for file dialogs */
695+ static object *
696+ mfs_SetFolder (self , args )
697+ object * self ;
698+ object * args ;
699+ {
700+ FSSpec spec ;
701+ FSSpec ospec ;
702+ short orefnum ;
703+ long oparid ;
704+
705+ /* Get old values */
706+ orefnum = - LMGetSFSaveDisk ();
707+ oparid = LMGetCurDirStore ();
708+ (void )FSMakeFSSpec (orefnum , oparid , "\pplaceholder" , & ospec );
709+
710+ /* Go to working directory by default */
711+ (void )FSMakeFSSpec (0 , 0 , "\p:placeholder" , & spec );
712+ if (!newgetargs (args , "|O&" , PyMac_GetFSSpec , & spec ))
713+ return NULL ;
714+ /* Set standard-file working directory */
715+ LMSetSFSaveDisk (- spec .vRefNum );
716+ LMSetCurDirStore (spec .parID );
717+ return (object * )newmfssobject (& ospec );
718+ }
719+
692720static object *
693721mfs_FSSpec (self , args )
694722 object * self ; /* Not used */
@@ -794,6 +822,7 @@ static struct methodlist mfs_methods[] = {
794822 {"PromptGetFile" , mfs_PromptGetFile , 1 },
795823 {"StandardPutFile" , mfs_StandardPutFile , 1 },
796824 {"GetDirectory" , mfs_GetDirectory , 1 },
825+ {"SetFolder" , mfs_SetFolder , 1 },
797826 {"FSSpec" , mfs_FSSpec , 1 },
798827 {"RawFSSpec" , mfs_RawFSSpec , 1 },
799828 {"RawAlias" , mfs_RawAlias , 1 },
0 commit comments