blob: bc9a30354f187f71c253c818539ab162fb5cf0cb [file] [log] [blame]
Guido van Rossumd4d77281994-08-19 10:51:31 +00001/* 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. */
4
5#include "macdefs.h"
6
Guido van Rossumbcf3b561995-02-20 23:41:35 +00007/* Last directory used by Standard File */
8#define SFSaveDisk (*(short *)0x214)
9#define CurDirStore (*(long *)0x398)
10
Guido van Rossumd4d77281994-08-19 10:51:31 +000011/* Change current directory. */
12
13int
14chdir(path)
15 char *path;
16{
17 WDPBRec pb;
Guido van Rossumd4d77281994-08-19 10:51:31 +000018
Jack Jansen67132b31995-01-18 13:55:41 +000019 pb.ioNamePtr= (StringPtr) Pstring(path);
Guido van Rossumd4d77281994-08-19 10:51:31 +000020 pb.ioVRefNum= 0;
21 pb.ioWDDirID= 0;
22 if (PBHSetVol(&pb, FALSE) != noErr) {
23 errno= ENOENT;
24 return -1;
25 }
Guido van Rossumbcf3b561995-02-20 23:41:35 +000026 if (PBHGetVol(&pb, FALSE) == noErr) {
27 /* Set the Standard File directory */
28 SFSaveDisk= -pb.ioWDVRefNum;
29 CurDirStore= pb.ioWDDirID;
30 }
Guido van Rossumd4d77281994-08-19 10:51:31 +000031 return 0;
32}