Mercurial > cpython-lru_cache-weakref
annotate Mac/Modules/macmodule.c @ 17322:bd110eadc19a legacy-trunk
One-liner critical fix from Jim Fulton: Eric's string-method crusade
got the order backwards in a line (for .find()).
| author | Tim Peters <tim.peters@gmail.com> |
|---|---|
| date | Thu, 05 Apr 2001 22:26:23 +0000 |
| parents | b1b0a703ec4e |
| children | 8cd8741ebec0 |
| rev | line source |
|---|---|
| 1495 | 1 /*********************************************************** |
|
5079
d6b292a33cfe
Added/updated copyright notices
Jack Jansen <jack.jansen@cwi.nl>
parents:
5071
diff
changeset
|
2 Copyright 1991-1997 by Stichting Mathematisch Centrum, Amsterdam, |
| 2091 | 3 The Netherlands. |
| 1495 | 4 |
| 5 All Rights Reserved | |
| 6 | |
| 7 Permission to use, copy, modify, and distribute this software and its | |
| 8 documentation for any purpose and without fee is hereby granted, | |
| 9 provided that the above copyright notice appear in all copies and that | |
| 10 both that copyright notice and this permission notice appear in | |
| 11 supporting documentation, and that the names of Stichting Mathematisch | |
| 12 Centrum or CWI not be used in advertising or publicity pertaining to | |
| 13 distribution of the software without specific, written prior permission. | |
| 14 | |
| 15 STICHTING MATHEMATISCH CENTRUM DISCLAIMS ALL WARRANTIES WITH REGARD TO | |
| 16 THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND | |
| 17 FITNESS, IN NO EVENT SHALL STICHTING MATHEMATISCH CENTRUM BE LIABLE | |
| 18 FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES | |
| 19 WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN | |
| 20 ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT | |
| 21 OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. | |
| 22 | |
| 23 ******************************************************************/ | |
| 24 | |
|
1620
8454579ab52f
As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents:
1522
diff
changeset
|
25 /* Mac module implementation */ |
| 1495 | 26 |
| 5071 | 27 #include "Python.h" |
|
1620
8454579ab52f
As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents:
1522
diff
changeset
|
28 #include "ceval.h" |
| 1495 | 29 |
|
1620
8454579ab52f
As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents:
1522
diff
changeset
|
30 #include <stdio.h> |
|
8454579ab52f
As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents:
1522
diff
changeset
|
31 #include <string.h> |
|
8454579ab52f
As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents:
1522
diff
changeset
|
32 #include <errno.h> |
|
1822
76d0f2b3b9ee
Completed (hopefully) the unification of THINK 6.0 and MPW 3.2
Guido van Rossum <guido@python.org>
parents:
1821
diff
changeset
|
33 |
|
15835
b1b0a703ec4e
xstat() will never be implemented under Carbon. Fortunately it also doesn't appear to be used anywhere.
Jack Jansen <jack.jansen@cwi.nl>
parents:
14205
diff
changeset
|
34 #if !TARGET_API_MAC_CARBON |
|
b1b0a703ec4e
xstat() will never be implemented under Carbon. Fortunately it also doesn't appear to be used anywhere.
Jack Jansen <jack.jansen@cwi.nl>
parents:
14205
diff
changeset
|
35 /* Skip for Carbon */ |
|
4414
02a68d623805
Fixed xstat to again include resroucefork size, creator, type. Obtain
Jack Jansen <jack.jansen@cwi.nl>
parents:
3942
diff
changeset
|
36 #include "macstat.h" |
|
12836
3fe304050434
Made the core toolbox modules carbon-compatible using the new greylist feature of bgen: non-carbon methods are still included in non-carbon MacPython. The issue of backward compatibility of Python code is still open.
Jack Jansen <jack.jansen@cwi.nl>
parents:
12686
diff
changeset
|
37 #endif |
|
3fe304050434
Made the core toolbox modules carbon-compatible using the new greylist feature of bgen: non-carbon methods are still included in non-carbon MacPython. The issue of backward compatibility of Python code is still open.
Jack Jansen <jack.jansen@cwi.nl>
parents:
12686
diff
changeset
|
38 |
| 3394 | 39 #ifdef USE_GUSI |
|
4414
02a68d623805
Fixed xstat to again include resroucefork size, creator, type. Obtain
Jack Jansen <jack.jansen@cwi.nl>
parents:
3942
diff
changeset
|
40 /* Remove defines from macstat.h */ |
|
02a68d623805
Fixed xstat to again include resroucefork size, creator, type. Obtain
Jack Jansen <jack.jansen@cwi.nl>
parents:
3942
diff
changeset
|
41 #undef S_IFMT |
|
02a68d623805
Fixed xstat to again include resroucefork size, creator, type. Obtain
Jack Jansen <jack.jansen@cwi.nl>
parents:
3942
diff
changeset
|
42 #undef S_IFDIR |
|
02a68d623805
Fixed xstat to again include resroucefork size, creator, type. Obtain
Jack Jansen <jack.jansen@cwi.nl>
parents:
3942
diff
changeset
|
43 #undef S_IFREG |
|
02a68d623805
Fixed xstat to again include resroucefork size, creator, type. Obtain
Jack Jansen <jack.jansen@cwi.nl>
parents:
3942
diff
changeset
|
44 #undef S_IREAD |
|
02a68d623805
Fixed xstat to again include resroucefork size, creator, type. Obtain
Jack Jansen <jack.jansen@cwi.nl>
parents:
3942
diff
changeset
|
45 #undef S_IWRITE |
|
02a68d623805
Fixed xstat to again include resroucefork size, creator, type. Obtain
Jack Jansen <jack.jansen@cwi.nl>
parents:
3942
diff
changeset
|
46 #undef S_IEXEC |
|
02a68d623805
Fixed xstat to again include resroucefork size, creator, type. Obtain
Jack Jansen <jack.jansen@cwi.nl>
parents:
3942
diff
changeset
|
47 |
|
12284
9c96e5d437a8
Started on GUSI2 and threading support.
Jack Jansen <jack.jansen@cwi.nl>
parents:
7434
diff
changeset
|
48 #ifdef USE_GUSI1 |
| 3400 | 49 #include <GUSI.h> |
|
12284
9c96e5d437a8
Started on GUSI2 and threading support.
Jack Jansen <jack.jansen@cwi.nl>
parents:
7434
diff
changeset
|
50 #endif /* USE_GUSI1 */ |
| 3394 | 51 #include <sys/types.h> |
|
12284
9c96e5d437a8
Started on GUSI2 and threading support.
Jack Jansen <jack.jansen@cwi.nl>
parents:
7434
diff
changeset
|
52 #include <sys/stat.h> |
|
9c96e5d437a8
Started on GUSI2 and threading support.
Jack Jansen <jack.jansen@cwi.nl>
parents:
7434
diff
changeset
|
53 #else /* USE_GUSI */ |
|
15835
b1b0a703ec4e
xstat() will never be implemented under Carbon. Fortunately it also doesn't appear to be used anywhere.
Jack Jansen <jack.jansen@cwi.nl>
parents:
14205
diff
changeset
|
54 #if !TARGET_API_MAC_CARBON |
|
12284
9c96e5d437a8
Started on GUSI2 and threading support.
Jack Jansen <jack.jansen@cwi.nl>
parents:
7434
diff
changeset
|
55 #define stat macstat |
|
12836
3fe304050434
Made the core toolbox modules carbon-compatible using the new greylist feature of bgen: non-carbon methods are still included in non-carbon MacPython. The issue of backward compatibility of Python code is still open.
Jack Jansen <jack.jansen@cwi.nl>
parents:
12686
diff
changeset
|
56 #endif |
|
12284
9c96e5d437a8
Started on GUSI2 and threading support.
Jack Jansen <jack.jansen@cwi.nl>
parents:
7434
diff
changeset
|
57 #endif /* USE_GUSI */ |
|
9c96e5d437a8
Started on GUSI2 and threading support.
Jack Jansen <jack.jansen@cwi.nl>
parents:
7434
diff
changeset
|
58 |
|
9c96e5d437a8
Started on GUSI2 and threading support.
Jack Jansen <jack.jansen@cwi.nl>
parents:
7434
diff
changeset
|
59 #ifdef USE_GUSI2 |
|
9c96e5d437a8
Started on GUSI2 and threading support.
Jack Jansen <jack.jansen@cwi.nl>
parents:
7434
diff
changeset
|
60 #define sync bad_sync |
|
9c96e5d437a8
Started on GUSI2 and threading support.
Jack Jansen <jack.jansen@cwi.nl>
parents:
7434
diff
changeset
|
61 #include <unistd.h> |
|
9c96e5d437a8
Started on GUSI2 and threading support.
Jack Jansen <jack.jansen@cwi.nl>
parents:
7434
diff
changeset
|
62 #include <fcntl.h> |
|
9c96e5d437a8
Started on GUSI2 and threading support.
Jack Jansen <jack.jansen@cwi.nl>
parents:
7434
diff
changeset
|
63 #undef sync |
|
9c96e5d437a8
Started on GUSI2 and threading support.
Jack Jansen <jack.jansen@cwi.nl>
parents:
7434
diff
changeset
|
64 int sync(void); |
| 3394 | 65 #else |
|
12686
bc96c912dce8
Fixed to work again without USE_GUSI
Jack Jansen <jack.jansen@cwi.nl>
parents:
12284
diff
changeset
|
66 #define mode_t int |
|
1620
8454579ab52f
As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents:
1522
diff
changeset
|
67 #include <fcntl.h> |
|
12836
3fe304050434
Made the core toolbox modules carbon-compatible using the new greylist feature of bgen: non-carbon methods are still included in non-carbon MacPython. The issue of backward compatibility of Python code is still open.
Jack Jansen <jack.jansen@cwi.nl>
parents:
12686
diff
changeset
|
68 #ifdef _POSIX |
|
3fe304050434
Made the core toolbox modules carbon-compatible using the new greylist feature of bgen: non-carbon methods are still included in non-carbon MacPython. The issue of backward compatibility of Python code is still open.
Jack Jansen <jack.jansen@cwi.nl>
parents:
12686
diff
changeset
|
69 #include <unistd.h> |
|
3fe304050434
Made the core toolbox modules carbon-compatible using the new greylist feature of bgen: non-carbon methods are still included in non-carbon MacPython. The issue of backward compatibility of Python code is still open.
Jack Jansen <jack.jansen@cwi.nl>
parents:
12686
diff
changeset
|
70 #include <stat.h> |
|
3fe304050434
Made the core toolbox modules carbon-compatible using the new greylist feature of bgen: non-carbon methods are still included in non-carbon MacPython. The issue of backward compatibility of Python code is still open.
Jack Jansen <jack.jansen@cwi.nl>
parents:
12686
diff
changeset
|
71 #endif |
|
2032
609bfb8ae7f5
Ported to MetroWerks, which misses file-descriptor like functionality.
Jack Jansen <jack.jansen@cwi.nl>
parents:
1822
diff
changeset
|
72 #endif |
|
1620
8454579ab52f
As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents:
1522
diff
changeset
|
73 |
| 3400 | 74 /* Optional routines, for some compiler/runtime combinations */ |
| 75 #if defined(USE_GUSI) || !defined(__MWERKS__) | |
| 76 #define WEHAVE_FDOPEN | |
| 77 #endif | |
| 78 #if defined(MPW) || defined(USE_GUSI) | |
| 79 #define WEHAVE_DUP | |
| 80 #endif | |
|
7434
3de0cb82e61a
Add fstat() if using GUSI
Jack Jansen <jack.jansen@cwi.nl>
parents:
6442
diff
changeset
|
81 #if defined(USE_GUSI) |
|
3de0cb82e61a
Add fstat() if using GUSI
Jack Jansen <jack.jansen@cwi.nl>
parents:
6442
diff
changeset
|
82 #define WEHAVE_FSTAT |
|
3de0cb82e61a
Add fstat() if using GUSI
Jack Jansen <jack.jansen@cwi.nl>
parents:
6442
diff
changeset
|
83 #endif |
|
2222
bbb56dc3b526
Make malloc stats routine available under MetroWerks
Jack Jansen <jack.jansen@cwi.nl>
parents:
2179
diff
changeset
|
84 |
|
1795
fa8bbd09f2e6
Updates for THINK C 6.0. Moved the necessary UNIX emulation routines here.
Guido van Rossum <guido@python.org>
parents:
1692
diff
changeset
|
85 #include "macdefs.h" |
| 3394 | 86 #ifdef USE_GUSI |
| 87 #include <dirent.h> | |
| 88 #else | |
|
1795
fa8bbd09f2e6
Updates for THINK C 6.0. Moved the necessary UNIX emulation routines here.
Guido van Rossum <guido@python.org>
parents:
1692
diff
changeset
|
89 #include "dirent.h" |
| 3394 | 90 #endif |
|
1620
8454579ab52f
As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents:
1522
diff
changeset
|
91 |
|
8454579ab52f
As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents:
1522
diff
changeset
|
92 #ifndef MAXPATHLEN |
|
8454579ab52f
As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents:
1522
diff
changeset
|
93 #define MAXPATHLEN 1024 |
|
8454579ab52f
As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents:
1522
diff
changeset
|
94 #endif |
|
8454579ab52f
As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents:
1522
diff
changeset
|
95 |
|
8454579ab52f
As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents:
1522
diff
changeset
|
96 /* Prototypes for Unix simulation on Mac */ |
|
8454579ab52f
As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents:
1522
diff
changeset
|
97 |
| 3400 | 98 #ifndef USE_GUSI |
| 99 | |
|
13542
ddd6138c9e6f
ANSIfication step 1: get rid of Py_PROTO and Py_FPROTO.
Jack Jansen <jack.jansen@cwi.nl>
parents:
12856
diff
changeset
|
100 int chdir(const char *path); |
|
ddd6138c9e6f
ANSIfication step 1: get rid of Py_PROTO and Py_FPROTO.
Jack Jansen <jack.jansen@cwi.nl>
parents:
12856
diff
changeset
|
101 int mkdir(const char *path, int mode); |
|
ddd6138c9e6f
ANSIfication step 1: get rid of Py_PROTO and Py_FPROTO.
Jack Jansen <jack.jansen@cwi.nl>
parents:
12856
diff
changeset
|
102 DIR * opendir(char *); |
|
ddd6138c9e6f
ANSIfication step 1: get rid of Py_PROTO and Py_FPROTO.
Jack Jansen <jack.jansen@cwi.nl>
parents:
12856
diff
changeset
|
103 void closedir(DIR *); |
|
ddd6138c9e6f
ANSIfication step 1: get rid of Py_PROTO and Py_FPROTO.
Jack Jansen <jack.jansen@cwi.nl>
parents:
12856
diff
changeset
|
104 struct dirent * readdir(DIR *); |
|
ddd6138c9e6f
ANSIfication step 1: get rid of Py_PROTO and Py_FPROTO.
Jack Jansen <jack.jansen@cwi.nl>
parents:
12856
diff
changeset
|
105 int rmdir(const char *path); |
|
ddd6138c9e6f
ANSIfication step 1: get rid of Py_PROTO and Py_FPROTO.
Jack Jansen <jack.jansen@cwi.nl>
parents:
12856
diff
changeset
|
106 int sync(void); |
| 3400 | 107 |
|
13542
ddd6138c9e6f
ANSIfication step 1: get rid of Py_PROTO and Py_FPROTO.
Jack Jansen <jack.jansen@cwi.nl>
parents:
12856
diff
changeset
|
108 int unlink(const char *); |
|
1620
8454579ab52f
As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents:
1522
diff
changeset
|
109 |
| 3400 | 110 #endif /* USE_GUSI */ |
| 111 | |
|
13542
ddd6138c9e6f
ANSIfication step 1: get rid of Py_PROTO and Py_FPROTO.
Jack Jansen <jack.jansen@cwi.nl>
parents:
12856
diff
changeset
|
112 char *getwd(char *); |
|
ddd6138c9e6f
ANSIfication step 1: get rid of Py_PROTO and Py_FPROTO.
Jack Jansen <jack.jansen@cwi.nl>
parents:
12856
diff
changeset
|
113 char *getbootvol(void); |
|
1620
8454579ab52f
As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents:
1522
diff
changeset
|
114 |
|
8454579ab52f
As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents:
1522
diff
changeset
|
115 |
| 5071 | 116 static PyObject *MacError; /* Exception mac.error */ |
|
1620
8454579ab52f
As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents:
1522
diff
changeset
|
117 |
|
8454579ab52f
As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents:
1522
diff
changeset
|
118 /* Set a MAC-specific error from errno, and return NULL */ |
|
8454579ab52f
As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents:
1522
diff
changeset
|
119 |
| 5071 | 120 static PyObject * |
|
1620
8454579ab52f
As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents:
1522
diff
changeset
|
121 mac_error() |
|
8454579ab52f
As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents:
1522
diff
changeset
|
122 { |
| 5071 | 123 return PyErr_SetFromErrno(MacError); |
|
1620
8454579ab52f
As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents:
1522
diff
changeset
|
124 } |
|
8454579ab52f
As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents:
1522
diff
changeset
|
125 |
|
8454579ab52f
As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents:
1522
diff
changeset
|
126 /* MAC generic methods */ |
| 1495 | 127 |
| 5071 | 128 static PyObject * |
|
1620
8454579ab52f
As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents:
1522
diff
changeset
|
129 mac_1str(args, func) |
| 5071 | 130 PyObject *args; |
|
13542
ddd6138c9e6f
ANSIfication step 1: get rid of Py_PROTO and Py_FPROTO.
Jack Jansen <jack.jansen@cwi.nl>
parents:
12856
diff
changeset
|
131 int (*func)(const char *); |
|
1620
8454579ab52f
As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents:
1522
diff
changeset
|
132 { |
|
8454579ab52f
As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents:
1522
diff
changeset
|
133 char *path1; |
|
8454579ab52f
As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents:
1522
diff
changeset
|
134 int res; |
| 5071 | 135 if (!PyArg_Parse(args, "s", &path1)) |
|
1620
8454579ab52f
As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents:
1522
diff
changeset
|
136 return NULL; |
| 5071 | 137 Py_BEGIN_ALLOW_THREADS |
|
1620
8454579ab52f
As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents:
1522
diff
changeset
|
138 res = (*func)(path1); |
| 5071 | 139 Py_END_ALLOW_THREADS |
|
1620
8454579ab52f
As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents:
1522
diff
changeset
|
140 if (res < 0) |
|
8454579ab52f
As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents:
1522
diff
changeset
|
141 return mac_error(); |
| 5071 | 142 Py_INCREF(Py_None); |
| 143 return Py_None; | |
|
1620
8454579ab52f
As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents:
1522
diff
changeset
|
144 } |
| 1495 | 145 |
| 5071 | 146 static PyObject * |
|
1620
8454579ab52f
As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents:
1522
diff
changeset
|
147 mac_2str(args, func) |
| 5071 | 148 PyObject *args; |
|
13542
ddd6138c9e6f
ANSIfication step 1: get rid of Py_PROTO and Py_FPROTO.
Jack Jansen <jack.jansen@cwi.nl>
parents:
12856
diff
changeset
|
149 int (*func)(const char *, const char *); |
|
1620
8454579ab52f
As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents:
1522
diff
changeset
|
150 { |
|
8454579ab52f
As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents:
1522
diff
changeset
|
151 char *path1, *path2; |
|
8454579ab52f
As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents:
1522
diff
changeset
|
152 int res; |
| 5071 | 153 if (!PyArg_Parse(args, "(ss)", &path1, &path2)) |
|
1620
8454579ab52f
As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents:
1522
diff
changeset
|
154 return NULL; |
| 5071 | 155 Py_BEGIN_ALLOW_THREADS |
|
1620
8454579ab52f
As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents:
1522
diff
changeset
|
156 res = (*func)(path1, path2); |
| 5071 | 157 Py_END_ALLOW_THREADS |
|
1620
8454579ab52f
As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents:
1522
diff
changeset
|
158 if (res < 0) |
|
8454579ab52f
As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents:
1522
diff
changeset
|
159 return mac_error(); |
| 5071 | 160 Py_INCREF(Py_None); |
| 161 return Py_None; | |
|
1620
8454579ab52f
As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents:
1522
diff
changeset
|
162 } |
| 1495 | 163 |
| 5071 | 164 static PyObject * |
|
1620
8454579ab52f
As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents:
1522
diff
changeset
|
165 mac_strint(args, func) |
| 5071 | 166 PyObject *args; |
|
13542
ddd6138c9e6f
ANSIfication step 1: get rid of Py_PROTO and Py_FPROTO.
Jack Jansen <jack.jansen@cwi.nl>
parents:
12856
diff
changeset
|
167 int (*func)(const char *, int); |
|
1620
8454579ab52f
As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents:
1522
diff
changeset
|
168 { |
|
8454579ab52f
As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents:
1522
diff
changeset
|
169 char *path; |
|
8454579ab52f
As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents:
1522
diff
changeset
|
170 int i; |
|
8454579ab52f
As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents:
1522
diff
changeset
|
171 int res; |
| 5071 | 172 if (!PyArg_Parse(args, "(si)", &path, &i)) |
|
1620
8454579ab52f
As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents:
1522
diff
changeset
|
173 return NULL; |
| 5071 | 174 Py_BEGIN_ALLOW_THREADS |
|
1620
8454579ab52f
As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents:
1522
diff
changeset
|
175 res = (*func)(path, i); |
| 5071 | 176 Py_END_ALLOW_THREADS |
|
1620
8454579ab52f
As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents:
1522
diff
changeset
|
177 if (res < 0) |
|
8454579ab52f
As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents:
1522
diff
changeset
|
178 return mac_error(); |
| 5071 | 179 Py_INCREF(Py_None); |
| 180 return Py_None; | |
|
1620
8454579ab52f
As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents:
1522
diff
changeset
|
181 } |
|
8454579ab52f
As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents:
1522
diff
changeset
|
182 |
| 5071 | 183 static PyObject * |
| 1495 | 184 mac_chdir(self, args) |
| 5071 | 185 PyObject *self; |
| 186 PyObject *args; | |
| 1495 | 187 { |
|
12284
9c96e5d437a8
Started on GUSI2 and threading support.
Jack Jansen <jack.jansen@cwi.nl>
parents:
7434
diff
changeset
|
188 #ifdef USE_GUSI1 |
| 5071 | 189 PyObject *rv; |
|
3433
578ca302a598
Replaced previous gusi-chdir() fix by a call to PyMac_FixGUSIcd()
Jack Jansen <jack.jansen@cwi.nl>
parents:
3405
diff
changeset
|
190 |
|
578ca302a598
Replaced previous gusi-chdir() fix by a call to PyMac_FixGUSIcd()
Jack Jansen <jack.jansen@cwi.nl>
parents:
3405
diff
changeset
|
191 /* Change MacOS's idea of wd too */ |
|
578ca302a598
Replaced previous gusi-chdir() fix by a call to PyMac_FixGUSIcd()
Jack Jansen <jack.jansen@cwi.nl>
parents:
3405
diff
changeset
|
192 rv = mac_1str(args, chdir); |
|
578ca302a598
Replaced previous gusi-chdir() fix by a call to PyMac_FixGUSIcd()
Jack Jansen <jack.jansen@cwi.nl>
parents:
3405
diff
changeset
|
193 PyMac_FixGUSIcd(); |
|
578ca302a598
Replaced previous gusi-chdir() fix by a call to PyMac_FixGUSIcd()
Jack Jansen <jack.jansen@cwi.nl>
parents:
3405
diff
changeset
|
194 return rv; |
|
578ca302a598
Replaced previous gusi-chdir() fix by a call to PyMac_FixGUSIcd()
Jack Jansen <jack.jansen@cwi.nl>
parents:
3405
diff
changeset
|
195 #else |
|
1620
8454579ab52f
As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents:
1522
diff
changeset
|
196 return mac_1str(args, chdir); |
|
3433
578ca302a598
Replaced previous gusi-chdir() fix by a call to PyMac_FixGUSIcd()
Jack Jansen <jack.jansen@cwi.nl>
parents:
3405
diff
changeset
|
197 #endif |
|
578ca302a598
Replaced previous gusi-chdir() fix by a call to PyMac_FixGUSIcd()
Jack Jansen <jack.jansen@cwi.nl>
parents:
3405
diff
changeset
|
198 |
|
1620
8454579ab52f
As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents:
1522
diff
changeset
|
199 } |
|
8454579ab52f
As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents:
1522
diff
changeset
|
200 |
| 5071 | 201 static PyObject * |
|
1620
8454579ab52f
As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents:
1522
diff
changeset
|
202 mac_close(self, args) |
| 5071 | 203 PyObject *self; |
| 204 PyObject *args; | |
|
1620
8454579ab52f
As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents:
1522
diff
changeset
|
205 { |
|
8454579ab52f
As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents:
1522
diff
changeset
|
206 int fd, res; |
| 5071 | 207 if (!PyArg_Parse(args, "i", &fd)) |
| 1495 | 208 return NULL; |
| 5071 | 209 Py_BEGIN_ALLOW_THREADS |
|
1620
8454579ab52f
As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents:
1522
diff
changeset
|
210 res = close(fd); |
| 5071 | 211 Py_END_ALLOW_THREADS |
|
12284
9c96e5d437a8
Started on GUSI2 and threading support.
Jack Jansen <jack.jansen@cwi.nl>
parents:
7434
diff
changeset
|
212 #ifndef USE_GUSI1 |
| 3400 | 213 /* GUSI gives surious errors here? */ |
|
1620
8454579ab52f
As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents:
1522
diff
changeset
|
214 if (res < 0) |
|
8454579ab52f
As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents:
1522
diff
changeset
|
215 return mac_error(); |
| 3400 | 216 #endif |
| 5071 | 217 Py_INCREF(Py_None); |
| 218 return Py_None; | |
| 1495 | 219 } |
| 220 | |
| 3400 | 221 #ifdef WEHAVE_DUP |
|
1622
812d0811fcf3
Walker's changes fixed so they work in THINK C 5
Guido van Rossum <guido@python.org>
parents:
1620
diff
changeset
|
222 |
| 5071 | 223 static PyObject * |
|
1620
8454579ab52f
As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents:
1522
diff
changeset
|
224 mac_dup(self, args) |
| 5071 | 225 PyObject *self; |
| 226 PyObject *args; | |
|
1620
8454579ab52f
As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents:
1522
diff
changeset
|
227 { |
|
8454579ab52f
As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents:
1522
diff
changeset
|
228 int fd; |
| 5071 | 229 if (!PyArg_Parse(args, "i", &fd)) |
|
1620
8454579ab52f
As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents:
1522
diff
changeset
|
230 return NULL; |
| 5071 | 231 Py_BEGIN_ALLOW_THREADS |
|
1620
8454579ab52f
As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents:
1522
diff
changeset
|
232 fd = dup(fd); |
| 5071 | 233 Py_END_ALLOW_THREADS |
|
1620
8454579ab52f
As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents:
1522
diff
changeset
|
234 if (fd < 0) |
|
8454579ab52f
As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents:
1522
diff
changeset
|
235 return mac_error(); |
| 5071 | 236 return PyInt_FromLong((long)fd); |
|
1620
8454579ab52f
As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents:
1522
diff
changeset
|
237 } |
|
8454579ab52f
As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents:
1522
diff
changeset
|
238 |
| 3400 | 239 #endif |
|
1821
40594f80ab3c
Intermediate version of changes after porting to MPW 3.2
Guido van Rossum <guido@python.org>
parents:
1808
diff
changeset
|
240 |
| 3400 | 241 #ifdef WEHAVE_FDOPEN |
| 5071 | 242 static PyObject * |
|
1620
8454579ab52f
As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents:
1522
diff
changeset
|
243 mac_fdopen(self, args) |
| 5071 | 244 PyObject *self; |
| 245 PyObject *args; | |
|
1620
8454579ab52f
As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents:
1522
diff
changeset
|
246 { |
|
13542
ddd6138c9e6f
ANSIfication step 1: get rid of Py_PROTO and Py_FPROTO.
Jack Jansen <jack.jansen@cwi.nl>
parents:
12856
diff
changeset
|
247 extern int fclose(FILE *); |
|
1620
8454579ab52f
As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents:
1522
diff
changeset
|
248 int fd; |
|
8454579ab52f
As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents:
1522
diff
changeset
|
249 char *mode; |
|
8454579ab52f
As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents:
1522
diff
changeset
|
250 FILE *fp; |
| 5071 | 251 if (!PyArg_Parse(args, "(is)", &fd, &mode)) |
|
1620
8454579ab52f
As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents:
1522
diff
changeset
|
252 return NULL; |
| 5071 | 253 Py_BEGIN_ALLOW_THREADS |
|
1620
8454579ab52f
As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents:
1522
diff
changeset
|
254 fp = fdopen(fd, mode); |
| 5071 | 255 Py_END_ALLOW_THREADS |
|
1620
8454579ab52f
As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents:
1522
diff
changeset
|
256 if (fp == NULL) |
|
8454579ab52f
As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents:
1522
diff
changeset
|
257 return mac_error(); |
| 5071 | 258 return PyFile_FromFile(fp, "(fdopen)", mode, fclose); |
|
1620
8454579ab52f
As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents:
1522
diff
changeset
|
259 } |
|
2032
609bfb8ae7f5
Ported to MetroWerks, which misses file-descriptor like functionality.
Jack Jansen <jack.jansen@cwi.nl>
parents:
1822
diff
changeset
|
260 #endif |
|
1620
8454579ab52f
As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents:
1522
diff
changeset
|
261 |
|
13608
a901c2c0166b
Test for TARGET_API_MAC_CARBON with #if in stead of #ifdef.
Jack Jansen <jack.jansen@cwi.nl>
parents:
13553
diff
changeset
|
262 #if !TARGET_API_MAC_CARBON |
| 5071 | 263 static PyObject * |
|
1620
8454579ab52f
As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents:
1522
diff
changeset
|
264 mac_getbootvol(self, args) |
| 5071 | 265 PyObject *self; |
| 266 PyObject *args; | |
|
1620
8454579ab52f
As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents:
1522
diff
changeset
|
267 { |
|
8454579ab52f
As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents:
1522
diff
changeset
|
268 char *res; |
| 5071 | 269 if (!PyArg_NoArgs(args)) |
|
1620
8454579ab52f
As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents:
1522
diff
changeset
|
270 return NULL; |
| 5071 | 271 Py_BEGIN_ALLOW_THREADS |
|
1620
8454579ab52f
As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents:
1522
diff
changeset
|
272 res = getbootvol(); |
| 5071 | 273 Py_END_ALLOW_THREADS |
|
1620
8454579ab52f
As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents:
1522
diff
changeset
|
274 if (res == NULL) |
|
8454579ab52f
As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents:
1522
diff
changeset
|
275 return mac_error(); |
| 5071 | 276 return PyString_FromString(res); |
|
1620
8454579ab52f
As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents:
1522
diff
changeset
|
277 } |
|
12836
3fe304050434
Made the core toolbox modules carbon-compatible using the new greylist feature of bgen: non-carbon methods are still included in non-carbon MacPython. The issue of backward compatibility of Python code is still open.
Jack Jansen <jack.jansen@cwi.nl>
parents:
12686
diff
changeset
|
278 #endif |
| 1495 | 279 |
| 5071 | 280 static PyObject * |
| 1495 | 281 mac_getcwd(self, args) |
| 5071 | 282 PyObject *self; |
| 283 PyObject *args; | |
| 1495 | 284 { |
|
1620
8454579ab52f
As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents:
1522
diff
changeset
|
285 char path[MAXPATHLEN]; |
|
8454579ab52f
As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents:
1522
diff
changeset
|
286 char *res; |
| 5071 | 287 if (!PyArg_NoArgs(args)) |
| 1495 | 288 return NULL; |
| 5071 | 289 Py_BEGIN_ALLOW_THREADS |
| 3400 | 290 #ifdef USE_GUSI |
| 291 res = getcwd(path, sizeof path); | |
| 292 #else | |
|
1620
8454579ab52f
As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents:
1522
diff
changeset
|
293 res = getwd(path); |
| 3400 | 294 #endif |
| 5071 | 295 Py_END_ALLOW_THREADS |
|
1620
8454579ab52f
As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents:
1522
diff
changeset
|
296 if (res == NULL) { |
| 5071 | 297 PyErr_SetString(MacError, path); |
| 1495 | 298 return NULL; |
| 299 } | |
| 5071 | 300 return PyString_FromString(res); |
| 1495 | 301 } |
| 302 | |
| 5071 | 303 static PyObject * |
| 1495 | 304 mac_listdir(self, args) |
| 5071 | 305 PyObject *self; |
| 306 PyObject *args; | |
| 1495 | 307 { |
|
1620
8454579ab52f
As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents:
1522
diff
changeset
|
308 char *name; |
| 5071 | 309 PyObject *d, *v; |
| 1495 | 310 DIR *dirp; |
|
1795
fa8bbd09f2e6
Updates for THINK C 6.0. Moved the necessary UNIX emulation routines here.
Guido van Rossum <guido@python.org>
parents:
1692
diff
changeset
|
311 struct dirent *ep; |
| 5071 | 312 if (!PyArg_Parse(args, "s", &name)) |
| 1495 | 313 return NULL; |
| 5071 | 314 Py_BEGIN_ALLOW_THREADS |
|
1620
8454579ab52f
As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents:
1522
diff
changeset
|
315 if ((dirp = opendir(name)) == NULL) { |
| 5071 | 316 Py_BLOCK_THREADS |
|
1620
8454579ab52f
As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents:
1522
diff
changeset
|
317 return mac_error(); |
|
8454579ab52f
As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents:
1522
diff
changeset
|
318 } |
| 5071 | 319 if ((d = PyList_New(0)) == NULL) { |
| 1495 | 320 closedir(dirp); |
| 5071 | 321 Py_BLOCK_THREADS |
| 1495 | 322 return NULL; |
| 323 } | |
| 324 while ((ep = readdir(dirp)) != NULL) { | |
| 5071 | 325 v = PyString_FromString(ep->d_name); |
| 1495 | 326 if (v == NULL) { |
| 5071 | 327 Py_DECREF(d); |
| 1495 | 328 d = NULL; |
| 329 break; | |
| 330 } | |
| 5071 | 331 if (PyList_Append(d, v) != 0) { |
| 332 Py_DECREF(v); | |
| 333 Py_DECREF(d); | |
| 1495 | 334 d = NULL; |
| 335 break; | |
| 336 } | |
| 5071 | 337 Py_DECREF(v); |
| 1495 | 338 } |
| 339 closedir(dirp); | |
| 5071 | 340 Py_END_ALLOW_THREADS |
|
1620
8454579ab52f
As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents:
1522
diff
changeset
|
341 |
| 1495 | 342 return d; |
| 343 } | |
| 344 | |
| 5071 | 345 static PyObject * |
|
1620
8454579ab52f
As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents:
1522
diff
changeset
|
346 mac_lseek(self, args) |
| 5071 | 347 PyObject *self; |
| 348 PyObject *args; | |
|
1620
8454579ab52f
As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents:
1522
diff
changeset
|
349 { |
|
8454579ab52f
As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents:
1522
diff
changeset
|
350 int fd; |
|
8454579ab52f
As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents:
1522
diff
changeset
|
351 int where; |
|
8454579ab52f
As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents:
1522
diff
changeset
|
352 int how; |
|
8454579ab52f
As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents:
1522
diff
changeset
|
353 long res; |
| 5071 | 354 if (!PyArg_Parse(args, "(iii)", &fd, &where, &how)) |
|
1620
8454579ab52f
As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents:
1522
diff
changeset
|
355 return NULL; |
| 5071 | 356 Py_BEGIN_ALLOW_THREADS |
|
1620
8454579ab52f
As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents:
1522
diff
changeset
|
357 res = lseek(fd, (long)where, how); |
| 5071 | 358 Py_END_ALLOW_THREADS |
|
1620
8454579ab52f
As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents:
1522
diff
changeset
|
359 if (res < 0) |
|
8454579ab52f
As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents:
1522
diff
changeset
|
360 return mac_error(); |
| 5071 | 361 return PyInt_FromLong(res); |
|
1620
8454579ab52f
As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents:
1522
diff
changeset
|
362 } |
| 3394 | 363 |
| 5071 | 364 static PyObject * |
| 1495 | 365 mac_mkdir(self, args) |
| 5071 | 366 PyObject *self; |
| 367 PyObject *args; | |
| 1495 | 368 { |
|
3405
c283447b985f
Mods by Guido: mkdir 2nd arg optional and remove as alias for unlink.
Jack Jansen <jack.jansen@cwi.nl>
parents:
3400
diff
changeset
|
369 int res; |
|
c283447b985f
Mods by Guido: mkdir 2nd arg optional and remove as alias for unlink.
Jack Jansen <jack.jansen@cwi.nl>
parents:
3400
diff
changeset
|
370 char *path; |
|
c283447b985f
Mods by Guido: mkdir 2nd arg optional and remove as alias for unlink.
Jack Jansen <jack.jansen@cwi.nl>
parents:
3400
diff
changeset
|
371 int mode = 0777; /* Unused */ |
| 5071 | 372 if (!PyArg_ParseTuple(args, "s|i", &path, &mode)) |
|
3405
c283447b985f
Mods by Guido: mkdir 2nd arg optional and remove as alias for unlink.
Jack Jansen <jack.jansen@cwi.nl>
parents:
3400
diff
changeset
|
373 return NULL; |
| 5071 | 374 Py_BEGIN_ALLOW_THREADS |
|
12284
9c96e5d437a8
Started on GUSI2 and threading support.
Jack Jansen <jack.jansen@cwi.nl>
parents:
7434
diff
changeset
|
375 #ifdef USE_GUSI1 |
|
3942
38684852376f
GUSI mkdir() lost its dummy second arg
Jack Jansen <jack.jansen@cwi.nl>
parents:
3433
diff
changeset
|
376 res = mkdir(path); |
|
38684852376f
GUSI mkdir() lost its dummy second arg
Jack Jansen <jack.jansen@cwi.nl>
parents:
3433
diff
changeset
|
377 #else |
|
3405
c283447b985f
Mods by Guido: mkdir 2nd arg optional and remove as alias for unlink.
Jack Jansen <jack.jansen@cwi.nl>
parents:
3400
diff
changeset
|
378 res = mkdir(path, mode); |
|
3942
38684852376f
GUSI mkdir() lost its dummy second arg
Jack Jansen <jack.jansen@cwi.nl>
parents:
3433
diff
changeset
|
379 #endif |
| 5071 | 380 Py_END_ALLOW_THREADS |
|
3405
c283447b985f
Mods by Guido: mkdir 2nd arg optional and remove as alias for unlink.
Jack Jansen <jack.jansen@cwi.nl>
parents:
3400
diff
changeset
|
381 if (res < 0) |
|
c283447b985f
Mods by Guido: mkdir 2nd arg optional and remove as alias for unlink.
Jack Jansen <jack.jansen@cwi.nl>
parents:
3400
diff
changeset
|
382 return mac_error(); |
| 5071 | 383 Py_INCREF(Py_None); |
| 384 return Py_None; | |
|
1620
8454579ab52f
As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents:
1522
diff
changeset
|
385 } |
|
8454579ab52f
As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents:
1522
diff
changeset
|
386 |
| 5071 | 387 static PyObject * |
|
1620
8454579ab52f
As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents:
1522
diff
changeset
|
388 mac_open(self, args) |
| 5071 | 389 PyObject *self; |
| 390 PyObject *args; | |
|
1620
8454579ab52f
As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents:
1522
diff
changeset
|
391 { |
| 1495 | 392 char *path; |
| 393 int mode; | |
|
1620
8454579ab52f
As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents:
1522
diff
changeset
|
394 int fd; |
| 5071 | 395 if (!PyArg_Parse(args, "(si)", &path, &mode)) |
| 1495 | 396 return NULL; |
| 5071 | 397 Py_BEGIN_ALLOW_THREADS |
|
1620
8454579ab52f
As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents:
1522
diff
changeset
|
398 fd = open(path, mode); |
| 5071 | 399 Py_END_ALLOW_THREADS |
|
1620
8454579ab52f
As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents:
1522
diff
changeset
|
400 if (fd < 0) |
|
8454579ab52f
As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents:
1522
diff
changeset
|
401 return mac_error(); |
| 5071 | 402 return PyInt_FromLong((long)fd); |
| 1495 | 403 } |
| 404 | |
| 5071 | 405 static PyObject * |
|
1620
8454579ab52f
As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents:
1522
diff
changeset
|
406 mac_read(self, args) |
| 5071 | 407 PyObject *self; |
| 408 PyObject *args; | |
|
1620
8454579ab52f
As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents:
1522
diff
changeset
|
409 { |
|
8454579ab52f
As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents:
1522
diff
changeset
|
410 int fd, size; |
| 5071 | 411 PyObject *buffer; |
| 412 if (!PyArg_Parse(args, "(ii)", &fd, &size)) | |
|
1620
8454579ab52f
As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents:
1522
diff
changeset
|
413 return NULL; |
| 5071 | 414 buffer = PyString_FromStringAndSize((char *)NULL, size); |
|
1620
8454579ab52f
As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents:
1522
diff
changeset
|
415 if (buffer == NULL) |
|
8454579ab52f
As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents:
1522
diff
changeset
|
416 return NULL; |
| 5071 | 417 Py_BEGIN_ALLOW_THREADS |
| 418 size = read(fd, PyString_AsString(buffer), size); | |
| 419 Py_END_ALLOW_THREADS | |
|
1620
8454579ab52f
As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents:
1522
diff
changeset
|
420 if (size < 0) { |
| 5071 | 421 Py_DECREF(buffer); |
|
1620
8454579ab52f
As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents:
1522
diff
changeset
|
422 return mac_error(); |
|
8454579ab52f
As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents:
1522
diff
changeset
|
423 } |
| 5071 | 424 _PyString_Resize(&buffer, size); |
|
1620
8454579ab52f
As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents:
1522
diff
changeset
|
425 return buffer; |
|
8454579ab52f
As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents:
1522
diff
changeset
|
426 } |
| 1495 | 427 |
| 5071 | 428 static PyObject * |
| 1495 | 429 mac_rename(self, args) |
| 5071 | 430 PyObject *self; |
| 431 PyObject *args; | |
| 1495 | 432 { |
|
1620
8454579ab52f
As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents:
1522
diff
changeset
|
433 return mac_2str(args, rename); |
| 1495 | 434 } |
| 435 | |
| 5071 | 436 static PyObject * |
| 1495 | 437 mac_rmdir(self, args) |
| 5071 | 438 PyObject *self; |
| 439 PyObject *args; | |
| 1495 | 440 { |
|
1620
8454579ab52f
As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents:
1522
diff
changeset
|
441 return mac_1str(args, rmdir); |
| 1495 | 442 } |
| 443 | |
| 5071 | 444 static PyObject * |
| 1495 | 445 mac_stat(self, args) |
| 5071 | 446 PyObject *self; |
| 447 PyObject *args; | |
| 1495 | 448 { |
|
4414
02a68d623805
Fixed xstat to again include resroucefork size, creator, type. Obtain
Jack Jansen <jack.jansen@cwi.nl>
parents:
3942
diff
changeset
|
449 struct stat st; |
| 1495 | 450 char *path; |
|
1620
8454579ab52f
As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents:
1522
diff
changeset
|
451 int res; |
| 5071 | 452 if (!PyArg_Parse(args, "s", &path)) |
| 1495 | 453 return NULL; |
| 5071 | 454 Py_BEGIN_ALLOW_THREADS |
|
4414
02a68d623805
Fixed xstat to again include resroucefork size, creator, type. Obtain
Jack Jansen <jack.jansen@cwi.nl>
parents:
3942
diff
changeset
|
455 res = stat(path, &st); |
| 5071 | 456 Py_END_ALLOW_THREADS |
|
1620
8454579ab52f
As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents:
1522
diff
changeset
|
457 if (res != 0) |
|
8454579ab52f
As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents:
1522
diff
changeset
|
458 return mac_error(); |
| 5071 | 459 return Py_BuildValue("(lllllllddd)", |
|
4414
02a68d623805
Fixed xstat to again include resroucefork size, creator, type. Obtain
Jack Jansen <jack.jansen@cwi.nl>
parents:
3942
diff
changeset
|
460 (long)st.st_mode, |
|
02a68d623805
Fixed xstat to again include resroucefork size, creator, type. Obtain
Jack Jansen <jack.jansen@cwi.nl>
parents:
3942
diff
changeset
|
461 (long)st.st_ino, |
|
02a68d623805
Fixed xstat to again include resroucefork size, creator, type. Obtain
Jack Jansen <jack.jansen@cwi.nl>
parents:
3942
diff
changeset
|
462 (long)st.st_dev, |
|
02a68d623805
Fixed xstat to again include resroucefork size, creator, type. Obtain
Jack Jansen <jack.jansen@cwi.nl>
parents:
3942
diff
changeset
|
463 (long)st.st_nlink, |
|
02a68d623805
Fixed xstat to again include resroucefork size, creator, type. Obtain
Jack Jansen <jack.jansen@cwi.nl>
parents:
3942
diff
changeset
|
464 (long)st.st_uid, |
|
02a68d623805
Fixed xstat to again include resroucefork size, creator, type. Obtain
Jack Jansen <jack.jansen@cwi.nl>
parents:
3942
diff
changeset
|
465 (long)st.st_gid, |
|
02a68d623805
Fixed xstat to again include resroucefork size, creator, type. Obtain
Jack Jansen <jack.jansen@cwi.nl>
parents:
3942
diff
changeset
|
466 (long)st.st_size, |
|
02a68d623805
Fixed xstat to again include resroucefork size, creator, type. Obtain
Jack Jansen <jack.jansen@cwi.nl>
parents:
3942
diff
changeset
|
467 (double)st.st_atime, |
|
02a68d623805
Fixed xstat to again include resroucefork size, creator, type. Obtain
Jack Jansen <jack.jansen@cwi.nl>
parents:
3942
diff
changeset
|
468 (double)st.st_mtime, |
|
02a68d623805
Fixed xstat to again include resroucefork size, creator, type. Obtain
Jack Jansen <jack.jansen@cwi.nl>
parents:
3942
diff
changeset
|
469 (double)st.st_ctime); |
|
7434
3de0cb82e61a
Add fstat() if using GUSI
Jack Jansen <jack.jansen@cwi.nl>
parents:
6442
diff
changeset
|
470 } |
|
3de0cb82e61a
Add fstat() if using GUSI
Jack Jansen <jack.jansen@cwi.nl>
parents:
6442
diff
changeset
|
471 |
|
3de0cb82e61a
Add fstat() if using GUSI
Jack Jansen <jack.jansen@cwi.nl>
parents:
6442
diff
changeset
|
472 #ifdef WEHAVE_FSTAT |
|
3de0cb82e61a
Add fstat() if using GUSI
Jack Jansen <jack.jansen@cwi.nl>
parents:
6442
diff
changeset
|
473 static PyObject * |
|
3de0cb82e61a
Add fstat() if using GUSI
Jack Jansen <jack.jansen@cwi.nl>
parents:
6442
diff
changeset
|
474 mac_fstat(self, args) |
|
3de0cb82e61a
Add fstat() if using GUSI
Jack Jansen <jack.jansen@cwi.nl>
parents:
6442
diff
changeset
|
475 PyObject *self; |
|
3de0cb82e61a
Add fstat() if using GUSI
Jack Jansen <jack.jansen@cwi.nl>
parents:
6442
diff
changeset
|
476 PyObject *args; |
|
3de0cb82e61a
Add fstat() if using GUSI
Jack Jansen <jack.jansen@cwi.nl>
parents:
6442
diff
changeset
|
477 { |
|
3de0cb82e61a
Add fstat() if using GUSI
Jack Jansen <jack.jansen@cwi.nl>
parents:
6442
diff
changeset
|
478 struct stat st; |
|
3de0cb82e61a
Add fstat() if using GUSI
Jack Jansen <jack.jansen@cwi.nl>
parents:
6442
diff
changeset
|
479 long fd; |
|
3de0cb82e61a
Add fstat() if using GUSI
Jack Jansen <jack.jansen@cwi.nl>
parents:
6442
diff
changeset
|
480 int res; |
|
3de0cb82e61a
Add fstat() if using GUSI
Jack Jansen <jack.jansen@cwi.nl>
parents:
6442
diff
changeset
|
481 if (!PyArg_Parse(args, "l", &fd)) |
|
3de0cb82e61a
Add fstat() if using GUSI
Jack Jansen <jack.jansen@cwi.nl>
parents:
6442
diff
changeset
|
482 return NULL; |
|
3de0cb82e61a
Add fstat() if using GUSI
Jack Jansen <jack.jansen@cwi.nl>
parents:
6442
diff
changeset
|
483 Py_BEGIN_ALLOW_THREADS |
|
3de0cb82e61a
Add fstat() if using GUSI
Jack Jansen <jack.jansen@cwi.nl>
parents:
6442
diff
changeset
|
484 res = fstat((int)fd, &st); |
|
3de0cb82e61a
Add fstat() if using GUSI
Jack Jansen <jack.jansen@cwi.nl>
parents:
6442
diff
changeset
|
485 Py_END_ALLOW_THREADS |
|
3de0cb82e61a
Add fstat() if using GUSI
Jack Jansen <jack.jansen@cwi.nl>
parents:
6442
diff
changeset
|
486 if (res != 0) |
|
3de0cb82e61a
Add fstat() if using GUSI
Jack Jansen <jack.jansen@cwi.nl>
parents:
6442
diff
changeset
|
487 return mac_error(); |
|
3de0cb82e61a
Add fstat() if using GUSI
Jack Jansen <jack.jansen@cwi.nl>
parents:
6442
diff
changeset
|
488 return Py_BuildValue("(lllllllddd)", |
|
1620
8454579ab52f
As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents:
1522
diff
changeset
|
489 (long)st.st_mode, |
|
1821
40594f80ab3c
Intermediate version of changes after porting to MPW 3.2
Guido van Rossum <guido@python.org>
parents:
1808
diff
changeset
|
490 (long)st.st_ino, |
|
1795
fa8bbd09f2e6
Updates for THINK C 6.0. Moved the necessary UNIX emulation routines here.
Guido van Rossum <guido@python.org>
parents:
1692
diff
changeset
|
491 (long)st.st_dev, |
|
fa8bbd09f2e6
Updates for THINK C 6.0. Moved the necessary UNIX emulation routines here.
Guido van Rossum <guido@python.org>
parents:
1692
diff
changeset
|
492 (long)st.st_nlink, |
|
fa8bbd09f2e6
Updates for THINK C 6.0. Moved the necessary UNIX emulation routines here.
Guido van Rossum <guido@python.org>
parents:
1692
diff
changeset
|
493 (long)st.st_uid, |
|
fa8bbd09f2e6
Updates for THINK C 6.0. Moved the necessary UNIX emulation routines here.
Guido van Rossum <guido@python.org>
parents:
1692
diff
changeset
|
494 (long)st.st_gid, |
|
1620
8454579ab52f
As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents:
1522
diff
changeset
|
495 (long)st.st_size, |
|
7434
3de0cb82e61a
Add fstat() if using GUSI
Jack Jansen <jack.jansen@cwi.nl>
parents:
6442
diff
changeset
|
496 (double)st.st_atime, |
|
3de0cb82e61a
Add fstat() if using GUSI
Jack Jansen <jack.jansen@cwi.nl>
parents:
6442
diff
changeset
|
497 (double)st.st_mtime, |
|
3de0cb82e61a
Add fstat() if using GUSI
Jack Jansen <jack.jansen@cwi.nl>
parents:
6442
diff
changeset
|
498 (double)st.st_ctime); |
| 1495 | 499 } |
|
7434
3de0cb82e61a
Add fstat() if using GUSI
Jack Jansen <jack.jansen@cwi.nl>
parents:
6442
diff
changeset
|
500 #endif /* WEHAVE_FSTAT */ |
| 1495 | 501 |
|
15835
b1b0a703ec4e
xstat() will never be implemented under Carbon. Fortunately it also doesn't appear to be used anywhere.
Jack Jansen <jack.jansen@cwi.nl>
parents:
14205
diff
changeset
|
502 #if !TARGET_API_MAC_CARBON |
| 5071 | 503 static PyObject * |
|
2929
7d1ecec25c06
add xstat (extended stat, returns resource fork size and creator/type)
Guido van Rossum <guido@python.org>
parents:
2722
diff
changeset
|
504 mac_xstat(self, args) |
| 5071 | 505 PyObject *self; |
| 506 PyObject *args; | |
|
2929
7d1ecec25c06
add xstat (extended stat, returns resource fork size and creator/type)
Guido van Rossum <guido@python.org>
parents:
2722
diff
changeset
|
507 { |
|
4414
02a68d623805
Fixed xstat to again include resroucefork size, creator, type. Obtain
Jack Jansen <jack.jansen@cwi.nl>
parents:
3942
diff
changeset
|
508 struct macstat mst; |
|
02a68d623805
Fixed xstat to again include resroucefork size, creator, type. Obtain
Jack Jansen <jack.jansen@cwi.nl>
parents:
3942
diff
changeset
|
509 struct stat st; |
|
2929
7d1ecec25c06
add xstat (extended stat, returns resource fork size and creator/type)
Guido van Rossum <guido@python.org>
parents:
2722
diff
changeset
|
510 char *path; |
|
7d1ecec25c06
add xstat (extended stat, returns resource fork size and creator/type)
Guido van Rossum <guido@python.org>
parents:
2722
diff
changeset
|
511 int res; |
| 5071 | 512 if (!PyArg_Parse(args, "s", &path)) |
|
2929
7d1ecec25c06
add xstat (extended stat, returns resource fork size and creator/type)
Guido van Rossum <guido@python.org>
parents:
2722
diff
changeset
|
513 return NULL; |
|
4414
02a68d623805
Fixed xstat to again include resroucefork size, creator, type. Obtain
Jack Jansen <jack.jansen@cwi.nl>
parents:
3942
diff
changeset
|
514 /* |
|
02a68d623805
Fixed xstat to again include resroucefork size, creator, type. Obtain
Jack Jansen <jack.jansen@cwi.nl>
parents:
3942
diff
changeset
|
515 ** Convoluted: we want stat() and xstat() to agree, so we call both |
|
02a68d623805
Fixed xstat to again include resroucefork size, creator, type. Obtain
Jack Jansen <jack.jansen@cwi.nl>
parents:
3942
diff
changeset
|
516 ** stat and macstat, and use the latter only for values not provided by |
|
02a68d623805
Fixed xstat to again include resroucefork size, creator, type. Obtain
Jack Jansen <jack.jansen@cwi.nl>
parents:
3942
diff
changeset
|
517 ** the former. |
|
02a68d623805
Fixed xstat to again include resroucefork size, creator, type. Obtain
Jack Jansen <jack.jansen@cwi.nl>
parents:
3942
diff
changeset
|
518 */ |
| 5071 | 519 Py_BEGIN_ALLOW_THREADS |
|
4414
02a68d623805
Fixed xstat to again include resroucefork size, creator, type. Obtain
Jack Jansen <jack.jansen@cwi.nl>
parents:
3942
diff
changeset
|
520 res = macstat(path, &mst); |
| 5071 | 521 Py_END_ALLOW_THREADS |
|
2929
7d1ecec25c06
add xstat (extended stat, returns resource fork size and creator/type)
Guido van Rossum <guido@python.org>
parents:
2722
diff
changeset
|
522 if (res != 0) |
|
7d1ecec25c06
add xstat (extended stat, returns resource fork size and creator/type)
Guido van Rossum <guido@python.org>
parents:
2722
diff
changeset
|
523 return mac_error(); |
| 5071 | 524 Py_BEGIN_ALLOW_THREADS |
|
4414
02a68d623805
Fixed xstat to again include resroucefork size, creator, type. Obtain
Jack Jansen <jack.jansen@cwi.nl>
parents:
3942
diff
changeset
|
525 res = stat(path, &st); |
| 5071 | 526 Py_END_ALLOW_THREADS |
|
4414
02a68d623805
Fixed xstat to again include resroucefork size, creator, type. Obtain
Jack Jansen <jack.jansen@cwi.nl>
parents:
3942
diff
changeset
|
527 if (res != 0) |
|
02a68d623805
Fixed xstat to again include resroucefork size, creator, type. Obtain
Jack Jansen <jack.jansen@cwi.nl>
parents:
3942
diff
changeset
|
528 return mac_error(); |
| 5071 | 529 return Py_BuildValue("(llllllldddls#s#)", |
| 3394 | 530 (long)st.st_mode, |
| 531 (long)st.st_ino, | |
| 532 (long)st.st_dev, | |
| 533 (long)st.st_nlink, | |
| 534 (long)st.st_uid, | |
| 535 (long)st.st_gid, | |
| 536 (long)st.st_size, | |
|
4414
02a68d623805
Fixed xstat to again include resroucefork size, creator, type. Obtain
Jack Jansen <jack.jansen@cwi.nl>
parents:
3942
diff
changeset
|
537 (double)st.st_atime, |
|
02a68d623805
Fixed xstat to again include resroucefork size, creator, type. Obtain
Jack Jansen <jack.jansen@cwi.nl>
parents:
3942
diff
changeset
|
538 (double)st.st_mtime, |
|
02a68d623805
Fixed xstat to again include resroucefork size, creator, type. Obtain
Jack Jansen <jack.jansen@cwi.nl>
parents:
3942
diff
changeset
|
539 (double)st.st_ctime, |
|
02a68d623805
Fixed xstat to again include resroucefork size, creator, type. Obtain
Jack Jansen <jack.jansen@cwi.nl>
parents:
3942
diff
changeset
|
540 (long)mst.st_rsize, |
|
02a68d623805
Fixed xstat to again include resroucefork size, creator, type. Obtain
Jack Jansen <jack.jansen@cwi.nl>
parents:
3942
diff
changeset
|
541 mst.st_creator, 4, |
|
02a68d623805
Fixed xstat to again include resroucefork size, creator, type. Obtain
Jack Jansen <jack.jansen@cwi.nl>
parents:
3942
diff
changeset
|
542 mst.st_type, 4); |
|
2929
7d1ecec25c06
add xstat (extended stat, returns resource fork size and creator/type)
Guido van Rossum <guido@python.org>
parents:
2722
diff
changeset
|
543 } |
|
12836
3fe304050434
Made the core toolbox modules carbon-compatible using the new greylist feature of bgen: non-carbon methods are still included in non-carbon MacPython. The issue of backward compatibility of Python code is still open.
Jack Jansen <jack.jansen@cwi.nl>
parents:
12686
diff
changeset
|
544 #endif |
|
2929
7d1ecec25c06
add xstat (extended stat, returns resource fork size and creator/type)
Guido van Rossum <guido@python.org>
parents:
2722
diff
changeset
|
545 |
| 5071 | 546 static PyObject * |
| 1495 | 547 mac_sync(self, args) |
| 5071 | 548 PyObject *self; |
| 549 PyObject *args; | |
| 1495 | 550 { |
|
1620
8454579ab52f
As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents:
1522
diff
changeset
|
551 int res; |
| 5071 | 552 if (!PyArg_NoArgs(args)) |
| 1495 | 553 return NULL; |
| 5071 | 554 Py_BEGIN_ALLOW_THREADS |
|
1620
8454579ab52f
As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents:
1522
diff
changeset
|
555 res = sync(); |
| 5071 | 556 Py_END_ALLOW_THREADS |
|
1620
8454579ab52f
As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents:
1522
diff
changeset
|
557 if (res != 0) |
|
8454579ab52f
As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents:
1522
diff
changeset
|
558 return mac_error(); |
| 5071 | 559 Py_INCREF(Py_None); |
| 560 return Py_None; | |
| 1495 | 561 } |
| 562 | |
| 5071 | 563 static PyObject * |
| 1495 | 564 mac_unlink(self, args) |
| 5071 | 565 PyObject *self; |
| 566 PyObject *args; | |
| 1495 | 567 { |
|
1822
76d0f2b3b9ee
Completed (hopefully) the unification of THINK 6.0 and MPW 3.2
Guido van Rossum <guido@python.org>
parents:
1821
diff
changeset
|
568 return mac_1str(args, (int (*)(const char *))unlink); |
| 1495 | 569 } |
| 570 | |
| 5071 | 571 static PyObject * |
|
1620
8454579ab52f
As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents:
1522
diff
changeset
|
572 mac_write(self, args) |
| 5071 | 573 PyObject *self; |
| 574 PyObject *args; | |
|
1620
8454579ab52f
As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents:
1522
diff
changeset
|
575 { |
|
8454579ab52f
As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents:
1522
diff
changeset
|
576 int fd, size; |
|
8454579ab52f
As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents:
1522
diff
changeset
|
577 char *buffer; |
|
5429
ac235c9e6881
- Changed the m# format for PyArg_ParseTuple back to s#
Jack Jansen <jack.jansen@cwi.nl>
parents:
5152
diff
changeset
|
578 if (!PyArg_Parse(args, "(is#)", &fd, &buffer, &size)) |
|
1620
8454579ab52f
As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents:
1522
diff
changeset
|
579 return NULL; |
| 5071 | 580 Py_BEGIN_ALLOW_THREADS |
|
1620
8454579ab52f
As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents:
1522
diff
changeset
|
581 size = write(fd, buffer, size); |
| 5071 | 582 Py_END_ALLOW_THREADS |
|
1620
8454579ab52f
As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents:
1522
diff
changeset
|
583 if (size < 0) |
|
8454579ab52f
As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents:
1522
diff
changeset
|
584 return mac_error(); |
| 5071 | 585 return PyInt_FromLong((long)size); |
|
1620
8454579ab52f
As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents:
1522
diff
changeset
|
586 } |
| 1495 | 587 |
|
4468
600f5b8a16cb
Malloc debugging now flagged with USE_MALLOC_DEBUG
Jack Jansen <jack.jansen@cwi.nl>
parents:
4414
diff
changeset
|
588 #ifdef USE_MALLOC_DEBUG |
|
14205
3ae185b8ff03
Added a prototype for mstats().
Jack Jansen <jack.jansen@cwi.nl>
parents:
13608
diff
changeset
|
589 void *mstats(char *); |
|
3ae185b8ff03
Added a prototype for mstats().
Jack Jansen <jack.jansen@cwi.nl>
parents:
13608
diff
changeset
|
590 |
| 5071 | 591 static PyObject * |
|
2179
8da03decef59
More Pstring() stuff and some cosmetics
Jack Jansen <jack.jansen@cwi.nl>
parents:
2091
diff
changeset
|
592 mac_mstats(self, args) |
| 5071 | 593 PyObject*self; |
| 594 PyObject *args; | |
|
2179
8da03decef59
More Pstring() stuff and some cosmetics
Jack Jansen <jack.jansen@cwi.nl>
parents:
2091
diff
changeset
|
595 { |
|
8da03decef59
More Pstring() stuff and some cosmetics
Jack Jansen <jack.jansen@cwi.nl>
parents:
2091
diff
changeset
|
596 mstats("python"); |
| 5071 | 597 Py_INCREF(Py_None); |
| 598 return Py_None; | |
|
2179
8da03decef59
More Pstring() stuff and some cosmetics
Jack Jansen <jack.jansen@cwi.nl>
parents:
2091
diff
changeset
|
599 } |
|
5141
a4c8b8871376
Comments around identifier after #endif
Jack Jansen <jack.jansen@cwi.nl>
parents:
5079
diff
changeset
|
600 #endif /* USE_MALLOC_DEBUG */ |
|
2179
8da03decef59
More Pstring() stuff and some cosmetics
Jack Jansen <jack.jansen@cwi.nl>
parents:
2091
diff
changeset
|
601 |
| 5071 | 602 static struct PyMethodDef mac_methods[] = { |
| 1495 | 603 {"chdir", mac_chdir}, |
|
1620
8454579ab52f
As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents:
1522
diff
changeset
|
604 {"close", mac_close}, |
| 3400 | 605 #ifdef WEHAVE_DUP |
|
1620
8454579ab52f
As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents:
1522
diff
changeset
|
606 {"dup", mac_dup}, |
|
1821
40594f80ab3c
Intermediate version of changes after porting to MPW 3.2
Guido van Rossum <guido@python.org>
parents:
1808
diff
changeset
|
607 #endif |
| 3400 | 608 #ifdef WEHAVE_FDOPEN |
|
1620
8454579ab52f
As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents:
1522
diff
changeset
|
609 {"fdopen", mac_fdopen}, |
|
2032
609bfb8ae7f5
Ported to MetroWerks, which misses file-descriptor like functionality.
Jack Jansen <jack.jansen@cwi.nl>
parents:
1822
diff
changeset
|
610 #endif |
|
7434
3de0cb82e61a
Add fstat() if using GUSI
Jack Jansen <jack.jansen@cwi.nl>
parents:
6442
diff
changeset
|
611 #ifdef WEHAVE_FSTAT |
|
3de0cb82e61a
Add fstat() if using GUSI
Jack Jansen <jack.jansen@cwi.nl>
parents:
6442
diff
changeset
|
612 {"fstat", mac_fstat}, |
|
3de0cb82e61a
Add fstat() if using GUSI
Jack Jansen <jack.jansen@cwi.nl>
parents:
6442
diff
changeset
|
613 #endif |
|
13608
a901c2c0166b
Test for TARGET_API_MAC_CARBON with #if in stead of #ifdef.
Jack Jansen <jack.jansen@cwi.nl>
parents:
13553
diff
changeset
|
614 #if !TARGET_API_MAC_CARBON |
|
1620
8454579ab52f
As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents:
1522
diff
changeset
|
615 {"getbootvol", mac_getbootvol}, /* non-standard */ |
|
12836
3fe304050434
Made the core toolbox modules carbon-compatible using the new greylist feature of bgen: non-carbon methods are still included in non-carbon MacPython. The issue of backward compatibility of Python code is still open.
Jack Jansen <jack.jansen@cwi.nl>
parents:
12686
diff
changeset
|
616 #endif |
| 1495 | 617 {"getcwd", mac_getcwd}, |
|
2391
ecbbaa584f3c
explicitly init flags in methodlist
Guido van Rossum <guido@python.org>
parents:
2359
diff
changeset
|
618 {"listdir", mac_listdir, 0}, |
|
1620
8454579ab52f
As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents:
1522
diff
changeset
|
619 {"lseek", mac_lseek}, |
|
3405
c283447b985f
Mods by Guido: mkdir 2nd arg optional and remove as alias for unlink.
Jack Jansen <jack.jansen@cwi.nl>
parents:
3400
diff
changeset
|
620 {"mkdir", mac_mkdir, 1}, |
|
1620
8454579ab52f
As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents:
1522
diff
changeset
|
621 {"open", mac_open}, |
|
8454579ab52f
As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents:
1522
diff
changeset
|
622 {"read", mac_read}, |
| 1495 | 623 {"rename", mac_rename}, |
| 624 {"rmdir", mac_rmdir}, | |
| 625 {"stat", mac_stat}, | |
|
15835
b1b0a703ec4e
xstat() will never be implemented under Carbon. Fortunately it also doesn't appear to be used anywhere.
Jack Jansen <jack.jansen@cwi.nl>
parents:
14205
diff
changeset
|
626 #if !TARGET_API_MAC_CARBON |
|
2929
7d1ecec25c06
add xstat (extended stat, returns resource fork size and creator/type)
Guido van Rossum <guido@python.org>
parents:
2722
diff
changeset
|
627 {"xstat", mac_xstat}, |
|
12836
3fe304050434
Made the core toolbox modules carbon-compatible using the new greylist feature of bgen: non-carbon methods are still included in non-carbon MacPython. The issue of backward compatibility of Python code is still open.
Jack Jansen <jack.jansen@cwi.nl>
parents:
12686
diff
changeset
|
628 #endif |
| 1495 | 629 {"sync", mac_sync}, |
|
3405
c283447b985f
Mods by Guido: mkdir 2nd arg optional and remove as alias for unlink.
Jack Jansen <jack.jansen@cwi.nl>
parents:
3400
diff
changeset
|
630 {"remove", mac_unlink}, |
| 1495 | 631 {"unlink", mac_unlink}, |
|
1620
8454579ab52f
As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents:
1522
diff
changeset
|
632 {"write", mac_write}, |
|
4468
600f5b8a16cb
Malloc debugging now flagged with USE_MALLOC_DEBUG
Jack Jansen <jack.jansen@cwi.nl>
parents:
4414
diff
changeset
|
633 #ifdef USE_MALLOC_DEBUG |
|
2179
8da03decef59
More Pstring() stuff and some cosmetics
Jack Jansen <jack.jansen@cwi.nl>
parents:
2091
diff
changeset
|
634 {"mstats", mac_mstats}, |
|
8da03decef59
More Pstring() stuff and some cosmetics
Jack Jansen <jack.jansen@cwi.nl>
parents:
2091
diff
changeset
|
635 #endif |
|
1620
8454579ab52f
As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents:
1522
diff
changeset
|
636 |
| 1495 | 637 {NULL, NULL} /* Sentinel */ |
| 638 }; | |
| 639 | |
| 640 | |
| 641 void | |
| 642 initmac() | |
| 643 { | |
| 5071 | 644 PyObject *m, *d; |
| 1495 | 645 |
| 5071 | 646 m = Py_InitModule("mac", mac_methods); |
| 647 d = PyModule_GetDict(m); | |
| 1495 | 648 |
| 649 /* Initialize mac.error exception */ | |
| 6442 | 650 MacError = PyErr_NewException("mac.error", NULL, NULL); |
| 651 PyDict_SetItemString(d, "error", MacError); | |
| 1495 | 652 } |
