diff options
author | Jack Jansen <jack.jansen@cwi.nl> | 1998-07-13 13:38:29 (GMT) |
---|---|---|
committer | Jack Jansen <jack.jansen@cwi.nl> | 1998-07-13 13:38:29 (GMT) |
commit | ac82b6a041942de19f11f8929da9a5f9d9597212 (patch) | |
tree | a1ce040a59b29b83786dd0f459846c653df78c75 | |
parent | 1e2260fcb4647ec84753427e1a92c59e8f0c0171 (diff) | |
download | cpython-ac82b6a041942de19f11f8929da9a5f9d9597212.zip cpython-ac82b6a041942de19f11f8929da9a5f9d9597212.tar.gz cpython-ac82b6a041942de19f11f8929da9a5f9d9597212.tar.bz2 |
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.
-rw-r--r-- | Mac/Python/macgetpath.c | 17 |
1 files changed, 13 insertions, 4 deletions
diff --git a/Mac/Python/macgetpath.c b/Mac/Python/macgetpath.c index 80918fd..70a1b69 100644 --- a/Mac/Python/macgetpath.c +++ b/Mac/Python/macgetpath.c @@ -65,10 +65,11 @@ PERFORMANCE OF THIS SOFTWARE. :Lib:test\n\ :Lib:mac" -static void +static int getpreffilefss(FSSpec *fssp) { static int diditbefore=0; + static int rv = 1; static FSSpec fss; short prefdirRefNum; long prefdirDirID; @@ -88,12 +89,19 @@ getpreffilefss(FSSpec *fssp) } 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); ReleaseResource(namehandle); diditbefore = 1; } *fssp = fss; + return rv; } char * @@ -162,7 +170,8 @@ PyMac_OpenPrefFile() short prefrh; OSErr err; - getpreffilefss(&dirspec); + if ( !getpreffilefss(&dirspec)) + return -1; prefrh = FSpOpenResFile(&dirspec, fsRdWrShPerm); if ( prefrh < 0 ) { #if 0 @@ -225,7 +234,7 @@ PyMac_GetPythonDir() prefrh = PyMac_OpenPrefFile(); handle = (AliasHandle)Get1Resource('alis', PYTHONHOME_ID); if ( handle == NULL ) { - (void)StopAlert(BADPREFFILE_ID, NULL); + /* (void)StopAlert(BADPREFFILE_ID, NULL); */ diditbefore=1; return ":"; } |