diff options
author | Just van Rossum <just@lettererror.com> | 1999-02-02 15:49:03 (GMT) |
---|---|---|
committer | Just van Rossum <just@lettererror.com> | 1999-02-02 15:49:03 (GMT) |
commit | 26a69db4c7d50299178c24b6f5e9b59dd12a6f66 (patch) | |
tree | 31d0d6537f2c6bde3a85281e579e34f433378d9f /Mac/Python | |
parent | 9202755fcb1c26927930735e4f37f1f9571e7b06 (diff) | |
download | cpython-26a69db4c7d50299178c24b6f5e9b59dd12a6f66.zip cpython-26a69db4c7d50299178c24b6f5e9b59dd12a6f66.tar.gz cpython-26a69db4c7d50299178c24b6f5e9b59dd12a6f66.tar.bz2 |
put the preferences file in a folder called "Python" inside the prefs folder, just like the IDE does -- jvr
Diffstat (limited to 'Mac/Python')
-rw-r--r-- | Mac/Python/macgetpath.c | 47 |
1 files changed, 37 insertions, 10 deletions
diff --git a/Mac/Python/macgetpath.c b/Mac/Python/macgetpath.c index e84766f..02f9b48 100644 --- a/Mac/Python/macgetpath.c +++ b/Mac/Python/macgetpath.c @@ -73,30 +73,57 @@ getpreffilefss(FSSpec *fssp) static FSSpec fss; short prefdirRefNum; long prefdirDirID; + long pyprefdirDirID; Handle namehandle; + OSErr err; if ( !diditbefore ) { - if ( FindFolder(kOnSystemDisk, 'pref', kDontCreateFolder, &prefdirRefNum, - &prefdirDirID) != noErr ) { - /* Something wrong with preferences folder */ - (void)StopAlert(NOPREFDIR_ID, NULL); - exit(1); - } - if ( (namehandle=GetNamedResource('STR ', PREFFILENAME_NAME)) == NULL ) { (void)StopAlert(NOPREFNAME_ID, NULL); exit(1); } - HLock(namehandle); 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); + if ( FindFolder(kOnSystemDisk, 'pref', kDontCreateFolder, &prefdirRefNum, + &prefdirDirID) != noErr ) { + /* Something wrong with preferences folder */ + (void)StopAlert(NOPREFDIR_ID, NULL); + exit(1); + } + /* make fsspec for the "Python" folder inside the prefs folder */ + err = FSMakeFSSpec(prefdirRefNum, prefdirDirID, "\pPython", &fss); + if (err == fnfErr) { + /* it doesn't exist: create it */ + err = FSpDirCreate(&fss, smSystemScript, &pyprefdirDirID); + } else { + /* it does exist, now find out the dirID of the Python prefs folder, brrr. */ + CInfoPBRec info; + info.dirInfo.ioVRefNum = fss.vRefNum; + info.dirInfo.ioDrDirID = fss.parID; + info.dirInfo.ioNamePtr = fss.name; + info.dirInfo.ioFDirIndex = 0; + info.dirInfo.ioACUser = 0; + err = PBGetCatInfo(&info, 0); + if (err == noErr) { + pyprefdirDirID = info.dirInfo.ioDrDirID; + } + } + if (err != noErr) { + (void)StopAlert(NOPREFDIR_ID, NULL); + exit(1); + } + HLock(namehandle); + err = FSMakeFSSpec(fss.vRefNum, pyprefdirDirID, (unsigned char *)*namehandle, &fss); + HUnlock(namehandle); + if (err != noErr && err != fnfErr) { + (void)StopAlert(NOPREFDIR_ID, NULL); + exit(1); + } } - HUnlock(namehandle); ReleaseResource(namehandle); diditbefore = 1; } |