summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJust van Rossum <just@lettererror.com>1999-02-02 15:49:03 (GMT)
committerJust van Rossum <just@lettererror.com>1999-02-02 15:49:03 (GMT)
commit26a69db4c7d50299178c24b6f5e9b59dd12a6f66 (patch)
tree31d0d6537f2c6bde3a85281e579e34f433378d9f
parent9202755fcb1c26927930735e4f37f1f9571e7b06 (diff)
downloadcpython-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
-rw-r--r--Mac/Lib/preferences.py2
-rw-r--r--Mac/Python/macgetpath.c47
2 files changed, 38 insertions, 11 deletions
diff --git a/Mac/Lib/preferences.py b/Mac/Lib/preferences.py
index 810d9cc..b1e0948 100644
--- a/Mac/Lib/preferences.py
+++ b/Mac/Lib/preferences.py
@@ -205,7 +205,7 @@ class StrListLoader:
def preferencefile(filename, creator=None, type=None):
create = creator != None and type != None
vrefnum, dirid = macfs.FindFolder(MACFS.kOnSystemDisk, 'pref', create)
- fss = macfs.FSSpec((vrefnum, dirid, filename))
+ fss = macfs.FSSpec((vrefnum, dirid, ":Python:" + filename))
oldrf = Res.CurResFile()
if create:
try:
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;
}