Mercurial > cpython-lru_cache-weakref
annotate Mac/Compat/chdir.c @ 4566:6403c94de50d legacy-trunk
Added safeguard against failure in __del__.
| author | Guido van Rossum <guido@python.org> |
|---|---|
| date | Wed, 27 Nov 1996 19:39:58 +0000 |
| parents | 520e1855a24d |
| children |
| rev | line source |
|---|---|
|
1795
fa8bbd09f2e6
Updates for THINK C 6.0. Moved the necessary UNIX emulation routines here.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1 /* Chdir for the Macintosh. |
|
fa8bbd09f2e6
Updates for THINK C 6.0. Moved the necessary UNIX emulation routines here.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
2 Public domain by Guido van Rossum, CWI, Amsterdam (July 1987). |
|
fa8bbd09f2e6
Updates for THINK C 6.0. Moved the necessary UNIX emulation routines here.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
3 Pathnames must be Macintosh paths, with colons as separators. */ |
|
fa8bbd09f2e6
Updates for THINK C 6.0. Moved the necessary UNIX emulation routines here.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
4 |
|
fa8bbd09f2e6
Updates for THINK C 6.0. Moved the necessary UNIX emulation routines here.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
5 #include "macdefs.h" |
|
fa8bbd09f2e6
Updates for THINK C 6.0. Moved the necessary UNIX emulation routines here.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
6 |
| 2870 | 7 #ifdef __MWERKS__ |
| 8 /* XXXX All compilers should use this, really */ | |
| 9 #include <LowMem.h> | |
| 10 #else | |
|
2405
0b62b53d43f8
also set cur dir for standard get/put file
Guido van Rossum <guido@python.org>
parents:
2177
diff
changeset
|
11 /* Last directory used by Standard File */ |
|
0b62b53d43f8
also set cur dir for standard get/put file
Guido van Rossum <guido@python.org>
parents:
2177
diff
changeset
|
12 #define SFSaveDisk (*(short *)0x214) |
|
0b62b53d43f8
also set cur dir for standard get/put file
Guido van Rossum <guido@python.org>
parents:
2177
diff
changeset
|
13 #define CurDirStore (*(long *)0x398) |
| 2870 | 14 #endif |
|
2405
0b62b53d43f8
also set cur dir for standard get/put file
Guido van Rossum <guido@python.org>
parents:
2177
diff
changeset
|
15 |
|
1795
fa8bbd09f2e6
Updates for THINK C 6.0. Moved the necessary UNIX emulation routines here.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
16 /* Change current directory. */ |
|
fa8bbd09f2e6
Updates for THINK C 6.0. Moved the necessary UNIX emulation routines here.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
17 |
|
fa8bbd09f2e6
Updates for THINK C 6.0. Moved the necessary UNIX emulation routines here.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
18 int |
|
fa8bbd09f2e6
Updates for THINK C 6.0. Moved the necessary UNIX emulation routines here.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
19 chdir(path) |
|
fa8bbd09f2e6
Updates for THINK C 6.0. Moved the necessary UNIX emulation routines here.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
20 char *path; |
|
fa8bbd09f2e6
Updates for THINK C 6.0. Moved the necessary UNIX emulation routines here.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
21 { |
|
fa8bbd09f2e6
Updates for THINK C 6.0. Moved the necessary UNIX emulation routines here.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
22 WDPBRec pb; |
|
fa8bbd09f2e6
Updates for THINK C 6.0. Moved the necessary UNIX emulation routines here.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
23 |
|
2177
9f500a34c355
Some of these were overwriting their argument with a pascal
Jack Jansen <jack.jansen@cwi.nl>
parents:
1795
diff
changeset
|
24 pb.ioNamePtr= (StringPtr) Pstring(path); |
|
1795
fa8bbd09f2e6
Updates for THINK C 6.0. Moved the necessary UNIX emulation routines here.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
25 pb.ioVRefNum= 0; |
|
fa8bbd09f2e6
Updates for THINK C 6.0. Moved the necessary UNIX emulation routines here.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
26 pb.ioWDDirID= 0; |
|
fa8bbd09f2e6
Updates for THINK C 6.0. Moved the necessary UNIX emulation routines here.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
27 if (PBHSetVol(&pb, FALSE) != noErr) { |
|
fa8bbd09f2e6
Updates for THINK C 6.0. Moved the necessary UNIX emulation routines here.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
28 errno= ENOENT; |
|
fa8bbd09f2e6
Updates for THINK C 6.0. Moved the necessary UNIX emulation routines here.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
29 return -1; |
|
fa8bbd09f2e6
Updates for THINK C 6.0. Moved the necessary UNIX emulation routines here.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
30 } |
|
2405
0b62b53d43f8
also set cur dir for standard get/put file
Guido van Rossum <guido@python.org>
parents:
2177
diff
changeset
|
31 if (PBHGetVol(&pb, FALSE) == noErr) { |
|
0b62b53d43f8
also set cur dir for standard get/put file
Guido van Rossum <guido@python.org>
parents:
2177
diff
changeset
|
32 /* Set the Standard File directory */ |
| 2870 | 33 #ifdef __MWERKS__ |
| 34 LMSetSFSaveDisk(-pb.ioWDVRefNum); | |
| 35 LMSetCurDirStore(pb.ioWDDirID); | |
| 36 #else | |
|
2405
0b62b53d43f8
also set cur dir for standard get/put file
Guido van Rossum <guido@python.org>
parents:
2177
diff
changeset
|
37 SFSaveDisk= -pb.ioWDVRefNum; |
|
0b62b53d43f8
also set cur dir for standard get/put file
Guido van Rossum <guido@python.org>
parents:
2177
diff
changeset
|
38 CurDirStore= pb.ioWDDirID; |
| 2870 | 39 #endif |
|
2405
0b62b53d43f8
also set cur dir for standard get/put file
Guido van Rossum <guido@python.org>
parents:
2177
diff
changeset
|
40 } |
|
1795
fa8bbd09f2e6
Updates for THINK C 6.0. Moved the necessary UNIX emulation routines here.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
41 return 0; |
|
fa8bbd09f2e6
Updates for THINK C 6.0. Moved the necessary UNIX emulation routines here.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
42 } |
