Mercurial > cpython-lru_cache-weakref
annotate Mac/Modules/macmodule.c @ 25838:8540887bcec6 2.2
Backport of 2.183:
Fix memory leak in add_subclass() found by NealN with valgrind.
| author | Guido van Rossum <guido@python.org> |
|---|---|
| date | Fri, 18 Oct 2002 13:42:21 +0000 |
| parents | 457bf184e7ba |
| children | 4f9d5ea4f37d |
| 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" |
|
20539
2d599a36b67a
SF patch #462296: Add attributes to os.stat results; by Nick Mathewson.
Guido van Rossum <guido@python.org>
parents:
19181
diff
changeset
|
28 #include "structseq.h" |
|
1620
8454579ab52f
As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents:
1522
diff
changeset
|
29 #include "ceval.h" |
| 1495 | 30 |
|
1620
8454579ab52f
As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents:
1522
diff
changeset
|
31 #include <stdio.h> |
|
8454579ab52f
As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents:
1522
diff
changeset
|
32 #include <string.h> |
|
8454579ab52f
As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents:
1522
diff
changeset
|
33 #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
|
34 |
|
17813
8cd8741ebec0
Be more sensible about when to use TARGET_API_MAC_OS8 in stead of !TARGET_API_MAC_CARBON. This should greatly facilitate porting stuff to OSX in its MachO/BSD incarnation.
Jack Jansen <jack.jansen@cwi.nl>
parents:
15835
diff
changeset
|
35 #if TARGET_API_MAC_OS8 |
|
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
|
36 /* 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
|
37 #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
|
38 #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
|
39 |
| 3394 | 40 #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
|
41 /* 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
|
42 #undef S_IFMT |
|
02a68d623805
Fixed xstat to again include resroucefork size, creator, type. Obtain
Jack Jansen <jack.jansen@cwi.nl>
parents:
3942
diff
changeset
|
43 #undef S_IFDIR |
|
02a68d623805
Fixed xstat to again include resroucefork size, creator, type. Obtain
Jack Jansen <jack.jansen@cwi.nl>
parents:
3942
diff
changeset
|
44 #undef S_IFREG |
|
02a68d623805
Fixed xstat to again include resroucefork size, creator, type. Obtain
Jack Jansen <jack.jansen@cwi.nl>
parents:
3942
diff
changeset
|
45 #undef S_IREAD |
|
02a68d623805
Fixed xstat to again include resroucefork size, creator, type. Obtain
Jack Jansen <jack.jansen@cwi.nl>
parents:
3942
diff
changeset
|
46 #undef S_IWRITE |
|
02a68d623805
Fixed xstat to again include resroucefork size, creator, type. Obtain
Jack Jansen <jack.jansen@cwi.nl>
parents:
3942
diff
changeset
|
47 #undef S_IEXEC |
|
02a68d623805
Fixed xstat to again include resroucefork size, creator, type. Obtain
Jack Jansen <jack.jansen@cwi.nl>
parents:
3942
diff
changeset
|
48 |
|
12284
9c96e5d437a8
Started on GUSI2 and threading support.
Jack Jansen <jack.jansen@cwi.nl>
parents:
7434
diff
changeset
|
49 #ifdef USE_GUSI1 |
| 3400 | 50 #include <GUSI.h> |
|
12284
9c96e5d437a8
Started on GUSI2 and threading support.
Jack Jansen <jack.jansen@cwi.nl>
parents:
7434
diff
changeset
|
51 #endif /* USE_GUSI1 */ |
| 3394 | 52 #include <sys/types.h> |
|
12284
9c96e5d437a8
Started on GUSI2 and threading support.
Jack Jansen <jack.jansen@cwi.nl>
parents:
7434
diff
changeset
|
53 #include <sys/stat.h> |
|
9c96e5d437a8
Started on GUSI2 and threading support.
Jack Jansen <jack.jansen@cwi.nl>
parents:
7434
diff
changeset
|
54 #else /* USE_GUSI */ |
|
17813
8cd8741ebec0
Be more sensible about when to use TARGET_API_MAC_OS8 in stead of !TARGET_API_MAC_CARBON. This should greatly facilitate porting stuff to OSX in its MachO/BSD incarnation.
Jack Jansen <jack.jansen@cwi.nl>
parents:
15835
diff
changeset
|
55 #if TARGET_API_MAC_OS8 |
|
12284
9c96e5d437a8
Started on GUSI2 and threading support.
Jack Jansen <jack.jansen@cwi.nl>
parents:
7434
diff
changeset
|
56 #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
|
57 #endif |
|
12284
9c96e5d437a8
Started on GUSI2 and threading support.
Jack Jansen <jack.jansen@cwi.nl>
parents:
7434
diff
changeset
|
58 #endif /* USE_GUSI */ |
|
9c96e5d437a8
Started on GUSI2 and threading support.
Jack Jansen <jack.jansen@cwi.nl>
parents:
7434
diff
changeset
|
59 |
|
9c96e5d437a8
Started on GUSI2 and threading support.
Jack Jansen <jack.jansen@cwi.nl>
parents:
7434
diff
changeset
|
60 #ifdef USE_GUSI2 |
|
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> |
| 3394 | 63 #else |
|
12686
bc96c912dce8
Fixed to work again without USE_GUSI
Jack Jansen <jack.jansen@cwi.nl>
parents:
12284
diff
changeset
|
64 #define mode_t int |
|
1620
8454579ab52f
As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents:
1522
diff
changeset
|
65 #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
|
66 #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
|
67 #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
|
68 #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
|
69 #endif |
|
2032
609bfb8ae7f5
Ported to MetroWerks, which misses file-descriptor like functionality.
Jack Jansen <jack.jansen@cwi.nl>
parents:
1822
diff
changeset
|
70 #endif |
|
1620
8454579ab52f
As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents:
1522
diff
changeset
|
71 |
| 3400 | 72 /* Optional routines, for some compiler/runtime combinations */ |
| 73 #if defined(USE_GUSI) || !defined(__MWERKS__) | |
| 74 #define WEHAVE_FDOPEN | |
| 75 #endif | |
| 76 #if defined(MPW) || defined(USE_GUSI) | |
| 77 #define WEHAVE_DUP | |
| 78 #endif | |
|
7434
3de0cb82e61a
Add fstat() if using GUSI
Jack Jansen <jack.jansen@cwi.nl>
parents:
6442
diff
changeset
|
79 #if defined(USE_GUSI) |
|
3de0cb82e61a
Add fstat() if using GUSI
Jack Jansen <jack.jansen@cwi.nl>
parents:
6442
diff
changeset
|
80 #define WEHAVE_FSTAT |
|
3de0cb82e61a
Add fstat() if using GUSI
Jack Jansen <jack.jansen@cwi.nl>
parents:
6442
diff
changeset
|
81 #endif |
|
2222
bbb56dc3b526
Make malloc stats routine available under MetroWerks
Jack Jansen <jack.jansen@cwi.nl>
parents:
2179
diff
changeset
|
82 |
|
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
|
83 #include "macdefs.h" |
| 3394 | 84 #ifdef USE_GUSI |
| 85 #include <dirent.h> | |
| 86 #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
|
87 #include "dirent.h" |
| 3394 | 88 #endif |
|
1620
8454579ab52f
As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents:
1522
diff
changeset
|
89 |
|
8454579ab52f
As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents:
1522
diff
changeset
|
90 #ifndef MAXPATHLEN |
|
8454579ab52f
As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents:
1522
diff
changeset
|
91 #define MAXPATHLEN 1024 |
|
8454579ab52f
As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents:
1522
diff
changeset
|
92 #endif |
|
8454579ab52f
As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents:
1522
diff
changeset
|
93 |
|
8454579ab52f
As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents:
1522
diff
changeset
|
94 /* 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
|
95 |
| 3400 | 96 #ifndef USE_GUSI |
| 97 | |
|
13542
ddd6138c9e6f
ANSIfication step 1: get rid of Py_PROTO and Py_FPROTO.
Jack Jansen <jack.jansen@cwi.nl>
parents:
12856
diff
changeset
|
98 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
|
99 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
|
100 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
|
101 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
|
102 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
|
103 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
|
104 int sync(void); |
| 3400 | 105 |
|
13542
ddd6138c9e6f
ANSIfication step 1: get rid of Py_PROTO and Py_FPROTO.
Jack Jansen <jack.jansen@cwi.nl>
parents:
12856
diff
changeset
|
106 int unlink(const char *); |
|
1620
8454579ab52f
As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents:
1522
diff
changeset
|
107 |
| 3400 | 108 #endif /* USE_GUSI */ |
| 109 | |
|
13542
ddd6138c9e6f
ANSIfication step 1: get rid of Py_PROTO and Py_FPROTO.
Jack Jansen <jack.jansen@cwi.nl>
parents:
12856
diff
changeset
|
110 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
|
111 char *getbootvol(void); |
|
1620
8454579ab52f
As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents:
1522
diff
changeset
|
112 |
|
8454579ab52f
As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents:
1522
diff
changeset
|
113 |
|
8454579ab52f
As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents:
1522
diff
changeset
|
114 /* 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
|
115 |
| 5071 | 116 static PyObject * |
|
1620
8454579ab52f
As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents:
1522
diff
changeset
|
117 mac_error() |
|
8454579ab52f
As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents:
1522
diff
changeset
|
118 { |
|
21113
ed3dce17fc79
Merged changes made on r22b2-branch between r22b2 and r22b2-mac (the
Jack Jansen <jack.jansen@cwi.nl>
parents:
20896
diff
changeset
|
119 return PyErr_SetFromErrno(PyExc_OSError); |
|
1620
8454579ab52f
As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents:
1522
diff
changeset
|
120 } |
|
8454579ab52f
As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents:
1522
diff
changeset
|
121 |
|
8454579ab52f
As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents:
1522
diff
changeset
|
122 /* MAC generic methods */ |
| 1495 | 123 |
| 5071 | 124 static PyObject * |
|
1620
8454579ab52f
As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents:
1522
diff
changeset
|
125 mac_1str(args, func) |
| 5071 | 126 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
|
127 int (*func)(const char *); |
|
1620
8454579ab52f
As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents:
1522
diff
changeset
|
128 { |
|
8454579ab52f
As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents:
1522
diff
changeset
|
129 char *path1; |
|
8454579ab52f
As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents:
1522
diff
changeset
|
130 int res; |
|
18960
9aa5d66cd13d
(Finally) converted to new-style args.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17813
diff
changeset
|
131 if (!PyArg_ParseTuple(args, "s", &path1)) |
|
1620
8454579ab52f
As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents:
1522
diff
changeset
|
132 return NULL; |
| 5071 | 133 Py_BEGIN_ALLOW_THREADS |
|
1620
8454579ab52f
As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents:
1522
diff
changeset
|
134 res = (*func)(path1); |
| 5071 | 135 Py_END_ALLOW_THREADS |
|
1620
8454579ab52f
As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents:
1522
diff
changeset
|
136 if (res < 0) |
|
8454579ab52f
As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents:
1522
diff
changeset
|
137 return mac_error(); |
| 5071 | 138 Py_INCREF(Py_None); |
| 139 return Py_None; | |
|
1620
8454579ab52f
As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents:
1522
diff
changeset
|
140 } |
| 1495 | 141 |
| 5071 | 142 static PyObject * |
|
1620
8454579ab52f
As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents:
1522
diff
changeset
|
143 mac_2str(args, func) |
| 5071 | 144 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
|
145 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
|
146 { |
|
8454579ab52f
As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents:
1522
diff
changeset
|
147 char *path1, *path2; |
|
8454579ab52f
As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents:
1522
diff
changeset
|
148 int res; |
|
18960
9aa5d66cd13d
(Finally) converted to new-style args.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17813
diff
changeset
|
149 if (!PyArg_ParseTuple(args, "ss", &path1, &path2)) |
|
1620
8454579ab52f
As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents:
1522
diff
changeset
|
150 return NULL; |
| 5071 | 151 Py_BEGIN_ALLOW_THREADS |
|
1620
8454579ab52f
As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents:
1522
diff
changeset
|
152 res = (*func)(path1, path2); |
| 5071 | 153 Py_END_ALLOW_THREADS |
|
1620
8454579ab52f
As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents:
1522
diff
changeset
|
154 if (res < 0) |
|
8454579ab52f
As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents:
1522
diff
changeset
|
155 return mac_error(); |
| 5071 | 156 Py_INCREF(Py_None); |
| 157 return Py_None; | |
|
1620
8454579ab52f
As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents:
1522
diff
changeset
|
158 } |
| 1495 | 159 |
| 5071 | 160 static PyObject * |
|
1620
8454579ab52f
As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents:
1522
diff
changeset
|
161 mac_strint(args, func) |
| 5071 | 162 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
|
163 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
|
164 { |
|
8454579ab52f
As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents:
1522
diff
changeset
|
165 char *path; |
|
8454579ab52f
As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents:
1522
diff
changeset
|
166 int i; |
|
8454579ab52f
As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents:
1522
diff
changeset
|
167 int res; |
|
18960
9aa5d66cd13d
(Finally) converted to new-style args.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17813
diff
changeset
|
168 if (!PyArg_ParseTuple(args, "si", &path, &i)) |
|
1620
8454579ab52f
As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents:
1522
diff
changeset
|
169 return NULL; |
| 5071 | 170 Py_BEGIN_ALLOW_THREADS |
|
1620
8454579ab52f
As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents:
1522
diff
changeset
|
171 res = (*func)(path, i); |
| 5071 | 172 Py_END_ALLOW_THREADS |
|
1620
8454579ab52f
As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents:
1522
diff
changeset
|
173 if (res < 0) |
|
8454579ab52f
As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents:
1522
diff
changeset
|
174 return mac_error(); |
| 5071 | 175 Py_INCREF(Py_None); |
| 176 return Py_None; | |
|
1620
8454579ab52f
As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents:
1522
diff
changeset
|
177 } |
|
8454579ab52f
As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents:
1522
diff
changeset
|
178 |
| 5071 | 179 static PyObject * |
| 1495 | 180 mac_chdir(self, args) |
| 5071 | 181 PyObject *self; |
| 182 PyObject *args; | |
| 1495 | 183 { |
|
12284
9c96e5d437a8
Started on GUSI2 and threading support.
Jack Jansen <jack.jansen@cwi.nl>
parents:
7434
diff
changeset
|
184 #ifdef USE_GUSI1 |
| 5071 | 185 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
|
186 |
|
578ca302a598
Replaced previous gusi-chdir() fix by a call to PyMac_FixGUSIcd()
Jack Jansen <jack.jansen@cwi.nl>
parents:
3405
diff
changeset
|
187 /* 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
|
188 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
|
189 PyMac_FixGUSIcd(); |
|
578ca302a598
Replaced previous gusi-chdir() fix by a call to PyMac_FixGUSIcd()
Jack Jansen <jack.jansen@cwi.nl>
parents:
3405
diff
changeset
|
190 return rv; |
|
578ca302a598
Replaced previous gusi-chdir() fix by a call to PyMac_FixGUSIcd()
Jack Jansen <jack.jansen@cwi.nl>
parents:
3405
diff
changeset
|
191 #else |
|
1620
8454579ab52f
As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents:
1522
diff
changeset
|
192 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
|
193 #endif |
|
578ca302a598
Replaced previous gusi-chdir() fix by a call to PyMac_FixGUSIcd()
Jack Jansen <jack.jansen@cwi.nl>
parents:
3405
diff
changeset
|
194 |
|
1620
8454579ab52f
As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents:
1522
diff
changeset
|
195 } |
|
8454579ab52f
As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents:
1522
diff
changeset
|
196 |
| 5071 | 197 static PyObject * |
|
1620
8454579ab52f
As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents:
1522
diff
changeset
|
198 mac_close(self, args) |
| 5071 | 199 PyObject *self; |
| 200 PyObject *args; | |
|
1620
8454579ab52f
As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents:
1522
diff
changeset
|
201 { |
|
8454579ab52f
As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents:
1522
diff
changeset
|
202 int fd, res; |
|
18960
9aa5d66cd13d
(Finally) converted to new-style args.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17813
diff
changeset
|
203 if (!PyArg_ParseTuple(args, "i", &fd)) |
| 1495 | 204 return NULL; |
| 5071 | 205 Py_BEGIN_ALLOW_THREADS |
|
1620
8454579ab52f
As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents:
1522
diff
changeset
|
206 res = close(fd); |
| 5071 | 207 Py_END_ALLOW_THREADS |
|
12284
9c96e5d437a8
Started on GUSI2 and threading support.
Jack Jansen <jack.jansen@cwi.nl>
parents:
7434
diff
changeset
|
208 #ifndef USE_GUSI1 |
| 3400 | 209 /* 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
|
210 if (res < 0) |
|
8454579ab52f
As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents:
1522
diff
changeset
|
211 return mac_error(); |
| 3400 | 212 #endif |
| 5071 | 213 Py_INCREF(Py_None); |
| 214 return Py_None; | |
| 1495 | 215 } |
| 216 | |
| 3400 | 217 #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
|
218 |
| 5071 | 219 static PyObject * |
|
1620
8454579ab52f
As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents:
1522
diff
changeset
|
220 mac_dup(self, args) |
| 5071 | 221 PyObject *self; |
| 222 PyObject *args; | |
|
1620
8454579ab52f
As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents:
1522
diff
changeset
|
223 { |
|
8454579ab52f
As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents:
1522
diff
changeset
|
224 int fd; |
|
18960
9aa5d66cd13d
(Finally) converted to new-style args.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17813
diff
changeset
|
225 if (!PyArg_ParseTuple(args, "i", &fd)) |
|
1620
8454579ab52f
As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents:
1522
diff
changeset
|
226 return NULL; |
| 5071 | 227 Py_BEGIN_ALLOW_THREADS |
|
1620
8454579ab52f
As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents:
1522
diff
changeset
|
228 fd = dup(fd); |
| 5071 | 229 Py_END_ALLOW_THREADS |
|
1620
8454579ab52f
As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents:
1522
diff
changeset
|
230 if (fd < 0) |
|
8454579ab52f
As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents:
1522
diff
changeset
|
231 return mac_error(); |
| 5071 | 232 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
|
233 } |
|
8454579ab52f
As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents:
1522
diff
changeset
|
234 |
| 3400 | 235 #endif |
|
1821
40594f80ab3c
Intermediate version of changes after porting to MPW 3.2
Guido van Rossum <guido@python.org>
parents:
1808
diff
changeset
|
236 |
| 3400 | 237 #ifdef WEHAVE_FDOPEN |
| 5071 | 238 static PyObject * |
|
1620
8454579ab52f
As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents:
1522
diff
changeset
|
239 mac_fdopen(self, args) |
| 5071 | 240 PyObject *self; |
| 241 PyObject *args; | |
|
1620
8454579ab52f
As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents:
1522
diff
changeset
|
242 { |
|
13542
ddd6138c9e6f
ANSIfication step 1: get rid of Py_PROTO and Py_FPROTO.
Jack Jansen <jack.jansen@cwi.nl>
parents:
12856
diff
changeset
|
243 extern int fclose(FILE *); |
|
1620
8454579ab52f
As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents:
1522
diff
changeset
|
244 int fd; |
|
8454579ab52f
As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents:
1522
diff
changeset
|
245 char *mode; |
|
8454579ab52f
As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents:
1522
diff
changeset
|
246 FILE *fp; |
|
18960
9aa5d66cd13d
(Finally) converted to new-style args.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17813
diff
changeset
|
247 if (!PyArg_ParseTuple(args, "is", &fd, &mode)) |
|
1620
8454579ab52f
As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents:
1522
diff
changeset
|
248 return NULL; |
| 5071 | 249 Py_BEGIN_ALLOW_THREADS |
|
1620
8454579ab52f
As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents:
1522
diff
changeset
|
250 fp = fdopen(fd, mode); |
| 5071 | 251 Py_END_ALLOW_THREADS |
|
1620
8454579ab52f
As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents:
1522
diff
changeset
|
252 if (fp == NULL) |
|
8454579ab52f
As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents:
1522
diff
changeset
|
253 return mac_error(); |
| 5071 | 254 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
|
255 } |
|
2032
609bfb8ae7f5
Ported to MetroWerks, which misses file-descriptor like functionality.
Jack Jansen <jack.jansen@cwi.nl>
parents:
1822
diff
changeset
|
256 #endif |
|
1620
8454579ab52f
As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents:
1522
diff
changeset
|
257 |
|
17813
8cd8741ebec0
Be more sensible about when to use TARGET_API_MAC_OS8 in stead of !TARGET_API_MAC_CARBON. This should greatly facilitate porting stuff to OSX in its MachO/BSD incarnation.
Jack Jansen <jack.jansen@cwi.nl>
parents:
15835
diff
changeset
|
258 #if TARGET_API_MAC_OS8 |
| 5071 | 259 static PyObject * |
|
1620
8454579ab52f
As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents:
1522
diff
changeset
|
260 mac_getbootvol(self, args) |
| 5071 | 261 PyObject *self; |
| 262 PyObject *args; | |
|
1620
8454579ab52f
As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents:
1522
diff
changeset
|
263 { |
|
8454579ab52f
As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents:
1522
diff
changeset
|
264 char *res; |
|
18960
9aa5d66cd13d
(Finally) converted to new-style args.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17813
diff
changeset
|
265 if (!PyArg_ParseTuple(args, "")) |
|
1620
8454579ab52f
As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents:
1522
diff
changeset
|
266 return NULL; |
| 5071 | 267 Py_BEGIN_ALLOW_THREADS |
|
1620
8454579ab52f
As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents:
1522
diff
changeset
|
268 res = getbootvol(); |
| 5071 | 269 Py_END_ALLOW_THREADS |
|
1620
8454579ab52f
As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents:
1522
diff
changeset
|
270 if (res == NULL) |
|
8454579ab52f
As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents:
1522
diff
changeset
|
271 return mac_error(); |
| 5071 | 272 return PyString_FromString(res); |
|
1620
8454579ab52f
As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents:
1522
diff
changeset
|
273 } |
|
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
|
274 #endif |
| 1495 | 275 |
| 5071 | 276 static PyObject * |
| 1495 | 277 mac_getcwd(self, args) |
| 5071 | 278 PyObject *self; |
| 279 PyObject *args; | |
| 1495 | 280 { |
|
1620
8454579ab52f
As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents:
1522
diff
changeset
|
281 char path[MAXPATHLEN]; |
|
8454579ab52f
As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents:
1522
diff
changeset
|
282 char *res; |
|
18960
9aa5d66cd13d
(Finally) converted to new-style args.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17813
diff
changeset
|
283 if (!PyArg_ParseTuple(args, "")) |
| 1495 | 284 return NULL; |
| 5071 | 285 Py_BEGIN_ALLOW_THREADS |
| 3400 | 286 #ifdef USE_GUSI |
| 287 res = getcwd(path, sizeof path); | |
| 288 #else | |
|
1620
8454579ab52f
As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents:
1522
diff
changeset
|
289 res = getwd(path); |
| 3400 | 290 #endif |
| 5071 | 291 Py_END_ALLOW_THREADS |
|
1620
8454579ab52f
As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents:
1522
diff
changeset
|
292 if (res == NULL) { |
|
21113
ed3dce17fc79
Merged changes made on r22b2-branch between r22b2 and r22b2-mac (the
Jack Jansen <jack.jansen@cwi.nl>
parents:
20896
diff
changeset
|
293 return mac_error(); |
| 1495 | 294 } |
| 5071 | 295 return PyString_FromString(res); |
| 1495 | 296 } |
| 297 | |
| 5071 | 298 static PyObject * |
| 1495 | 299 mac_listdir(self, args) |
| 5071 | 300 PyObject *self; |
| 301 PyObject *args; | |
| 1495 | 302 { |
|
1620
8454579ab52f
As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents:
1522
diff
changeset
|
303 char *name; |
| 5071 | 304 PyObject *d, *v; |
| 1495 | 305 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
|
306 struct dirent *ep; |
|
18960
9aa5d66cd13d
(Finally) converted to new-style args.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17813
diff
changeset
|
307 if (!PyArg_ParseTuple(args, "s", &name)) |
| 1495 | 308 return NULL; |
|
19181
1d462b737810
test_glob found a nasty bug in GUSI opendir(): it will not fail when called on files, but in stead open the parent directory! We now explicitly test for the argument being a directory and simulate ENOTDIR otherwise.
Jack Jansen <jack.jansen@cwi.nl>
parents:
18960
diff
changeset
|
309 #ifdef USE_GUSI |
|
1d462b737810
test_glob found a nasty bug in GUSI opendir(): it will not fail when called on files, but in stead open the parent directory! We now explicitly test for the argument being a directory and simulate ENOTDIR otherwise.
Jack Jansen <jack.jansen@cwi.nl>
parents:
18960
diff
changeset
|
310 /* Work around a bug in GUSI: if you opendir() a file it will |
|
1d462b737810
test_glob found a nasty bug in GUSI opendir(): it will not fail when called on files, but in stead open the parent directory! We now explicitly test for the argument being a directory and simulate ENOTDIR otherwise.
Jack Jansen <jack.jansen@cwi.nl>
parents:
18960
diff
changeset
|
311 ** actually opendir() the parent directory. |
|
1d462b737810
test_glob found a nasty bug in GUSI opendir(): it will not fail when called on files, but in stead open the parent directory! We now explicitly test for the argument being a directory and simulate ENOTDIR otherwise.
Jack Jansen <jack.jansen@cwi.nl>
parents:
18960
diff
changeset
|
312 */ |
|
1d462b737810
test_glob found a nasty bug in GUSI opendir(): it will not fail when called on files, but in stead open the parent directory! We now explicitly test for the argument being a directory and simulate ENOTDIR otherwise.
Jack Jansen <jack.jansen@cwi.nl>
parents:
18960
diff
changeset
|
313 { |
|
1d462b737810
test_glob found a nasty bug in GUSI opendir(): it will not fail when called on files, but in stead open the parent directory! We now explicitly test for the argument being a directory and simulate ENOTDIR otherwise.
Jack Jansen <jack.jansen@cwi.nl>
parents:
18960
diff
changeset
|
314 struct stat stb; |
|
1d462b737810
test_glob found a nasty bug in GUSI opendir(): it will not fail when called on files, but in stead open the parent directory! We now explicitly test for the argument being a directory and simulate ENOTDIR otherwise.
Jack Jansen <jack.jansen@cwi.nl>
parents:
18960
diff
changeset
|
315 int res; |
|
1d462b737810
test_glob found a nasty bug in GUSI opendir(): it will not fail when called on files, but in stead open the parent directory! We now explicitly test for the argument being a directory and simulate ENOTDIR otherwise.
Jack Jansen <jack.jansen@cwi.nl>
parents:
18960
diff
changeset
|
316 |
|
1d462b737810
test_glob found a nasty bug in GUSI opendir(): it will not fail when called on files, but in stead open the parent directory! We now explicitly test for the argument being a directory and simulate ENOTDIR otherwise.
Jack Jansen <jack.jansen@cwi.nl>
parents:
18960
diff
changeset
|
317 res = stat(name, &stb); |
|
1d462b737810
test_glob found a nasty bug in GUSI opendir(): it will not fail when called on files, but in stead open the parent directory! We now explicitly test for the argument being a directory and simulate ENOTDIR otherwise.
Jack Jansen <jack.jansen@cwi.nl>
parents:
18960
diff
changeset
|
318 if ( res < 0 ) |
|
1d462b737810
test_glob found a nasty bug in GUSI opendir(): it will not fail when called on files, but in stead open the parent directory! We now explicitly test for the argument being a directory and simulate ENOTDIR otherwise.
Jack Jansen <jack.jansen@cwi.nl>
parents:
18960
diff
changeset
|
319 return mac_error(); |
|
1d462b737810
test_glob found a nasty bug in GUSI opendir(): it will not fail when called on files, but in stead open the parent directory! We now explicitly test for the argument being a directory and simulate ENOTDIR otherwise.
Jack Jansen <jack.jansen@cwi.nl>
parents:
18960
diff
changeset
|
320 if (!S_ISDIR(stb.st_mode) ) { |
|
1d462b737810
test_glob found a nasty bug in GUSI opendir(): it will not fail when called on files, but in stead open the parent directory! We now explicitly test for the argument being a directory and simulate ENOTDIR otherwise.
Jack Jansen <jack.jansen@cwi.nl>
parents:
18960
diff
changeset
|
321 errno = ENOTDIR; |
|
1d462b737810
test_glob found a nasty bug in GUSI opendir(): it will not fail when called on files, but in stead open the parent directory! We now explicitly test for the argument being a directory and simulate ENOTDIR otherwise.
Jack Jansen <jack.jansen@cwi.nl>
parents:
18960
diff
changeset
|
322 return mac_error(); |
|
1d462b737810
test_glob found a nasty bug in GUSI opendir(): it will not fail when called on files, but in stead open the parent directory! We now explicitly test for the argument being a directory and simulate ENOTDIR otherwise.
Jack Jansen <jack.jansen@cwi.nl>
parents:
18960
diff
changeset
|
323 } |
|
1d462b737810
test_glob found a nasty bug in GUSI opendir(): it will not fail when called on files, but in stead open the parent directory! We now explicitly test for the argument being a directory and simulate ENOTDIR otherwise.
Jack Jansen <jack.jansen@cwi.nl>
parents:
18960
diff
changeset
|
324 } |
|
1d462b737810
test_glob found a nasty bug in GUSI opendir(): it will not fail when called on files, but in stead open the parent directory! We now explicitly test for the argument being a directory and simulate ENOTDIR otherwise.
Jack Jansen <jack.jansen@cwi.nl>
parents:
18960
diff
changeset
|
325 #endif |
|
1d462b737810
test_glob found a nasty bug in GUSI opendir(): it will not fail when called on files, but in stead open the parent directory! We now explicitly test for the argument being a directory and simulate ENOTDIR otherwise.
Jack Jansen <jack.jansen@cwi.nl>
parents:
18960
diff
changeset
|
326 |
| 5071 | 327 Py_BEGIN_ALLOW_THREADS |
|
1620
8454579ab52f
As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents:
1522
diff
changeset
|
328 if ((dirp = opendir(name)) == NULL) { |
| 5071 | 329 Py_BLOCK_THREADS |
|
1620
8454579ab52f
As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents:
1522
diff
changeset
|
330 return mac_error(); |
|
8454579ab52f
As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents:
1522
diff
changeset
|
331 } |
| 5071 | 332 if ((d = PyList_New(0)) == NULL) { |
| 1495 | 333 closedir(dirp); |
| 5071 | 334 Py_BLOCK_THREADS |
| 1495 | 335 return NULL; |
| 336 } | |
| 337 while ((ep = readdir(dirp)) != NULL) { | |
| 5071 | 338 v = PyString_FromString(ep->d_name); |
| 1495 | 339 if (v == NULL) { |
| 5071 | 340 Py_DECREF(d); |
| 1495 | 341 d = NULL; |
| 342 break; | |
| 343 } | |
| 5071 | 344 if (PyList_Append(d, v) != 0) { |
| 345 Py_DECREF(v); | |
| 346 Py_DECREF(d); | |
| 1495 | 347 d = NULL; |
| 348 break; | |
| 349 } | |
| 5071 | 350 Py_DECREF(v); |
| 1495 | 351 } |
| 352 closedir(dirp); | |
| 5071 | 353 Py_END_ALLOW_THREADS |
|
1620
8454579ab52f
As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents:
1522
diff
changeset
|
354 |
| 1495 | 355 return d; |
| 356 } | |
| 357 | |
| 5071 | 358 static PyObject * |
|
1620
8454579ab52f
As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents:
1522
diff
changeset
|
359 mac_lseek(self, args) |
| 5071 | 360 PyObject *self; |
| 361 PyObject *args; | |
|
1620
8454579ab52f
As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents:
1522
diff
changeset
|
362 { |
|
8454579ab52f
As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents:
1522
diff
changeset
|
363 int fd; |
|
8454579ab52f
As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents:
1522
diff
changeset
|
364 int where; |
|
8454579ab52f
As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents:
1522
diff
changeset
|
365 int how; |
|
8454579ab52f
As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents:
1522
diff
changeset
|
366 long res; |
|
18960
9aa5d66cd13d
(Finally) converted to new-style args.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17813
diff
changeset
|
367 if (!PyArg_ParseTuple(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
|
368 return NULL; |
| 5071 | 369 Py_BEGIN_ALLOW_THREADS |
|
1620
8454579ab52f
As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents:
1522
diff
changeset
|
370 res = lseek(fd, (long)where, how); |
| 5071 | 371 Py_END_ALLOW_THREADS |
|
1620
8454579ab52f
As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents:
1522
diff
changeset
|
372 if (res < 0) |
|
8454579ab52f
As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents:
1522
diff
changeset
|
373 return mac_error(); |
| 5071 | 374 return PyInt_FromLong(res); |
|
1620
8454579ab52f
As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents:
1522
diff
changeset
|
375 } |
| 3394 | 376 |
| 5071 | 377 static PyObject * |
| 1495 | 378 mac_mkdir(self, args) |
| 5071 | 379 PyObject *self; |
| 380 PyObject *args; | |
| 1495 | 381 { |
|
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
|
382 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
|
383 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
|
384 int mode = 0777; /* Unused */ |
| 5071 | 385 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
|
386 return NULL; |
| 5071 | 387 Py_BEGIN_ALLOW_THREADS |
|
12284
9c96e5d437a8
Started on GUSI2 and threading support.
Jack Jansen <jack.jansen@cwi.nl>
parents:
7434
diff
changeset
|
388 #ifdef USE_GUSI1 |
|
3942
38684852376f
GUSI mkdir() lost its dummy second arg
Jack Jansen <jack.jansen@cwi.nl>
parents:
3433
diff
changeset
|
389 res = mkdir(path); |
|
38684852376f
GUSI mkdir() lost its dummy second arg
Jack Jansen <jack.jansen@cwi.nl>
parents:
3433
diff
changeset
|
390 #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
|
391 res = mkdir(path, mode); |
|
3942
38684852376f
GUSI mkdir() lost its dummy second arg
Jack Jansen <jack.jansen@cwi.nl>
parents:
3433
diff
changeset
|
392 #endif |
| 5071 | 393 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
|
394 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
|
395 return mac_error(); |
| 5071 | 396 Py_INCREF(Py_None); |
| 397 return Py_None; | |
|
1620
8454579ab52f
As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents:
1522
diff
changeset
|
398 } |
|
8454579ab52f
As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents:
1522
diff
changeset
|
399 |
| 5071 | 400 static PyObject * |
|
1620
8454579ab52f
As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents:
1522
diff
changeset
|
401 mac_open(self, args) |
| 5071 | 402 PyObject *self; |
| 403 PyObject *args; | |
|
1620
8454579ab52f
As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents:
1522
diff
changeset
|
404 { |
| 1495 | 405 char *path; |
| 406 int mode; | |
|
18960
9aa5d66cd13d
(Finally) converted to new-style args.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17813
diff
changeset
|
407 int perm; /* Accepted but ignored */ |
|
1620
8454579ab52f
As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents:
1522
diff
changeset
|
408 int fd; |
|
18960
9aa5d66cd13d
(Finally) converted to new-style args.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17813
diff
changeset
|
409 if (!PyArg_ParseTuple(args, "si|i", &path, &mode, &perm)) |
| 1495 | 410 return NULL; |
| 5071 | 411 Py_BEGIN_ALLOW_THREADS |
|
1620
8454579ab52f
As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents:
1522
diff
changeset
|
412 fd = open(path, mode); |
| 5071 | 413 Py_END_ALLOW_THREADS |
|
1620
8454579ab52f
As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents:
1522
diff
changeset
|
414 if (fd < 0) |
|
8454579ab52f
As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents:
1522
diff
changeset
|
415 return mac_error(); |
| 5071 | 416 return PyInt_FromLong((long)fd); |
| 1495 | 417 } |
| 418 | |
| 5071 | 419 static PyObject * |
|
1620
8454579ab52f
As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents:
1522
diff
changeset
|
420 mac_read(self, args) |
| 5071 | 421 PyObject *self; |
| 422 PyObject *args; | |
|
1620
8454579ab52f
As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents:
1522
diff
changeset
|
423 { |
|
8454579ab52f
As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents:
1522
diff
changeset
|
424 int fd, size; |
| 5071 | 425 PyObject *buffer; |
|
18960
9aa5d66cd13d
(Finally) converted to new-style args.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17813
diff
changeset
|
426 if (!PyArg_ParseTuple(args, "ii", &fd, &size)) |
|
1620
8454579ab52f
As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents:
1522
diff
changeset
|
427 return NULL; |
| 5071 | 428 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
|
429 if (buffer == NULL) |
|
8454579ab52f
As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents:
1522
diff
changeset
|
430 return NULL; |
| 5071 | 431 Py_BEGIN_ALLOW_THREADS |
| 432 size = read(fd, PyString_AsString(buffer), size); | |
| 433 Py_END_ALLOW_THREADS | |
|
1620
8454579ab52f
As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents:
1522
diff
changeset
|
434 if (size < 0) { |
| 5071 | 435 Py_DECREF(buffer); |
|
1620
8454579ab52f
As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents:
1522
diff
changeset
|
436 return mac_error(); |
|
8454579ab52f
As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents:
1522
diff
changeset
|
437 } |
| 5071 | 438 _PyString_Resize(&buffer, size); |
|
1620
8454579ab52f
As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents:
1522
diff
changeset
|
439 return buffer; |
|
8454579ab52f
As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents:
1522
diff
changeset
|
440 } |
| 1495 | 441 |
| 5071 | 442 static PyObject * |
| 1495 | 443 mac_rename(self, args) |
| 5071 | 444 PyObject *self; |
| 445 PyObject *args; | |
| 1495 | 446 { |
|
1620
8454579ab52f
As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents:
1522
diff
changeset
|
447 return mac_2str(args, rename); |
| 1495 | 448 } |
| 449 | |
| 5071 | 450 static PyObject * |
| 1495 | 451 mac_rmdir(self, args) |
| 5071 | 452 PyObject *self; |
| 453 PyObject *args; | |
| 1495 | 454 { |
|
1620
8454579ab52f
As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents:
1522
diff
changeset
|
455 return mac_1str(args, rmdir); |
| 1495 | 456 } |
| 457 | |
|
20539
2d599a36b67a
SF patch #462296: Add attributes to os.stat results; by Nick Mathewson.
Guido van Rossum <guido@python.org>
parents:
19181
diff
changeset
|
458 static char stat_result__doc__[] = |
|
2d599a36b67a
SF patch #462296: Add attributes to os.stat results; by Nick Mathewson.
Guido van Rossum <guido@python.org>
parents:
19181
diff
changeset
|
459 "stat_result: Result from stat or lstat.\n\n\ |
|
2d599a36b67a
SF patch #462296: Add attributes to os.stat results; by Nick Mathewson.
Guido van Rossum <guido@python.org>
parents:
19181
diff
changeset
|
460 This object may be accessed either as a tuple of\n\ |
|
2d599a36b67a
SF patch #462296: Add attributes to os.stat results; by Nick Mathewson.
Guido van Rossum <guido@python.org>
parents:
19181
diff
changeset
|
461 (mode,ino,dev,nlink,uid,gid,size,atime,mtime,ctime)\n\ |
|
2d599a36b67a
SF patch #462296: Add attributes to os.stat results; by Nick Mathewson.
Guido van Rossum <guido@python.org>
parents:
19181
diff
changeset
|
462 or via the attributes st_mode, st_ino, st_dev, st_nlink, st_uid, and so on.\n\ |
|
2d599a36b67a
SF patch #462296: Add attributes to os.stat results; by Nick Mathewson.
Guido van Rossum <guido@python.org>
parents:
19181
diff
changeset
|
463 \n\ |
|
2d599a36b67a
SF patch #462296: Add attributes to os.stat results; by Nick Mathewson.
Guido van Rossum <guido@python.org>
parents:
19181
diff
changeset
|
464 See os.stat for more information.\n"; |
|
2d599a36b67a
SF patch #462296: Add attributes to os.stat results; by Nick Mathewson.
Guido van Rossum <guido@python.org>
parents:
19181
diff
changeset
|
465 |
|
2d599a36b67a
SF patch #462296: Add attributes to os.stat results; by Nick Mathewson.
Guido van Rossum <guido@python.org>
parents:
19181
diff
changeset
|
466 #define COMMON_STAT_RESULT_FIELDS \ |
|
2d599a36b67a
SF patch #462296: Add attributes to os.stat results; by Nick Mathewson.
Guido van Rossum <guido@python.org>
parents:
19181
diff
changeset
|
467 { "st_mode", "protection bits" }, \ |
|
2d599a36b67a
SF patch #462296: Add attributes to os.stat results; by Nick Mathewson.
Guido van Rossum <guido@python.org>
parents:
19181
diff
changeset
|
468 { "st_ino", "inode" }, \ |
|
20643
ef78ec602a40
Some escaped newlines had spaces between the backslash and the newline. Also slightly changed the comment on xstat().
Jack Jansen <jack.jansen@cwi.nl>
parents:
20539
diff
changeset
|
469 { "st_dev", "device" }, \ |
|
20539
2d599a36b67a
SF patch #462296: Add attributes to os.stat results; by Nick Mathewson.
Guido van Rossum <guido@python.org>
parents:
19181
diff
changeset
|
470 { "st_nlink", "number of hard links" }, \ |
|
20643
ef78ec602a40
Some escaped newlines had spaces between the backslash and the newline. Also slightly changed the comment on xstat().
Jack Jansen <jack.jansen@cwi.nl>
parents:
20539
diff
changeset
|
471 { "st_uid", "user ID of owner" }, \ |
|
ef78ec602a40
Some escaped newlines had spaces between the backslash and the newline. Also slightly changed the comment on xstat().
Jack Jansen <jack.jansen@cwi.nl>
parents:
20539
diff
changeset
|
472 { "st_gid", "group ID of owner" }, \ |
|
20539
2d599a36b67a
SF patch #462296: Add attributes to os.stat results; by Nick Mathewson.
Guido van Rossum <guido@python.org>
parents:
19181
diff
changeset
|
473 { "st_size", "total size, in bytes" }, \ |
|
2d599a36b67a
SF patch #462296: Add attributes to os.stat results; by Nick Mathewson.
Guido van Rossum <guido@python.org>
parents:
19181
diff
changeset
|
474 { "st_atime", "time of last access" }, \ |
|
2d599a36b67a
SF patch #462296: Add attributes to os.stat results; by Nick Mathewson.
Guido van Rossum <guido@python.org>
parents:
19181
diff
changeset
|
475 { "st_mtime", "time of last modification" }, \ |
|
2d599a36b67a
SF patch #462296: Add attributes to os.stat results; by Nick Mathewson.
Guido van Rossum <guido@python.org>
parents:
19181
diff
changeset
|
476 { "st_ctime", "time of last change" }, |
|
2d599a36b67a
SF patch #462296: Add attributes to os.stat results; by Nick Mathewson.
Guido van Rossum <guido@python.org>
parents:
19181
diff
changeset
|
477 |
|
2d599a36b67a
SF patch #462296: Add attributes to os.stat results; by Nick Mathewson.
Guido van Rossum <guido@python.org>
parents:
19181
diff
changeset
|
478 |
|
2d599a36b67a
SF patch #462296: Add attributes to os.stat results; by Nick Mathewson.
Guido van Rossum <guido@python.org>
parents:
19181
diff
changeset
|
479 |
|
2d599a36b67a
SF patch #462296: Add attributes to os.stat results; by Nick Mathewson.
Guido van Rossum <guido@python.org>
parents:
19181
diff
changeset
|
480 static PyStructSequence_Field stat_result_fields[] = { |
|
2d599a36b67a
SF patch #462296: Add attributes to os.stat results; by Nick Mathewson.
Guido van Rossum <guido@python.org>
parents:
19181
diff
changeset
|
481 COMMON_STAT_RESULT_FIELDS |
|
2d599a36b67a
SF patch #462296: Add attributes to os.stat results; by Nick Mathewson.
Guido van Rossum <guido@python.org>
parents:
19181
diff
changeset
|
482 {0} |
|
2d599a36b67a
SF patch #462296: Add attributes to os.stat results; by Nick Mathewson.
Guido van Rossum <guido@python.org>
parents:
19181
diff
changeset
|
483 }; |
|
2d599a36b67a
SF patch #462296: Add attributes to os.stat results; by Nick Mathewson.
Guido van Rossum <guido@python.org>
parents:
19181
diff
changeset
|
484 |
|
2d599a36b67a
SF patch #462296: Add attributes to os.stat results; by Nick Mathewson.
Guido van Rossum <guido@python.org>
parents:
19181
diff
changeset
|
485 static PyStructSequence_Desc stat_result_desc = { |
|
21313
91dd223829c6
Patch supplied by Burton Radons for his own SF bug #487390: Modifying
Guido van Rossum <guido@python.org>
parents:
21113
diff
changeset
|
486 "mac.stat_result", |
|
20539
2d599a36b67a
SF patch #462296: Add attributes to os.stat results; by Nick Mathewson.
Guido van Rossum <guido@python.org>
parents:
19181
diff
changeset
|
487 stat_result__doc__, |
|
2d599a36b67a
SF patch #462296: Add attributes to os.stat results; by Nick Mathewson.
Guido van Rossum <guido@python.org>
parents:
19181
diff
changeset
|
488 stat_result_fields, |
|
2d599a36b67a
SF patch #462296: Add attributes to os.stat results; by Nick Mathewson.
Guido van Rossum <guido@python.org>
parents:
19181
diff
changeset
|
489 10 |
|
2d599a36b67a
SF patch #462296: Add attributes to os.stat results; by Nick Mathewson.
Guido van Rossum <guido@python.org>
parents:
19181
diff
changeset
|
490 }; |
|
2d599a36b67a
SF patch #462296: Add attributes to os.stat results; by Nick Mathewson.
Guido van Rossum <guido@python.org>
parents:
19181
diff
changeset
|
491 |
|
2d599a36b67a
SF patch #462296: Add attributes to os.stat results; by Nick Mathewson.
Guido van Rossum <guido@python.org>
parents:
19181
diff
changeset
|
492 static PyTypeObject StatResultType; |
|
2d599a36b67a
SF patch #462296: Add attributes to os.stat results; by Nick Mathewson.
Guido van Rossum <guido@python.org>
parents:
19181
diff
changeset
|
493 |
|
2d599a36b67a
SF patch #462296: Add attributes to os.stat results; by Nick Mathewson.
Guido van Rossum <guido@python.org>
parents:
19181
diff
changeset
|
494 #ifdef TARGET_API_MAC_OS8 |
|
2d599a36b67a
SF patch #462296: Add attributes to os.stat results; by Nick Mathewson.
Guido van Rossum <guido@python.org>
parents:
19181
diff
changeset
|
495 static PyStructSequence_Field xstat_result_fields[] = { |
|
20643
ef78ec602a40
Some escaped newlines had spaces between the backslash and the newline. Also slightly changed the comment on xstat().
Jack Jansen <jack.jansen@cwi.nl>
parents:
20539
diff
changeset
|
496 COMMON_STAT_RESULT_FIELDS |
|
20539
2d599a36b67a
SF patch #462296: Add attributes to os.stat results; by Nick Mathewson.
Guido van Rossum <guido@python.org>
parents:
19181
diff
changeset
|
497 { "st_rsize" }, |
|
2d599a36b67a
SF patch #462296: Add attributes to os.stat results; by Nick Mathewson.
Guido van Rossum <guido@python.org>
parents:
19181
diff
changeset
|
498 { "st_creator" }, |
|
2d599a36b67a
SF patch #462296: Add attributes to os.stat results; by Nick Mathewson.
Guido van Rossum <guido@python.org>
parents:
19181
diff
changeset
|
499 { "st_type "}, |
|
2d599a36b67a
SF patch #462296: Add attributes to os.stat results; by Nick Mathewson.
Guido van Rossum <guido@python.org>
parents:
19181
diff
changeset
|
500 {0} |
|
2d599a36b67a
SF patch #462296: Add attributes to os.stat results; by Nick Mathewson.
Guido van Rossum <guido@python.org>
parents:
19181
diff
changeset
|
501 }; |
|
2d599a36b67a
SF patch #462296: Add attributes to os.stat results; by Nick Mathewson.
Guido van Rossum <guido@python.org>
parents:
19181
diff
changeset
|
502 |
|
2d599a36b67a
SF patch #462296: Add attributes to os.stat results; by Nick Mathewson.
Guido van Rossum <guido@python.org>
parents:
19181
diff
changeset
|
503 static PyStructSequence_Desc xstat_result_desc = { |
|
21313
91dd223829c6
Patch supplied by Burton Radons for his own SF bug #487390: Modifying
Guido van Rossum <guido@python.org>
parents:
21113
diff
changeset
|
504 "mac.xstat_result", |
|
20539
2d599a36b67a
SF patch #462296: Add attributes to os.stat results; by Nick Mathewson.
Guido van Rossum <guido@python.org>
parents:
19181
diff
changeset
|
505 stat_result__doc__, |
|
2d599a36b67a
SF patch #462296: Add attributes to os.stat results; by Nick Mathewson.
Guido van Rossum <guido@python.org>
parents:
19181
diff
changeset
|
506 xstat_result_fields, |
|
2d599a36b67a
SF patch #462296: Add attributes to os.stat results; by Nick Mathewson.
Guido van Rossum <guido@python.org>
parents:
19181
diff
changeset
|
507 13 |
|
2d599a36b67a
SF patch #462296: Add attributes to os.stat results; by Nick Mathewson.
Guido van Rossum <guido@python.org>
parents:
19181
diff
changeset
|
508 }; |
|
2d599a36b67a
SF patch #462296: Add attributes to os.stat results; by Nick Mathewson.
Guido van Rossum <guido@python.org>
parents:
19181
diff
changeset
|
509 |
|
2d599a36b67a
SF patch #462296: Add attributes to os.stat results; by Nick Mathewson.
Guido van Rossum <guido@python.org>
parents:
19181
diff
changeset
|
510 static PyTypeObject XStatResultType; |
|
2d599a36b67a
SF patch #462296: Add attributes to os.stat results; by Nick Mathewson.
Guido van Rossum <guido@python.org>
parents:
19181
diff
changeset
|
511 #endif |
|
2d599a36b67a
SF patch #462296: Add attributes to os.stat results; by Nick Mathewson.
Guido van Rossum <guido@python.org>
parents:
19181
diff
changeset
|
512 |
|
2d599a36b67a
SF patch #462296: Add attributes to os.stat results; by Nick Mathewson.
Guido van Rossum <guido@python.org>
parents:
19181
diff
changeset
|
513 static PyObject * |
|
2d599a36b67a
SF patch #462296: Add attributes to os.stat results; by Nick Mathewson.
Guido van Rossum <guido@python.org>
parents:
19181
diff
changeset
|
514 _pystat_from_struct_stat(struct stat st, void* _mst) |
|
2d599a36b67a
SF patch #462296: Add attributes to os.stat results; by Nick Mathewson.
Guido van Rossum <guido@python.org>
parents:
19181
diff
changeset
|
515 { |
|
2d599a36b67a
SF patch #462296: Add attributes to os.stat results; by Nick Mathewson.
Guido van Rossum <guido@python.org>
parents:
19181
diff
changeset
|
516 PyObject *v; |
|
2d599a36b67a
SF patch #462296: Add attributes to os.stat results; by Nick Mathewson.
Guido van Rossum <guido@python.org>
parents:
19181
diff
changeset
|
517 |
|
2d599a36b67a
SF patch #462296: Add attributes to os.stat results; by Nick Mathewson.
Guido van Rossum <guido@python.org>
parents:
19181
diff
changeset
|
518 #if TARGET_API_MAC_OS8 |
|
2d599a36b67a
SF patch #462296: Add attributes to os.stat results; by Nick Mathewson.
Guido van Rossum <guido@python.org>
parents:
19181
diff
changeset
|
519 struct macstat *mst; |
|
2d599a36b67a
SF patch #462296: Add attributes to os.stat results; by Nick Mathewson.
Guido van Rossum <guido@python.org>
parents:
19181
diff
changeset
|
520 |
|
2d599a36b67a
SF patch #462296: Add attributes to os.stat results; by Nick Mathewson.
Guido van Rossum <guido@python.org>
parents:
19181
diff
changeset
|
521 if (_mst != NULL) |
|
2d599a36b67a
SF patch #462296: Add attributes to os.stat results; by Nick Mathewson.
Guido van Rossum <guido@python.org>
parents:
19181
diff
changeset
|
522 v = PyStructSequence_New(&XStatResultType); |
|
2d599a36b67a
SF patch #462296: Add attributes to os.stat results; by Nick Mathewson.
Guido van Rossum <guido@python.org>
parents:
19181
diff
changeset
|
523 else |
|
2d599a36b67a
SF patch #462296: Add attributes to os.stat results; by Nick Mathewson.
Guido van Rossum <guido@python.org>
parents:
19181
diff
changeset
|
524 #endif |
|
2d599a36b67a
SF patch #462296: Add attributes to os.stat results; by Nick Mathewson.
Guido van Rossum <guido@python.org>
parents:
19181
diff
changeset
|
525 v = PyStructSequence_New(&StatResultType); |
|
2d599a36b67a
SF patch #462296: Add attributes to os.stat results; by Nick Mathewson.
Guido van Rossum <guido@python.org>
parents:
19181
diff
changeset
|
526 PyStructSequence_SET_ITEM(v, 0, PyInt_FromLong((long)st.st_mode)); |
|
2d599a36b67a
SF patch #462296: Add attributes to os.stat results; by Nick Mathewson.
Guido van Rossum <guido@python.org>
parents:
19181
diff
changeset
|
527 PyStructSequence_SET_ITEM(v, 1, PyInt_FromLong((long)st.st_ino)); |
|
2d599a36b67a
SF patch #462296: Add attributes to os.stat results; by Nick Mathewson.
Guido van Rossum <guido@python.org>
parents:
19181
diff
changeset
|
528 PyStructSequence_SET_ITEM(v, 2, PyInt_FromLong((long)st.st_dev)); |
|
2d599a36b67a
SF patch #462296: Add attributes to os.stat results; by Nick Mathewson.
Guido van Rossum <guido@python.org>
parents:
19181
diff
changeset
|
529 PyStructSequence_SET_ITEM(v, 3, PyInt_FromLong((long)st.st_nlink)); |
|
2d599a36b67a
SF patch #462296: Add attributes to os.stat results; by Nick Mathewson.
Guido van Rossum <guido@python.org>
parents:
19181
diff
changeset
|
530 PyStructSequence_SET_ITEM(v, 4, PyInt_FromLong((long)st.st_uid)); |
|
2d599a36b67a
SF patch #462296: Add attributes to os.stat results; by Nick Mathewson.
Guido van Rossum <guido@python.org>
parents:
19181
diff
changeset
|
531 PyStructSequence_SET_ITEM(v, 5, PyInt_FromLong((long)st.st_gid)); |
|
2d599a36b67a
SF patch #462296: Add attributes to os.stat results; by Nick Mathewson.
Guido van Rossum <guido@python.org>
parents:
19181
diff
changeset
|
532 PyStructSequence_SET_ITEM(v, 6, PyInt_FromLong((long)st.st_size)); |
|
2d599a36b67a
SF patch #462296: Add attributes to os.stat results; by Nick Mathewson.
Guido van Rossum <guido@python.org>
parents:
19181
diff
changeset
|
533 PyStructSequence_SET_ITEM(v, 7, |
|
2d599a36b67a
SF patch #462296: Add attributes to os.stat results; by Nick Mathewson.
Guido van Rossum <guido@python.org>
parents:
19181
diff
changeset
|
534 PyFloat_FromDouble((double)st.st_atime)); |
|
2d599a36b67a
SF patch #462296: Add attributes to os.stat results; by Nick Mathewson.
Guido van Rossum <guido@python.org>
parents:
19181
diff
changeset
|
535 PyStructSequence_SET_ITEM(v, 8, |
|
2d599a36b67a
SF patch #462296: Add attributes to os.stat results; by Nick Mathewson.
Guido van Rossum <guido@python.org>
parents:
19181
diff
changeset
|
536 PyFloat_FromDouble((double)st.st_mtime)); |
|
2d599a36b67a
SF patch #462296: Add attributes to os.stat results; by Nick Mathewson.
Guido van Rossum <guido@python.org>
parents:
19181
diff
changeset
|
537 PyStructSequence_SET_ITEM(v, 9, |
|
2d599a36b67a
SF patch #462296: Add attributes to os.stat results; by Nick Mathewson.
Guido van Rossum <guido@python.org>
parents:
19181
diff
changeset
|
538 PyFloat_FromDouble((double)st.st_ctime)); |
|
2d599a36b67a
SF patch #462296: Add attributes to os.stat results; by Nick Mathewson.
Guido van Rossum <guido@python.org>
parents:
19181
diff
changeset
|
539 #if TARGET_API_MAC_OS8 |
|
2d599a36b67a
SF patch #462296: Add attributes to os.stat results; by Nick Mathewson.
Guido van Rossum <guido@python.org>
parents:
19181
diff
changeset
|
540 if (_mst != NULL) { |
|
2d599a36b67a
SF patch #462296: Add attributes to os.stat results; by Nick Mathewson.
Guido van Rossum <guido@python.org>
parents:
19181
diff
changeset
|
541 mst = (struct macstat *) _mst; |
|
2d599a36b67a
SF patch #462296: Add attributes to os.stat results; by Nick Mathewson.
Guido van Rossum <guido@python.org>
parents:
19181
diff
changeset
|
542 PyStructSequence_SET_ITEM(v, 10, |
|
2d599a36b67a
SF patch #462296: Add attributes to os.stat results; by Nick Mathewson.
Guido van Rossum <guido@python.org>
parents:
19181
diff
changeset
|
543 PyInt_FromLong((long)mst->st_rsize)); |
|
2d599a36b67a
SF patch #462296: Add attributes to os.stat results; by Nick Mathewson.
Guido van Rossum <guido@python.org>
parents:
19181
diff
changeset
|
544 PyStructSequence_SET_ITEM(v, 11, |
|
2d599a36b67a
SF patch #462296: Add attributes to os.stat results; by Nick Mathewson.
Guido van Rossum <guido@python.org>
parents:
19181
diff
changeset
|
545 PyString_FromStringAndSize(mst->st_creator, |
|
2d599a36b67a
SF patch #462296: Add attributes to os.stat results; by Nick Mathewson.
Guido van Rossum <guido@python.org>
parents:
19181
diff
changeset
|
546 4)); |
|
2d599a36b67a
SF patch #462296: Add attributes to os.stat results; by Nick Mathewson.
Guido van Rossum <guido@python.org>
parents:
19181
diff
changeset
|
547 PyStructSequence_SET_ITEM(v, 12, |
|
2d599a36b67a
SF patch #462296: Add attributes to os.stat results; by Nick Mathewson.
Guido van Rossum <guido@python.org>
parents:
19181
diff
changeset
|
548 PyString_FromStringAndSize(mst->st_type, |
|
2d599a36b67a
SF patch #462296: Add attributes to os.stat results; by Nick Mathewson.
Guido van Rossum <guido@python.org>
parents:
19181
diff
changeset
|
549 4)); |
|
2d599a36b67a
SF patch #462296: Add attributes to os.stat results; by Nick Mathewson.
Guido van Rossum <guido@python.org>
parents:
19181
diff
changeset
|
550 } |
|
2d599a36b67a
SF patch #462296: Add attributes to os.stat results; by Nick Mathewson.
Guido van Rossum <guido@python.org>
parents:
19181
diff
changeset
|
551 #endif |
|
2d599a36b67a
SF patch #462296: Add attributes to os.stat results; by Nick Mathewson.
Guido van Rossum <guido@python.org>
parents:
19181
diff
changeset
|
552 |
|
2d599a36b67a
SF patch #462296: Add attributes to os.stat results; by Nick Mathewson.
Guido van Rossum <guido@python.org>
parents:
19181
diff
changeset
|
553 if (PyErr_Occurred()) { |
|
2d599a36b67a
SF patch #462296: Add attributes to os.stat results; by Nick Mathewson.
Guido van Rossum <guido@python.org>
parents:
19181
diff
changeset
|
554 Py_DECREF(v); |
|
2d599a36b67a
SF patch #462296: Add attributes to os.stat results; by Nick Mathewson.
Guido van Rossum <guido@python.org>
parents:
19181
diff
changeset
|
555 return NULL; |
|
2d599a36b67a
SF patch #462296: Add attributes to os.stat results; by Nick Mathewson.
Guido van Rossum <guido@python.org>
parents:
19181
diff
changeset
|
556 } |
|
2d599a36b67a
SF patch #462296: Add attributes to os.stat results; by Nick Mathewson.
Guido van Rossum <guido@python.org>
parents:
19181
diff
changeset
|
557 |
|
2d599a36b67a
SF patch #462296: Add attributes to os.stat results; by Nick Mathewson.
Guido van Rossum <guido@python.org>
parents:
19181
diff
changeset
|
558 return v; |
|
2d599a36b67a
SF patch #462296: Add attributes to os.stat results; by Nick Mathewson.
Guido van Rossum <guido@python.org>
parents:
19181
diff
changeset
|
559 } |
|
2d599a36b67a
SF patch #462296: Add attributes to os.stat results; by Nick Mathewson.
Guido van Rossum <guido@python.org>
parents:
19181
diff
changeset
|
560 |
|
2d599a36b67a
SF patch #462296: Add attributes to os.stat results; by Nick Mathewson.
Guido van Rossum <guido@python.org>
parents:
19181
diff
changeset
|
561 |
| 5071 | 562 static PyObject * |
| 1495 | 563 mac_stat(self, args) |
| 5071 | 564 PyObject *self; |
| 565 PyObject *args; | |
| 1495 | 566 { |
|
4414
02a68d623805
Fixed xstat to again include resroucefork size, creator, type. Obtain
Jack Jansen <jack.jansen@cwi.nl>
parents:
3942
diff
changeset
|
567 struct stat st; |
| 1495 | 568 char *path; |
|
1620
8454579ab52f
As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents:
1522
diff
changeset
|
569 int res; |
|
18960
9aa5d66cd13d
(Finally) converted to new-style args.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17813
diff
changeset
|
570 if (!PyArg_ParseTuple(args, "s", &path)) |
| 1495 | 571 return NULL; |
| 5071 | 572 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
|
573 res = stat(path, &st); |
| 5071 | 574 Py_END_ALLOW_THREADS |
|
1620
8454579ab52f
As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents:
1522
diff
changeset
|
575 if (res != 0) |
|
8454579ab52f
As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents:
1522
diff
changeset
|
576 return mac_error(); |
|
20539
2d599a36b67a
SF patch #462296: Add attributes to os.stat results; by Nick Mathewson.
Guido van Rossum <guido@python.org>
parents:
19181
diff
changeset
|
577 |
|
2d599a36b67a
SF patch #462296: Add attributes to os.stat results; by Nick Mathewson.
Guido van Rossum <guido@python.org>
parents:
19181
diff
changeset
|
578 return _pystat_from_struct_stat(st, NULL); |
|
7434
3de0cb82e61a
Add fstat() if using GUSI
Jack Jansen <jack.jansen@cwi.nl>
parents:
6442
diff
changeset
|
579 } |
|
3de0cb82e61a
Add fstat() if using GUSI
Jack Jansen <jack.jansen@cwi.nl>
parents:
6442
diff
changeset
|
580 |
|
3de0cb82e61a
Add fstat() if using GUSI
Jack Jansen <jack.jansen@cwi.nl>
parents:
6442
diff
changeset
|
581 #ifdef WEHAVE_FSTAT |
|
3de0cb82e61a
Add fstat() if using GUSI
Jack Jansen <jack.jansen@cwi.nl>
parents:
6442
diff
changeset
|
582 static PyObject * |
|
3de0cb82e61a
Add fstat() if using GUSI
Jack Jansen <jack.jansen@cwi.nl>
parents:
6442
diff
changeset
|
583 mac_fstat(self, args) |
|
3de0cb82e61a
Add fstat() if using GUSI
Jack Jansen <jack.jansen@cwi.nl>
parents:
6442
diff
changeset
|
584 PyObject *self; |
|
3de0cb82e61a
Add fstat() if using GUSI
Jack Jansen <jack.jansen@cwi.nl>
parents:
6442
diff
changeset
|
585 PyObject *args; |
|
3de0cb82e61a
Add fstat() if using GUSI
Jack Jansen <jack.jansen@cwi.nl>
parents:
6442
diff
changeset
|
586 { |
|
3de0cb82e61a
Add fstat() if using GUSI
Jack Jansen <jack.jansen@cwi.nl>
parents:
6442
diff
changeset
|
587 struct stat st; |
|
3de0cb82e61a
Add fstat() if using GUSI
Jack Jansen <jack.jansen@cwi.nl>
parents:
6442
diff
changeset
|
588 long fd; |
|
3de0cb82e61a
Add fstat() if using GUSI
Jack Jansen <jack.jansen@cwi.nl>
parents:
6442
diff
changeset
|
589 int res; |
|
18960
9aa5d66cd13d
(Finally) converted to new-style args.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17813
diff
changeset
|
590 if (!PyArg_ParseTuple(args, "l", &fd)) |
|
7434
3de0cb82e61a
Add fstat() if using GUSI
Jack Jansen <jack.jansen@cwi.nl>
parents:
6442
diff
changeset
|
591 return NULL; |
|
3de0cb82e61a
Add fstat() if using GUSI
Jack Jansen <jack.jansen@cwi.nl>
parents:
6442
diff
changeset
|
592 Py_BEGIN_ALLOW_THREADS |
|
3de0cb82e61a
Add fstat() if using GUSI
Jack Jansen <jack.jansen@cwi.nl>
parents:
6442
diff
changeset
|
593 res = fstat((int)fd, &st); |
|
3de0cb82e61a
Add fstat() if using GUSI
Jack Jansen <jack.jansen@cwi.nl>
parents:
6442
diff
changeset
|
594 Py_END_ALLOW_THREADS |
|
3de0cb82e61a
Add fstat() if using GUSI
Jack Jansen <jack.jansen@cwi.nl>
parents:
6442
diff
changeset
|
595 if (res != 0) |
|
3de0cb82e61a
Add fstat() if using GUSI
Jack Jansen <jack.jansen@cwi.nl>
parents:
6442
diff
changeset
|
596 return mac_error(); |
|
20539
2d599a36b67a
SF patch #462296: Add attributes to os.stat results; by Nick Mathewson.
Guido van Rossum <guido@python.org>
parents:
19181
diff
changeset
|
597 |
|
2d599a36b67a
SF patch #462296: Add attributes to os.stat results; by Nick Mathewson.
Guido van Rossum <guido@python.org>
parents:
19181
diff
changeset
|
598 return _pystat_from_struct_stat(st, NULL); |
| 1495 | 599 } |
|
7434
3de0cb82e61a
Add fstat() if using GUSI
Jack Jansen <jack.jansen@cwi.nl>
parents:
6442
diff
changeset
|
600 #endif /* WEHAVE_FSTAT */ |
| 1495 | 601 |
|
17813
8cd8741ebec0
Be more sensible about when to use TARGET_API_MAC_OS8 in stead of !TARGET_API_MAC_CARBON. This should greatly facilitate porting stuff to OSX in its MachO/BSD incarnation.
Jack Jansen <jack.jansen@cwi.nl>
parents:
15835
diff
changeset
|
602 #if TARGET_API_MAC_OS8 |
| 5071 | 603 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
|
604 mac_xstat(self, args) |
| 5071 | 605 PyObject *self; |
| 606 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
|
607 { |
|
4414
02a68d623805
Fixed xstat to again include resroucefork size, creator, type. Obtain
Jack Jansen <jack.jansen@cwi.nl>
parents:
3942
diff
changeset
|
608 struct macstat mst; |
|
02a68d623805
Fixed xstat to again include resroucefork size, creator, type. Obtain
Jack Jansen <jack.jansen@cwi.nl>
parents:
3942
diff
changeset
|
609 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
|
610 char *path; |
|
7d1ecec25c06
add xstat (extended stat, returns resource fork size and creator/type)
Guido van Rossum <guido@python.org>
parents:
2722
diff
changeset
|
611 int res; |
|
18960
9aa5d66cd13d
(Finally) converted to new-style args.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17813
diff
changeset
|
612 if (!PyArg_ParseTuple(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
|
613 return NULL; |
|
4414
02a68d623805
Fixed xstat to again include resroucefork size, creator, type. Obtain
Jack Jansen <jack.jansen@cwi.nl>
parents:
3942
diff
changeset
|
614 /* |
|
02a68d623805
Fixed xstat to again include resroucefork size, creator, type. Obtain
Jack Jansen <jack.jansen@cwi.nl>
parents:
3942
diff
changeset
|
615 ** 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
|
616 ** 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
|
617 ** the former. |
|
02a68d623805
Fixed xstat to again include resroucefork size, creator, type. Obtain
Jack Jansen <jack.jansen@cwi.nl>
parents:
3942
diff
changeset
|
618 */ |
| 5071 | 619 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
|
620 res = macstat(path, &mst); |
| 5071 | 621 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
|
622 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
|
623 return mac_error(); |
| 5071 | 624 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
|
625 res = stat(path, &st); |
| 5071 | 626 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
|
627 if (res != 0) |
|
02a68d623805
Fixed xstat to again include resroucefork size, creator, type. Obtain
Jack Jansen <jack.jansen@cwi.nl>
parents:
3942
diff
changeset
|
628 return mac_error(); |
|
20539
2d599a36b67a
SF patch #462296: Add attributes to os.stat results; by Nick Mathewson.
Guido van Rossum <guido@python.org>
parents:
19181
diff
changeset
|
629 |
|
2d599a36b67a
SF patch #462296: Add attributes to os.stat results; by Nick Mathewson.
Guido van Rossum <guido@python.org>
parents:
19181
diff
changeset
|
630 return _pystat_from_struct_stat(st, (void*) &mst); |
|
2929
7d1ecec25c06
add xstat (extended stat, returns resource fork size and creator/type)
Guido van Rossum <guido@python.org>
parents:
2722
diff
changeset
|
631 } |
|
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
|
632 #endif |
|
2929
7d1ecec25c06
add xstat (extended stat, returns resource fork size and creator/type)
Guido van Rossum <guido@python.org>
parents:
2722
diff
changeset
|
633 |
| 5071 | 634 static PyObject * |
| 1495 | 635 mac_sync(self, args) |
| 5071 | 636 PyObject *self; |
| 637 PyObject *args; | |
| 1495 | 638 { |
|
1620
8454579ab52f
As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents:
1522
diff
changeset
|
639 int res; |
|
18960
9aa5d66cd13d
(Finally) converted to new-style args.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17813
diff
changeset
|
640 if (!PyArg_ParseTuple(args, "")) |
| 1495 | 641 return NULL; |
| 5071 | 642 Py_BEGIN_ALLOW_THREADS |
|
22410
457bf184e7ba
sync() has different return values depending on whether we build with GUSI or not.
Jack Jansen <jack.jansen@cwi.nl>
parents:
21313
diff
changeset
|
643 #ifdef USE_GUSI2 |
|
457bf184e7ba
sync() has different return values depending on whether we build with GUSI or not.
Jack Jansen <jack.jansen@cwi.nl>
parents:
21313
diff
changeset
|
644 sync(); |
|
457bf184e7ba
sync() has different return values depending on whether we build with GUSI or not.
Jack Jansen <jack.jansen@cwi.nl>
parents:
21313
diff
changeset
|
645 res = 0; |
|
457bf184e7ba
sync() has different return values depending on whether we build with GUSI or not.
Jack Jansen <jack.jansen@cwi.nl>
parents:
21313
diff
changeset
|
646 #else |
|
1620
8454579ab52f
As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents:
1522
diff
changeset
|
647 res = sync(); |
|
22410
457bf184e7ba
sync() has different return values depending on whether we build with GUSI or not.
Jack Jansen <jack.jansen@cwi.nl>
parents:
21313
diff
changeset
|
648 #endif |
| 5071 | 649 Py_END_ALLOW_THREADS |
|
1620
8454579ab52f
As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents:
1522
diff
changeset
|
650 if (res != 0) |
|
8454579ab52f
As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents:
1522
diff
changeset
|
651 return mac_error(); |
| 5071 | 652 Py_INCREF(Py_None); |
| 653 return Py_None; | |
| 1495 | 654 } |
| 655 | |
| 5071 | 656 static PyObject * |
| 1495 | 657 mac_unlink(self, args) |
| 5071 | 658 PyObject *self; |
| 659 PyObject *args; | |
| 1495 | 660 { |
|
1822
76d0f2b3b9ee
Completed (hopefully) the unification of THINK 6.0 and MPW 3.2
Guido van Rossum <guido@python.org>
parents:
1821
diff
changeset
|
661 return mac_1str(args, (int (*)(const char *))unlink); |
| 1495 | 662 } |
| 663 | |
| 5071 | 664 static PyObject * |
|
1620
8454579ab52f
As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents:
1522
diff
changeset
|
665 mac_write(self, args) |
| 5071 | 666 PyObject *self; |
| 667 PyObject *args; | |
|
1620
8454579ab52f
As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents:
1522
diff
changeset
|
668 { |
|
8454579ab52f
As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents:
1522
diff
changeset
|
669 int fd, size; |
|
8454579ab52f
As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents:
1522
diff
changeset
|
670 char *buffer; |
|
18960
9aa5d66cd13d
(Finally) converted to new-style args.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17813
diff
changeset
|
671 if (!PyArg_ParseTuple(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
|
672 return NULL; |
| 5071 | 673 Py_BEGIN_ALLOW_THREADS |
|
1620
8454579ab52f
As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents:
1522
diff
changeset
|
674 size = write(fd, buffer, size); |
| 5071 | 675 Py_END_ALLOW_THREADS |
|
1620
8454579ab52f
As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents:
1522
diff
changeset
|
676 if (size < 0) |
|
8454579ab52f
As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents:
1522
diff
changeset
|
677 return mac_error(); |
| 5071 | 678 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
|
679 } |
| 1495 | 680 |
|
4468
600f5b8a16cb
Malloc debugging now flagged with USE_MALLOC_DEBUG
Jack Jansen <jack.jansen@cwi.nl>
parents:
4414
diff
changeset
|
681 #ifdef USE_MALLOC_DEBUG |
|
14205
3ae185b8ff03
Added a prototype for mstats().
Jack Jansen <jack.jansen@cwi.nl>
parents:
13608
diff
changeset
|
682 void *mstats(char *); |
|
3ae185b8ff03
Added a prototype for mstats().
Jack Jansen <jack.jansen@cwi.nl>
parents:
13608
diff
changeset
|
683 |
| 5071 | 684 static PyObject * |
|
2179
8da03decef59
More Pstring() stuff and some cosmetics
Jack Jansen <jack.jansen@cwi.nl>
parents:
2091
diff
changeset
|
685 mac_mstats(self, args) |
| 5071 | 686 PyObject*self; |
| 687 PyObject *args; | |
|
2179
8da03decef59
More Pstring() stuff and some cosmetics
Jack Jansen <jack.jansen@cwi.nl>
parents:
2091
diff
changeset
|
688 { |
|
8da03decef59
More Pstring() stuff and some cosmetics
Jack Jansen <jack.jansen@cwi.nl>
parents:
2091
diff
changeset
|
689 mstats("python"); |
| 5071 | 690 Py_INCREF(Py_None); |
| 691 return Py_None; | |
|
2179
8da03decef59
More Pstring() stuff and some cosmetics
Jack Jansen <jack.jansen@cwi.nl>
parents:
2091
diff
changeset
|
692 } |
|
5141
a4c8b8871376
Comments around identifier after #endif
Jack Jansen <jack.jansen@cwi.nl>
parents:
5079
diff
changeset
|
693 #endif /* USE_MALLOC_DEBUG */ |
|
2179
8da03decef59
More Pstring() stuff and some cosmetics
Jack Jansen <jack.jansen@cwi.nl>
parents:
2091
diff
changeset
|
694 |
| 5071 | 695 static struct PyMethodDef mac_methods[] = { |
|
18960
9aa5d66cd13d
(Finally) converted to new-style args.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17813
diff
changeset
|
696 {"chdir", mac_chdir, 1}, |
|
9aa5d66cd13d
(Finally) converted to new-style args.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17813
diff
changeset
|
697 {"close", mac_close, 1}, |
| 3400 | 698 #ifdef WEHAVE_DUP |
|
18960
9aa5d66cd13d
(Finally) converted to new-style args.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17813
diff
changeset
|
699 {"dup", mac_dup, 1}, |
|
1821
40594f80ab3c
Intermediate version of changes after porting to MPW 3.2
Guido van Rossum <guido@python.org>
parents:
1808
diff
changeset
|
700 #endif |
| 3400 | 701 #ifdef WEHAVE_FDOPEN |
|
18960
9aa5d66cd13d
(Finally) converted to new-style args.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17813
diff
changeset
|
702 {"fdopen", mac_fdopen, 1}, |
|
2032
609bfb8ae7f5
Ported to MetroWerks, which misses file-descriptor like functionality.
Jack Jansen <jack.jansen@cwi.nl>
parents:
1822
diff
changeset
|
703 #endif |
|
7434
3de0cb82e61a
Add fstat() if using GUSI
Jack Jansen <jack.jansen@cwi.nl>
parents:
6442
diff
changeset
|
704 #ifdef WEHAVE_FSTAT |
|
18960
9aa5d66cd13d
(Finally) converted to new-style args.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17813
diff
changeset
|
705 {"fstat", mac_fstat, 1}, |
|
7434
3de0cb82e61a
Add fstat() if using GUSI
Jack Jansen <jack.jansen@cwi.nl>
parents:
6442
diff
changeset
|
706 #endif |
|
17813
8cd8741ebec0
Be more sensible about when to use TARGET_API_MAC_OS8 in stead of !TARGET_API_MAC_CARBON. This should greatly facilitate porting stuff to OSX in its MachO/BSD incarnation.
Jack Jansen <jack.jansen@cwi.nl>
parents:
15835
diff
changeset
|
707 #if TARGET_API_MAC_OS8 |
|
18960
9aa5d66cd13d
(Finally) converted to new-style args.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17813
diff
changeset
|
708 {"getbootvol", mac_getbootvol, 1}, /* 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
|
709 #endif |
|
18960
9aa5d66cd13d
(Finally) converted to new-style args.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17813
diff
changeset
|
710 {"getcwd", mac_getcwd, 1}, |
|
9aa5d66cd13d
(Finally) converted to new-style args.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17813
diff
changeset
|
711 {"listdir", mac_listdir, 1}, |
|
9aa5d66cd13d
(Finally) converted to new-style args.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17813
diff
changeset
|
712 {"lseek", mac_lseek, 1}, |
|
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
|
713 {"mkdir", mac_mkdir, 1}, |
|
18960
9aa5d66cd13d
(Finally) converted to new-style args.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17813
diff
changeset
|
714 {"open", mac_open, 1}, |
|
9aa5d66cd13d
(Finally) converted to new-style args.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17813
diff
changeset
|
715 {"read", mac_read, 1}, |
|
9aa5d66cd13d
(Finally) converted to new-style args.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17813
diff
changeset
|
716 {"rename", mac_rename, 1}, |
|
9aa5d66cd13d
(Finally) converted to new-style args.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17813
diff
changeset
|
717 {"rmdir", mac_rmdir, 1}, |
|
9aa5d66cd13d
(Finally) converted to new-style args.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17813
diff
changeset
|
718 {"stat", mac_stat, 1}, |
|
17813
8cd8741ebec0
Be more sensible about when to use TARGET_API_MAC_OS8 in stead of !TARGET_API_MAC_CARBON. This should greatly facilitate porting stuff to OSX in its MachO/BSD incarnation.
Jack Jansen <jack.jansen@cwi.nl>
parents:
15835
diff
changeset
|
719 #if TARGET_API_MAC_OS8 |
|
18960
9aa5d66cd13d
(Finally) converted to new-style args.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17813
diff
changeset
|
720 {"xstat", mac_xstat, 1}, |
|
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
|
721 #endif |
|
18960
9aa5d66cd13d
(Finally) converted to new-style args.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17813
diff
changeset
|
722 {"sync", mac_sync, 1}, |
|
9aa5d66cd13d
(Finally) converted to new-style args.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17813
diff
changeset
|
723 {"remove", mac_unlink, 1}, |
|
9aa5d66cd13d
(Finally) converted to new-style args.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17813
diff
changeset
|
724 {"unlink", mac_unlink, 1}, |
|
9aa5d66cd13d
(Finally) converted to new-style args.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17813
diff
changeset
|
725 {"write", mac_write, 1}, |
|
4468
600f5b8a16cb
Malloc debugging now flagged with USE_MALLOC_DEBUG
Jack Jansen <jack.jansen@cwi.nl>
parents:
4414
diff
changeset
|
726 #ifdef USE_MALLOC_DEBUG |
|
18960
9aa5d66cd13d
(Finally) converted to new-style args.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17813
diff
changeset
|
727 {"mstats", mac_mstats, 1}, |
|
2179
8da03decef59
More Pstring() stuff and some cosmetics
Jack Jansen <jack.jansen@cwi.nl>
parents:
2091
diff
changeset
|
728 #endif |
|
1620
8454579ab52f
As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents:
1522
diff
changeset
|
729 |
| 1495 | 730 {NULL, NULL} /* Sentinel */ |
| 731 }; | |
| 732 | |
|
18960
9aa5d66cd13d
(Finally) converted to new-style args.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17813
diff
changeset
|
733 static int |
|
9aa5d66cd13d
(Finally) converted to new-style args.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17813
diff
changeset
|
734 ins(PyObject *d, char *symbol, long value) |
|
9aa5d66cd13d
(Finally) converted to new-style args.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17813
diff
changeset
|
735 { |
|
9aa5d66cd13d
(Finally) converted to new-style args.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17813
diff
changeset
|
736 PyObject* v = PyInt_FromLong(value); |
|
9aa5d66cd13d
(Finally) converted to new-style args.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17813
diff
changeset
|
737 if (!v || PyDict_SetItemString(d, symbol, v) < 0) |
|
9aa5d66cd13d
(Finally) converted to new-style args.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17813
diff
changeset
|
738 return -1; /* triggers fatal error */ |
|
9aa5d66cd13d
(Finally) converted to new-style args.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17813
diff
changeset
|
739 |
|
9aa5d66cd13d
(Finally) converted to new-style args.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17813
diff
changeset
|
740 Py_DECREF(v); |
|
9aa5d66cd13d
(Finally) converted to new-style args.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17813
diff
changeset
|
741 return 0; |
|
9aa5d66cd13d
(Finally) converted to new-style args.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17813
diff
changeset
|
742 } |
|
9aa5d66cd13d
(Finally) converted to new-style args.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17813
diff
changeset
|
743 |
|
9aa5d66cd13d
(Finally) converted to new-style args.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17813
diff
changeset
|
744 static int |
|
9aa5d66cd13d
(Finally) converted to new-style args.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17813
diff
changeset
|
745 all_ins(PyObject *d) |
|
9aa5d66cd13d
(Finally) converted to new-style args.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17813
diff
changeset
|
746 { |
|
9aa5d66cd13d
(Finally) converted to new-style args.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17813
diff
changeset
|
747 #ifdef F_OK |
|
9aa5d66cd13d
(Finally) converted to new-style args.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17813
diff
changeset
|
748 if (ins(d, "F_OK", (long)F_OK)) return -1; |
|
9aa5d66cd13d
(Finally) converted to new-style args.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17813
diff
changeset
|
749 #endif |
|
9aa5d66cd13d
(Finally) converted to new-style args.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17813
diff
changeset
|
750 #ifdef R_OK |
|
9aa5d66cd13d
(Finally) converted to new-style args.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17813
diff
changeset
|
751 if (ins(d, "R_OK", (long)R_OK)) return -1; |
|
9aa5d66cd13d
(Finally) converted to new-style args.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17813
diff
changeset
|
752 #endif |
|
9aa5d66cd13d
(Finally) converted to new-style args.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17813
diff
changeset
|
753 #ifdef W_OK |
|
9aa5d66cd13d
(Finally) converted to new-style args.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17813
diff
changeset
|
754 if (ins(d, "W_OK", (long)W_OK)) return -1; |
|
9aa5d66cd13d
(Finally) converted to new-style args.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17813
diff
changeset
|
755 #endif |
|
9aa5d66cd13d
(Finally) converted to new-style args.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17813
diff
changeset
|
756 #ifdef X_OK |
|
9aa5d66cd13d
(Finally) converted to new-style args.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17813
diff
changeset
|
757 if (ins(d, "X_OK", (long)X_OK)) return -1; |
|
9aa5d66cd13d
(Finally) converted to new-style args.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17813
diff
changeset
|
758 #endif |
|
9aa5d66cd13d
(Finally) converted to new-style args.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17813
diff
changeset
|
759 #ifdef NGROUPS_MAX |
|
9aa5d66cd13d
(Finally) converted to new-style args.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17813
diff
changeset
|
760 if (ins(d, "NGROUPS_MAX", (long)NGROUPS_MAX)) return -1; |
|
9aa5d66cd13d
(Finally) converted to new-style args.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17813
diff
changeset
|
761 #endif |
|
9aa5d66cd13d
(Finally) converted to new-style args.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17813
diff
changeset
|
762 #ifdef TMP_MAX |
|
9aa5d66cd13d
(Finally) converted to new-style args.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17813
diff
changeset
|
763 if (ins(d, "TMP_MAX", (long)TMP_MAX)) return -1; |
|
9aa5d66cd13d
(Finally) converted to new-style args.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17813
diff
changeset
|
764 #endif |
|
9aa5d66cd13d
(Finally) converted to new-style args.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17813
diff
changeset
|
765 #ifdef WNOHANG |
|
9aa5d66cd13d
(Finally) converted to new-style args.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17813
diff
changeset
|
766 if (ins(d, "WNOHANG", (long)WNOHANG)) return -1; |
|
9aa5d66cd13d
(Finally) converted to new-style args.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17813
diff
changeset
|
767 #endif |
|
9aa5d66cd13d
(Finally) converted to new-style args.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17813
diff
changeset
|
768 #ifdef O_RDONLY |
|
9aa5d66cd13d
(Finally) converted to new-style args.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17813
diff
changeset
|
769 if (ins(d, "O_RDONLY", (long)O_RDONLY)) return -1; |
|
9aa5d66cd13d
(Finally) converted to new-style args.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17813
diff
changeset
|
770 #endif |
|
9aa5d66cd13d
(Finally) converted to new-style args.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17813
diff
changeset
|
771 #ifdef O_WRONLY |
|
9aa5d66cd13d
(Finally) converted to new-style args.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17813
diff
changeset
|
772 if (ins(d, "O_WRONLY", (long)O_WRONLY)) return -1; |
|
9aa5d66cd13d
(Finally) converted to new-style args.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17813
diff
changeset
|
773 #endif |
|
9aa5d66cd13d
(Finally) converted to new-style args.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17813
diff
changeset
|
774 #ifdef O_RDWR |
|
9aa5d66cd13d
(Finally) converted to new-style args.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17813
diff
changeset
|
775 if (ins(d, "O_RDWR", (long)O_RDWR)) return -1; |
|
9aa5d66cd13d
(Finally) converted to new-style args.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17813
diff
changeset
|
776 #endif |
|
9aa5d66cd13d
(Finally) converted to new-style args.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17813
diff
changeset
|
777 #ifdef O_NDELAY |
|
9aa5d66cd13d
(Finally) converted to new-style args.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17813
diff
changeset
|
778 if (ins(d, "O_NDELAY", (long)O_NDELAY)) return -1; |
|
9aa5d66cd13d
(Finally) converted to new-style args.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17813
diff
changeset
|
779 #endif |
|
9aa5d66cd13d
(Finally) converted to new-style args.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17813
diff
changeset
|
780 #ifdef O_NONBLOCK |
|
9aa5d66cd13d
(Finally) converted to new-style args.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17813
diff
changeset
|
781 if (ins(d, "O_NONBLOCK", (long)O_NONBLOCK)) return -1; |
|
9aa5d66cd13d
(Finally) converted to new-style args.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17813
diff
changeset
|
782 #endif |
|
9aa5d66cd13d
(Finally) converted to new-style args.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17813
diff
changeset
|
783 #ifdef O_APPEND |
|
9aa5d66cd13d
(Finally) converted to new-style args.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17813
diff
changeset
|
784 if (ins(d, "O_APPEND", (long)O_APPEND)) return -1; |
|
9aa5d66cd13d
(Finally) converted to new-style args.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17813
diff
changeset
|
785 #endif |
|
9aa5d66cd13d
(Finally) converted to new-style args.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17813
diff
changeset
|
786 #ifdef O_DSYNC |
|
9aa5d66cd13d
(Finally) converted to new-style args.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17813
diff
changeset
|
787 if (ins(d, "O_DSYNC", (long)O_DSYNC)) return -1; |
|
9aa5d66cd13d
(Finally) converted to new-style args.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17813
diff
changeset
|
788 #endif |
|
9aa5d66cd13d
(Finally) converted to new-style args.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17813
diff
changeset
|
789 #ifdef O_RSYNC |
|
9aa5d66cd13d
(Finally) converted to new-style args.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17813
diff
changeset
|
790 if (ins(d, "O_RSYNC", (long)O_RSYNC)) return -1; |
|
9aa5d66cd13d
(Finally) converted to new-style args.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17813
diff
changeset
|
791 #endif |
|
9aa5d66cd13d
(Finally) converted to new-style args.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17813
diff
changeset
|
792 #ifdef O_SYNC |
|
9aa5d66cd13d
(Finally) converted to new-style args.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17813
diff
changeset
|
793 if (ins(d, "O_SYNC", (long)O_SYNC)) return -1; |
|
9aa5d66cd13d
(Finally) converted to new-style args.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17813
diff
changeset
|
794 #endif |
|
9aa5d66cd13d
(Finally) converted to new-style args.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17813
diff
changeset
|
795 #ifdef O_NOCTTY |
|
9aa5d66cd13d
(Finally) converted to new-style args.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17813
diff
changeset
|
796 if (ins(d, "O_NOCTTY", (long)O_NOCTTY)) return -1; |
|
9aa5d66cd13d
(Finally) converted to new-style args.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17813
diff
changeset
|
797 #endif |
|
9aa5d66cd13d
(Finally) converted to new-style args.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17813
diff
changeset
|
798 #ifdef O_CREAT |
|
9aa5d66cd13d
(Finally) converted to new-style args.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17813
diff
changeset
|
799 if (ins(d, "O_CREAT", (long)O_CREAT)) return -1; |
|
9aa5d66cd13d
(Finally) converted to new-style args.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17813
diff
changeset
|
800 #endif |
|
9aa5d66cd13d
(Finally) converted to new-style args.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17813
diff
changeset
|
801 #ifdef O_EXCL |
|
9aa5d66cd13d
(Finally) converted to new-style args.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17813
diff
changeset
|
802 if (ins(d, "O_EXCL", (long)O_EXCL)) return -1; |
|
9aa5d66cd13d
(Finally) converted to new-style args.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17813
diff
changeset
|
803 #endif |
|
9aa5d66cd13d
(Finally) converted to new-style args.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17813
diff
changeset
|
804 #ifdef O_TRUNC |
|
9aa5d66cd13d
(Finally) converted to new-style args.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17813
diff
changeset
|
805 if (ins(d, "O_TRUNC", (long)O_TRUNC)) return -1; |
|
9aa5d66cd13d
(Finally) converted to new-style args.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17813
diff
changeset
|
806 #endif |
|
9aa5d66cd13d
(Finally) converted to new-style args.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17813
diff
changeset
|
807 #ifdef O_BINARY |
|
9aa5d66cd13d
(Finally) converted to new-style args.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17813
diff
changeset
|
808 if (ins(d, "O_BINARY", (long)O_BINARY)) return -1; |
|
9aa5d66cd13d
(Finally) converted to new-style args.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17813
diff
changeset
|
809 #endif |
|
9aa5d66cd13d
(Finally) converted to new-style args.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17813
diff
changeset
|
810 #ifdef O_TEXT |
|
9aa5d66cd13d
(Finally) converted to new-style args.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17813
diff
changeset
|
811 if (ins(d, "O_TEXT", (long)O_TEXT)) return -1; |
|
9aa5d66cd13d
(Finally) converted to new-style args.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17813
diff
changeset
|
812 #endif |
|
9aa5d66cd13d
(Finally) converted to new-style args.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17813
diff
changeset
|
813 |
|
9aa5d66cd13d
(Finally) converted to new-style args.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17813
diff
changeset
|
814 #ifdef HAVE_SPAWNV |
|
9aa5d66cd13d
(Finally) converted to new-style args.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17813
diff
changeset
|
815 if (ins(d, "P_WAIT", (long)_P_WAIT)) return -1; |
|
9aa5d66cd13d
(Finally) converted to new-style args.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17813
diff
changeset
|
816 if (ins(d, "P_NOWAIT", (long)_P_NOWAIT)) return -1; |
|
9aa5d66cd13d
(Finally) converted to new-style args.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17813
diff
changeset
|
817 if (ins(d, "P_OVERLAY", (long)_OLD_P_OVERLAY)) return -1; |
|
9aa5d66cd13d
(Finally) converted to new-style args.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17813
diff
changeset
|
818 if (ins(d, "P_NOWAITO", (long)_P_NOWAITO)) return -1; |
|
9aa5d66cd13d
(Finally) converted to new-style args.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17813
diff
changeset
|
819 if (ins(d, "P_DETACH", (long)_P_DETACH)) return -1; |
|
9aa5d66cd13d
(Finally) converted to new-style args.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17813
diff
changeset
|
820 #endif |
|
9aa5d66cd13d
(Finally) converted to new-style args.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17813
diff
changeset
|
821 |
|
9aa5d66cd13d
(Finally) converted to new-style args.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17813
diff
changeset
|
822 #if defined(PYOS_OS2) |
|
9aa5d66cd13d
(Finally) converted to new-style args.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17813
diff
changeset
|
823 if (insertvalues(d)) return -1; |
|
9aa5d66cd13d
(Finally) converted to new-style args.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17813
diff
changeset
|
824 #endif |
|
9aa5d66cd13d
(Finally) converted to new-style args.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17813
diff
changeset
|
825 return 0; |
|
9aa5d66cd13d
(Finally) converted to new-style args.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17813
diff
changeset
|
826 } |
|
9aa5d66cd13d
(Finally) converted to new-style args.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17813
diff
changeset
|
827 |
| 1495 | 828 |
| 829 void | |
| 830 initmac() | |
| 831 { | |
| 5071 | 832 PyObject *m, *d; |
| 1495 | 833 |
| 5071 | 834 m = Py_InitModule("mac", mac_methods); |
| 835 d = PyModule_GetDict(m); | |
| 1495 | 836 |
|
18960
9aa5d66cd13d
(Finally) converted to new-style args.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17813
diff
changeset
|
837 if (all_ins(d)) |
|
9aa5d66cd13d
(Finally) converted to new-style args.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17813
diff
changeset
|
838 return; |
|
9aa5d66cd13d
(Finally) converted to new-style args.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17813
diff
changeset
|
839 |
| 1495 | 840 /* Initialize mac.error exception */ |
|
21113
ed3dce17fc79
Merged changes made on r22b2-branch between r22b2 and r22b2-mac (the
Jack Jansen <jack.jansen@cwi.nl>
parents:
20896
diff
changeset
|
841 PyDict_SetItemString(d, "error", PyExc_OSError); |
|
20539
2d599a36b67a
SF patch #462296: Add attributes to os.stat results; by Nick Mathewson.
Guido van Rossum <guido@python.org>
parents:
19181
diff
changeset
|
842 |
|
2d599a36b67a
SF patch #462296: Add attributes to os.stat results; by Nick Mathewson.
Guido van Rossum <guido@python.org>
parents:
19181
diff
changeset
|
843 PyStructSequence_InitType(&StatResultType, &stat_result_desc); |
|
2d599a36b67a
SF patch #462296: Add attributes to os.stat results; by Nick Mathewson.
Guido van Rossum <guido@python.org>
parents:
19181
diff
changeset
|
844 PyDict_SetItemString(d, "stat_result", (PyObject*) &StatResultType); |
|
2d599a36b67a
SF patch #462296: Add attributes to os.stat results; by Nick Mathewson.
Guido van Rossum <guido@python.org>
parents:
19181
diff
changeset
|
845 |
|
2d599a36b67a
SF patch #462296: Add attributes to os.stat results; by Nick Mathewson.
Guido van Rossum <guido@python.org>
parents:
19181
diff
changeset
|
846 #if TARGET_API_MAC_OS8 |
|
2d599a36b67a
SF patch #462296: Add attributes to os.stat results; by Nick Mathewson.
Guido van Rossum <guido@python.org>
parents:
19181
diff
changeset
|
847 PyStructSequence_InitType(&XStatResultType, &xstat_result_desc); |
|
2d599a36b67a
SF patch #462296: Add attributes to os.stat results; by Nick Mathewson.
Guido van Rossum <guido@python.org>
parents:
19181
diff
changeset
|
848 PyDict_SetItemString(d, "xstat_result", (PyObject*) &XStatResultType); |
|
2d599a36b67a
SF patch #462296: Add attributes to os.stat results; by Nick Mathewson.
Guido van Rossum <guido@python.org>
parents:
19181
diff
changeset
|
849 #endif |
| 1495 | 850 } |
