annotate Mac/Compat/chdir.c @ 5817:48b94de85bf3 legacy-trunk

Extensive changes by AMK.
author Guido van Rossum <guido@python.org>
date Thu, 17 Jul 1997 16:29:42 +0000
parents 520e1855a24d
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
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
520e1855a24d Made more ppc-savvy
Jack Jansen <jack.jansen@cwi.nl>
parents: 2405
diff changeset
7 #ifdef __MWERKS__
520e1855a24d Made more ppc-savvy
Jack Jansen <jack.jansen@cwi.nl>
parents: 2405
diff changeset
8 /* XXXX All compilers should use this, really */
520e1855a24d Made more ppc-savvy
Jack Jansen <jack.jansen@cwi.nl>
parents: 2405
diff changeset
9 #include <LowMem.h>
520e1855a24d Made more ppc-savvy
Jack Jansen <jack.jansen@cwi.nl>
parents: 2405
diff changeset
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
520e1855a24d Made more ppc-savvy
Jack Jansen <jack.jansen@cwi.nl>
parents: 2405
diff changeset
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
520e1855a24d Made more ppc-savvy
Jack Jansen <jack.jansen@cwi.nl>
parents: 2405
diff changeset
33 #ifdef __MWERKS__
520e1855a24d Made more ppc-savvy
Jack Jansen <jack.jansen@cwi.nl>
parents: 2405
diff changeset
34 LMSetSFSaveDisk(-pb.ioWDVRefNum);
520e1855a24d Made more ppc-savvy
Jack Jansen <jack.jansen@cwi.nl>
parents: 2405
diff changeset
35 LMSetCurDirStore(pb.ioWDDirID);
520e1855a24d Made more ppc-savvy
Jack Jansen <jack.jansen@cwi.nl>
parents: 2405
diff changeset
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
520e1855a24d Made more ppc-savvy
Jack Jansen <jack.jansen@cwi.nl>
parents: 2405
diff changeset
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 }