Ditched '_find_SET()', since it was a no-value-added wrapper around
[python/dscho.git] / Mac / Compat / chdir.c
blob056080052f2c44d6d571af16341cd627da0f676f
1 /* Chdir for the Macintosh.
2 Public domain by Guido van Rossum, CWI, Amsterdam (July 1987).
3 Pathnames must be Macintosh paths, with colons as separators. */
5 #include "macdefs.h"
7 #ifdef __MWERKS__
8 /* XXXX All compilers should use this, really */
9 #include <LowMem.h>
10 #else
11 /* Last directory used by Standard File */
12 #define SFSaveDisk (*(short *)0x214)
13 #define CurDirStore (*(long *)0x398)
14 #endif
16 /* Change current directory. */
18 int
19 chdir(path)
20 char *path;
22 WDPBRec pb;
24 pb.ioNamePtr= (StringPtr) Pstring(path);
25 pb.ioVRefNum= 0;
26 pb.ioWDDirID= 0;
27 if (PBHSetVol(&pb, FALSE) != noErr) {
28 errno= ENOENT;
29 return -1;
31 if (PBHGetVol(&pb, FALSE) == noErr) {
32 /* Set the Standard File directory */
33 #ifdef __MWERKS__
34 LMSetSFSaveDisk(-pb.ioWDVRefNum);
35 LMSetCurDirStore(pb.ioWDDirID);
36 #else
37 SFSaveDisk= -pb.ioWDVRefNum;
38 CurDirStore= pb.ioWDDirID;
39 #endif
41 return 0;