summaryrefslogtreecommitdiffstats
path: root/Mac/Compat/chdir.c
diff options
context:
space:
mode:
Diffstat (limited to 'Mac/Compat/chdir.c')
-rw-r--r--Mac/Compat/chdir.c26
1 files changed, 26 insertions, 0 deletions
diff --git a/Mac/Compat/chdir.c b/Mac/Compat/chdir.c
new file mode 100644
index 0000000..b8ec6d7
--- /dev/null
+++ b/Mac/Compat/chdir.c
@@ -0,0 +1,26 @@
+/* Chdir for the Macintosh.
+ Public domain by Guido van Rossum, CWI, Amsterdam (July 1987).
+ Pathnames must be Macintosh paths, with colons as separators. */
+
+#include "macdefs.h"
+
+/* Change current directory. */
+
+int
+chdir(path)
+ char *path;
+{
+ WDPBRec pb;
+ char name[MAXPATH];
+
+ strncpy(name, path, sizeof name);
+ name[MAXPATH-1]= EOS;
+ pb.ioNamePtr= (StringPtr) c2pstr(name);
+ pb.ioVRefNum= 0;
+ pb.ioWDDirID= 0;
+ if (PBHSetVol(&pb, FALSE) != noErr) {
+ errno= ENOENT;
+ return -1;
+ }
+ return 0;
+}