Commit ac82b6a0 authored by Jack Jansen's avatar Jack Jansen

If the preference filename resource is empty don't try to open or

create the preferences file. This is so that frozen programs don't
interfere with an existing Python installation, or leave turds in the
Preferences folder.
parent 1e2260fc
...@@ -65,10 +65,11 @@ PERFORMANCE OF THIS SOFTWARE. ...@@ -65,10 +65,11 @@ PERFORMANCE OF THIS SOFTWARE.
:Lib:test\n\ :Lib:test\n\
:Lib:mac" :Lib:mac"
static void static int
getpreffilefss(FSSpec *fssp) getpreffilefss(FSSpec *fssp)
{ {
static int diditbefore=0; static int diditbefore=0;
static int rv = 1;
static FSSpec fss; static FSSpec fss;
short prefdirRefNum; short prefdirRefNum;
long prefdirDirID; long prefdirDirID;
...@@ -88,12 +89,19 @@ getpreffilefss(FSSpec *fssp) ...@@ -88,12 +89,19 @@ getpreffilefss(FSSpec *fssp)
} }
HLock(namehandle); HLock(namehandle);
(void)FSMakeFSSpec(prefdirRefNum, prefdirDirID, (unsigned char *)*namehandle, &fss); if ( **namehandle == '\0' ) {
/* Empty string means don't use preferences file */
rv = 0;
} else {
/* There is a filename, construct the fsspec */
(void)FSMakeFSSpec(prefdirRefNum, prefdirDirID, (unsigned char *)*namehandle, &fss);
}
HUnlock(namehandle); HUnlock(namehandle);
ReleaseResource(namehandle); ReleaseResource(namehandle);
diditbefore = 1; diditbefore = 1;
} }
*fssp = fss; *fssp = fss;
return rv;
} }
char * char *
...@@ -162,7 +170,8 @@ PyMac_OpenPrefFile() ...@@ -162,7 +170,8 @@ PyMac_OpenPrefFile()
short prefrh; short prefrh;
OSErr err; OSErr err;
getpreffilefss(&dirspec); if ( !getpreffilefss(&dirspec))
return -1;
prefrh = FSpOpenResFile(&dirspec, fsRdWrShPerm); prefrh = FSpOpenResFile(&dirspec, fsRdWrShPerm);
if ( prefrh < 0 ) { if ( prefrh < 0 ) {
#if 0 #if 0
...@@ -225,7 +234,7 @@ PyMac_GetPythonDir() ...@@ -225,7 +234,7 @@ PyMac_GetPythonDir()
prefrh = PyMac_OpenPrefFile(); prefrh = PyMac_OpenPrefFile();
handle = (AliasHandle)Get1Resource('alis', PYTHONHOME_ID); handle = (AliasHandle)Get1Resource('alis', PYTHONHOME_ID);
if ( handle == NULL ) { if ( handle == NULL ) {
(void)StopAlert(BADPREFFILE_ID, NULL); /* (void)StopAlert(BADPREFFILE_ID, NULL); */
diditbefore=1; diditbefore=1;
return ":"; return ":";
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment