Mercurial > cpython-lru_cache-weakref
annotate Mac/Modules/macmodule.c @ 27998:e27f58a50737 legacy-trunk
SF bug #690377: Dud footnote reference in distutils docs
| author | Raymond Hettinger <python@rcn.com> |
|---|---|
| date | Fri, 21 Feb 2003 02:47:09 +0000 |
| parents | eb6b36b26e8d |
| children |
| 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 |
| 3394 | 35 #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
|
36 /* 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
|
37 #undef S_IFMT |
|
02a68d623805
Fixed xstat to again include resroucefork size, creator, type. Obtain
Jack Jansen <jack.jansen@cwi.nl>
parents:
3942
diff
changeset
|
38 #undef S_IFDIR |
|
02a68d623805
Fixed xstat to again include resroucefork size, creator, type. Obtain
Jack Jansen <jack.jansen@cwi.nl>
parents:
3942
diff
changeset
|
39 #undef S_IFREG |
|
02a68d623805
Fixed xstat to again include resroucefork size, creator, type. Obtain
Jack Jansen <jack.jansen@cwi.nl>
parents:
3942
diff
changeset
|
40 #undef S_IREAD |
|
02a68d623805
Fixed xstat to again include resroucefork size, creator, type. Obtain
Jack Jansen <jack.jansen@cwi.nl>
parents:
3942
diff
changeset
|
41 #undef S_IWRITE |
|
02a68d623805
Fixed xstat to again include resroucefork size, creator, type. Obtain
Jack Jansen <jack.jansen@cwi.nl>
parents:
3942
diff
changeset
|
42 #undef S_IEXEC |
|
02a68d623805
Fixed xstat to again include resroucefork size, creator, type. Obtain
Jack Jansen <jack.jansen@cwi.nl>
parents:
3942
diff
changeset
|
43 |
| 3394 | 44 #include <sys/types.h> |
|
12284
9c96e5d437a8
Started on GUSI2 and threading support.
Jack Jansen <jack.jansen@cwi.nl>
parents:
7434
diff
changeset
|
45 #include <sys/stat.h> |
|
9c96e5d437a8
Started on GUSI2 and threading support.
Jack Jansen <jack.jansen@cwi.nl>
parents:
7434
diff
changeset
|
46 #else /* USE_GUSI */ |
|
9c96e5d437a8
Started on GUSI2 and threading support.
Jack Jansen <jack.jansen@cwi.nl>
parents:
7434
diff
changeset
|
47 #endif /* USE_GUSI */ |
|
9c96e5d437a8
Started on GUSI2 and threading support.
Jack Jansen <jack.jansen@cwi.nl>
parents:
7434
diff
changeset
|
48 |
|
9c96e5d437a8
Started on GUSI2 and threading support.
Jack Jansen <jack.jansen@cwi.nl>
parents:
7434
diff
changeset
|
49 #ifdef USE_GUSI2 |
|
9c96e5d437a8
Started on GUSI2 and threading support.
Jack Jansen <jack.jansen@cwi.nl>
parents:
7434
diff
changeset
|
50 #include <unistd.h> |
|
9c96e5d437a8
Started on GUSI2 and threading support.
Jack Jansen <jack.jansen@cwi.nl>
parents:
7434
diff
changeset
|
51 #include <fcntl.h> |
| 3394 | 52 #else |
|
12686
bc96c912dce8
Fixed to work again without USE_GUSI
Jack Jansen <jack.jansen@cwi.nl>
parents:
12284
diff
changeset
|
53 #define mode_t int |
|
1620
8454579ab52f
As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents:
1522
diff
changeset
|
54 #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
|
55 #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
|
56 #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
|
57 #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
|
58 #endif |
|
2032
609bfb8ae7f5
Ported to MetroWerks, which misses file-descriptor like functionality.
Jack Jansen <jack.jansen@cwi.nl>
parents:
1822
diff
changeset
|
59 #endif |
|
1620
8454579ab52f
As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents:
1522
diff
changeset
|
60 |
| 3400 | 61 /* Optional routines, for some compiler/runtime combinations */ |
| 62 #if defined(USE_GUSI) || !defined(__MWERKS__) | |
| 63 #define WEHAVE_FDOPEN | |
| 64 #endif | |
| 65 #if defined(MPW) || defined(USE_GUSI) | |
| 66 #define WEHAVE_DUP | |
| 67 #endif | |
|
7434
3de0cb82e61a
Add fstat() if using GUSI
Jack Jansen <jack.jansen@cwi.nl>
parents:
6442
diff
changeset
|
68 #if defined(USE_GUSI) |
|
3de0cb82e61a
Add fstat() if using GUSI
Jack Jansen <jack.jansen@cwi.nl>
parents:
6442
diff
changeset
|
69 #define WEHAVE_FSTAT |
|
3de0cb82e61a
Add fstat() if using GUSI
Jack Jansen <jack.jansen@cwi.nl>
parents:
6442
diff
changeset
|
70 #endif |
|
2222
bbb56dc3b526
Make malloc stats routine available under MetroWerks
Jack Jansen <jack.jansen@cwi.nl>
parents:
2179
diff
changeset
|
71 |
|
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
|
72 #include "macdefs.h" |
| 3394 | 73 #ifdef USE_GUSI |
| 74 #include <dirent.h> | |
| 75 #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
|
76 #include "dirent.h" |
| 3394 | 77 #endif |
|
1620
8454579ab52f
As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents:
1522
diff
changeset
|
78 |
|
8454579ab52f
As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents:
1522
diff
changeset
|
79 #ifndef MAXPATHLEN |
|
8454579ab52f
As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents:
1522
diff
changeset
|
80 #define MAXPATHLEN 1024 |
|
8454579ab52f
As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents:
1522
diff
changeset
|
81 #endif |
|
8454579ab52f
As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents:
1522
diff
changeset
|
82 |
|
8454579ab52f
As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents:
1522
diff
changeset
|
83 /* 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
|
84 |
| 3400 | 85 #ifndef USE_GUSI |
| 86 | |
|
13542
ddd6138c9e6f
ANSIfication step 1: get rid of Py_PROTO and Py_FPROTO.
Jack Jansen <jack.jansen@cwi.nl>
parents:
12856
diff
changeset
|
87 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
|
88 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
|
89 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
|
90 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
|
91 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
|
92 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
|
93 int sync(void); |
| 3400 | 94 |
|
13542
ddd6138c9e6f
ANSIfication step 1: get rid of Py_PROTO and Py_FPROTO.
Jack Jansen <jack.jansen@cwi.nl>
parents:
12856
diff
changeset
|
95 int unlink(const char *); |
|
1620
8454579ab52f
As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents:
1522
diff
changeset
|
96 |
| 3400 | 97 #endif /* USE_GUSI */ |
| 98 | |
|
13542
ddd6138c9e6f
ANSIfication step 1: get rid of Py_PROTO and Py_FPROTO.
Jack Jansen <jack.jansen@cwi.nl>
parents:
12856
diff
changeset
|
99 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
|
100 char *getbootvol(void); |
|
1620
8454579ab52f
As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents:
1522
diff
changeset
|
101 |
|
8454579ab52f
As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents:
1522
diff
changeset
|
102 |
|
8454579ab52f
As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents:
1522
diff
changeset
|
103 /* 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
|
104 |
| 5071 | 105 static PyObject * |
|
1620
8454579ab52f
As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents:
1522
diff
changeset
|
106 mac_error() |
|
8454579ab52f
As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents:
1522
diff
changeset
|
107 { |
|
21113
ed3dce17fc79
Merged changes made on r22b2-branch between r22b2 and r22b2-mac (the
Jack Jansen <jack.jansen@cwi.nl>
parents:
20896
diff
changeset
|
108 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
|
109 } |
|
8454579ab52f
As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents:
1522
diff
changeset
|
110 |
|
8454579ab52f
As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents:
1522
diff
changeset
|
111 /* MAC generic methods */ |
| 1495 | 112 |
| 5071 | 113 static PyObject * |
|
1620
8454579ab52f
As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents:
1522
diff
changeset
|
114 mac_1str(args, func) |
| 5071 | 115 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
|
116 int (*func)(const char *); |
|
1620
8454579ab52f
As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents:
1522
diff
changeset
|
117 { |
|
8454579ab52f
As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents:
1522
diff
changeset
|
118 char *path1; |
|
8454579ab52f
As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents:
1522
diff
changeset
|
119 int res; |
|
18960
9aa5d66cd13d
(Finally) converted to new-style args.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17813
diff
changeset
|
120 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
|
121 return NULL; |
| 5071 | 122 Py_BEGIN_ALLOW_THREADS |
|
1620
8454579ab52f
As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents:
1522
diff
changeset
|
123 res = (*func)(path1); |
| 5071 | 124 Py_END_ALLOW_THREADS |
|
1620
8454579ab52f
As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents:
1522
diff
changeset
|
125 if (res < 0) |
|
8454579ab52f
As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents:
1522
diff
changeset
|
126 return mac_error(); |
| 5071 | 127 Py_INCREF(Py_None); |
| 128 return Py_None; | |
|
1620
8454579ab52f
As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents:
1522
diff
changeset
|
129 } |
| 1495 | 130 |
| 5071 | 131 static PyObject * |
|
1620
8454579ab52f
As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents:
1522
diff
changeset
|
132 mac_2str(args, func) |
| 5071 | 133 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
|
134 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
|
135 { |
|
8454579ab52f
As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents:
1522
diff
changeset
|
136 char *path1, *path2; |
|
8454579ab52f
As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents:
1522
diff
changeset
|
137 int res; |
|
18960
9aa5d66cd13d
(Finally) converted to new-style args.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17813
diff
changeset
|
138 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
|
139 return NULL; |
| 5071 | 140 Py_BEGIN_ALLOW_THREADS |
|
1620
8454579ab52f
As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents:
1522
diff
changeset
|
141 res = (*func)(path1, path2); |
| 5071 | 142 Py_END_ALLOW_THREADS |
|
1620
8454579ab52f
As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents:
1522
diff
changeset
|
143 if (res < 0) |
|
8454579ab52f
As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents:
1522
diff
changeset
|
144 return mac_error(); |
| 5071 | 145 Py_INCREF(Py_None); |
| 146 return Py_None; | |
|
1620
8454579ab52f
As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents:
1522
diff
changeset
|
147 } |
| 1495 | 148 |
| 5071 | 149 static PyObject * |
|
1620
8454579ab52f
As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents:
1522
diff
changeset
|
150 mac_strint(args, func) |
| 5071 | 151 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
|
152 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
|
153 { |
|
8454579ab52f
As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents:
1522
diff
changeset
|
154 char *path; |
|
8454579ab52f
As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents:
1522
diff
changeset
|
155 int i; |
|
8454579ab52f
As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents:
1522
diff
changeset
|
156 int res; |
|
18960
9aa5d66cd13d
(Finally) converted to new-style args.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17813
diff
changeset
|
157 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
|
158 return NULL; |
| 5071 | 159 Py_BEGIN_ALLOW_THREADS |
|
1620
8454579ab52f
As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents:
1522
diff
changeset
|
160 res = (*func)(path, i); |
| 5071 | 161 Py_END_ALLOW_THREADS |
|
1620
8454579ab52f
As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents:
1522
diff
changeset
|
162 if (res < 0) |
|
8454579ab52f
As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents:
1522
diff
changeset
|
163 return mac_error(); |
| 5071 | 164 Py_INCREF(Py_None); |
| 165 return Py_None; | |
|
1620
8454579ab52f
As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents:
1522
diff
changeset
|
166 } |
|
8454579ab52f
As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents:
1522
diff
changeset
|
167 |
| 5071 | 168 static PyObject * |
| 1495 | 169 mac_chdir(self, args) |
| 5071 | 170 PyObject *self; |
| 171 PyObject *args; | |
| 1495 | 172 { |
|
1620
8454579ab52f
As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents:
1522
diff
changeset
|
173 return mac_1str(args, chdir); |
|
8454579ab52f
As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents:
1522
diff
changeset
|
174 } |
|
8454579ab52f
As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents:
1522
diff
changeset
|
175 |
| 5071 | 176 static PyObject * |
|
1620
8454579ab52f
As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents:
1522
diff
changeset
|
177 mac_close(self, args) |
| 5071 | 178 PyObject *self; |
| 179 PyObject *args; | |
|
1620
8454579ab52f
As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents:
1522
diff
changeset
|
180 { |
|
8454579ab52f
As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents:
1522
diff
changeset
|
181 int fd, res; |
|
18960
9aa5d66cd13d
(Finally) converted to new-style args.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17813
diff
changeset
|
182 if (!PyArg_ParseTuple(args, "i", &fd)) |
| 1495 | 183 return NULL; |
| 5071 | 184 Py_BEGIN_ALLOW_THREADS |
|
1620
8454579ab52f
As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents:
1522
diff
changeset
|
185 res = close(fd); |
| 5071 | 186 Py_END_ALLOW_THREADS |
|
1620
8454579ab52f
As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents:
1522
diff
changeset
|
187 if (res < 0) |
|
8454579ab52f
As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents:
1522
diff
changeset
|
188 return mac_error(); |
| 5071 | 189 Py_INCREF(Py_None); |
| 190 return Py_None; | |
| 1495 | 191 } |
| 192 | |
| 3400 | 193 #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
|
194 |
| 5071 | 195 static PyObject * |
|
1620
8454579ab52f
As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents:
1522
diff
changeset
|
196 mac_dup(self, args) |
| 5071 | 197 PyObject *self; |
| 198 PyObject *args; | |
|
1620
8454579ab52f
As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents:
1522
diff
changeset
|
199 { |
|
8454579ab52f
As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents:
1522
diff
changeset
|
200 int fd; |
|
18960
9aa5d66cd13d
(Finally) converted to new-style args.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17813
diff
changeset
|
201 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
|
202 return NULL; |
| 5071 | 203 Py_BEGIN_ALLOW_THREADS |
|
1620
8454579ab52f
As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents:
1522
diff
changeset
|
204 fd = dup(fd); |
| 5071 | 205 Py_END_ALLOW_THREADS |
|
1620
8454579ab52f
As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents:
1522
diff
changeset
|
206 if (fd < 0) |
|
8454579ab52f
As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents:
1522
diff
changeset
|
207 return mac_error(); |
| 5071 | 208 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
|
209 } |
|
8454579ab52f
As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents:
1522
diff
changeset
|
210 |
| 3400 | 211 #endif |
|
1821
40594f80ab3c
Intermediate version of changes after porting to MPW 3.2
Guido van Rossum <guido@python.org>
parents:
1808
diff
changeset
|
212 |
| 3400 | 213 #ifdef WEHAVE_FDOPEN |
| 5071 | 214 static PyObject * |
|
1620
8454579ab52f
As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents:
1522
diff
changeset
|
215 mac_fdopen(self, args) |
| 5071 | 216 PyObject *self; |
| 217 PyObject *args; | |
|
1620
8454579ab52f
As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents:
1522
diff
changeset
|
218 { |
|
13542
ddd6138c9e6f
ANSIfication step 1: get rid of Py_PROTO and Py_FPROTO.
Jack Jansen <jack.jansen@cwi.nl>
parents:
12856
diff
changeset
|
219 extern int fclose(FILE *); |
|
1620
8454579ab52f
As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents:
1522
diff
changeset
|
220 int fd; |
|
27158
eb6b36b26e8d
Merging the various tweaks for MacPython-OS9 2.3a1 back into the trunk.
Jack Jansen <jack.jansen@cwi.nl>
parents:
26610
diff
changeset
|
221 char *mode = "r"; |
|
eb6b36b26e8d
Merging the various tweaks for MacPython-OS9 2.3a1 back into the trunk.
Jack Jansen <jack.jansen@cwi.nl>
parents:
26610
diff
changeset
|
222 int bufsize = -1; |
|
1620
8454579ab52f
As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents:
1522
diff
changeset
|
223 FILE *fp; |
|
27158
eb6b36b26e8d
Merging the various tweaks for MacPython-OS9 2.3a1 back into the trunk.
Jack Jansen <jack.jansen@cwi.nl>
parents:
26610
diff
changeset
|
224 PyObject *f; |
|
eb6b36b26e8d
Merging the various tweaks for MacPython-OS9 2.3a1 back into the trunk.
Jack Jansen <jack.jansen@cwi.nl>
parents:
26610
diff
changeset
|
225 if (!PyArg_ParseTuple(args, "i|si", &fd, &mode, &bufsize)) |
|
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 fp = fdopen(fd, mode); |
| 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 (fp == NULL) |
|
8454579ab52f
As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents:
1522
diff
changeset
|
231 return mac_error(); |
|
27158
eb6b36b26e8d
Merging the various tweaks for MacPython-OS9 2.3a1 back into the trunk.
Jack Jansen <jack.jansen@cwi.nl>
parents:
26610
diff
changeset
|
232 f = PyFile_FromFile(fp, "<fdopen>", mode, fclose); |
|
eb6b36b26e8d
Merging the various tweaks for MacPython-OS9 2.3a1 back into the trunk.
Jack Jansen <jack.jansen@cwi.nl>
parents:
26610
diff
changeset
|
233 if (f != NULL) |
|
eb6b36b26e8d
Merging the various tweaks for MacPython-OS9 2.3a1 back into the trunk.
Jack Jansen <jack.jansen@cwi.nl>
parents:
26610
diff
changeset
|
234 PyFile_SetBufSize(f, bufsize); |
|
eb6b36b26e8d
Merging the various tweaks for MacPython-OS9 2.3a1 back into the trunk.
Jack Jansen <jack.jansen@cwi.nl>
parents:
26610
diff
changeset
|
235 return f; |
|
1620
8454579ab52f
As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents:
1522
diff
changeset
|
236 } |
|
2032
609bfb8ae7f5
Ported to MetroWerks, which misses file-descriptor like functionality.
Jack Jansen <jack.jansen@cwi.nl>
parents:
1822
diff
changeset
|
237 #endif |
|
1620
8454579ab52f
As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents:
1522
diff
changeset
|
238 |
| 5071 | 239 static PyObject * |
| 1495 | 240 mac_getcwd(self, args) |
| 5071 | 241 PyObject *self; |
| 242 PyObject *args; | |
| 1495 | 243 { |
|
1620
8454579ab52f
As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents:
1522
diff
changeset
|
244 char path[MAXPATHLEN]; |
|
8454579ab52f
As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents:
1522
diff
changeset
|
245 char *res; |
|
18960
9aa5d66cd13d
(Finally) converted to new-style args.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17813
diff
changeset
|
246 if (!PyArg_ParseTuple(args, "")) |
| 1495 | 247 return NULL; |
| 5071 | 248 Py_BEGIN_ALLOW_THREADS |
| 3400 | 249 #ifdef USE_GUSI |
| 250 res = getcwd(path, sizeof path); | |
| 251 #else | |
|
1620
8454579ab52f
As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents:
1522
diff
changeset
|
252 res = getwd(path); |
| 3400 | 253 #endif |
| 5071 | 254 Py_END_ALLOW_THREADS |
|
1620
8454579ab52f
As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents:
1522
diff
changeset
|
255 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
|
256 return mac_error(); |
| 1495 | 257 } |
| 5071 | 258 return PyString_FromString(res); |
| 1495 | 259 } |
| 260 | |
| 5071 | 261 static PyObject * |
| 1495 | 262 mac_listdir(self, args) |
| 5071 | 263 PyObject *self; |
| 264 PyObject *args; | |
| 1495 | 265 { |
|
1620
8454579ab52f
As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents:
1522
diff
changeset
|
266 char *name; |
| 5071 | 267 PyObject *d, *v; |
| 1495 | 268 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
|
269 struct dirent *ep; |
|
18960
9aa5d66cd13d
(Finally) converted to new-style args.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17813
diff
changeset
|
270 if (!PyArg_ParseTuple(args, "s", &name)) |
| 1495 | 271 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
|
272 #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
|
273 /* 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
|
274 ** 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
|
275 */ |
|
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
|
276 { |
|
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
|
277 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
|
278 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
|
279 |
|
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
|
280 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
|
281 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
|
282 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
|
283 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
|
284 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
|
285 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
|
286 } |
|
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
|
287 } |
|
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
|
288 #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
|
289 |
| 5071 | 290 Py_BEGIN_ALLOW_THREADS |
|
1620
8454579ab52f
As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents:
1522
diff
changeset
|
291 if ((dirp = opendir(name)) == NULL) { |
| 5071 | 292 Py_BLOCK_THREADS |
|
1620
8454579ab52f
As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents:
1522
diff
changeset
|
293 return mac_error(); |
|
8454579ab52f
As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents:
1522
diff
changeset
|
294 } |
| 5071 | 295 if ((d = PyList_New(0)) == NULL) { |
| 1495 | 296 closedir(dirp); |
| 5071 | 297 Py_BLOCK_THREADS |
| 1495 | 298 return NULL; |
| 299 } | |
| 300 while ((ep = readdir(dirp)) != NULL) { | |
| 5071 | 301 v = PyString_FromString(ep->d_name); |
| 1495 | 302 if (v == NULL) { |
| 5071 | 303 Py_DECREF(d); |
| 1495 | 304 d = NULL; |
| 305 break; | |
| 306 } | |
| 5071 | 307 if (PyList_Append(d, v) != 0) { |
| 308 Py_DECREF(v); | |
| 309 Py_DECREF(d); | |
| 1495 | 310 d = NULL; |
| 311 break; | |
| 312 } | |
| 5071 | 313 Py_DECREF(v); |
| 1495 | 314 } |
| 315 closedir(dirp); | |
| 5071 | 316 Py_END_ALLOW_THREADS |
|
1620
8454579ab52f
As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents:
1522
diff
changeset
|
317 |
| 1495 | 318 return d; |
| 319 } | |
| 320 | |
| 5071 | 321 static PyObject * |
|
1620
8454579ab52f
As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents:
1522
diff
changeset
|
322 mac_lseek(self, args) |
| 5071 | 323 PyObject *self; |
| 324 PyObject *args; | |
|
1620
8454579ab52f
As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents:
1522
diff
changeset
|
325 { |
|
8454579ab52f
As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents:
1522
diff
changeset
|
326 int fd; |
|
8454579ab52f
As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents:
1522
diff
changeset
|
327 int where; |
|
8454579ab52f
As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents:
1522
diff
changeset
|
328 int how; |
|
8454579ab52f
As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents:
1522
diff
changeset
|
329 long res; |
|
18960
9aa5d66cd13d
(Finally) converted to new-style args.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17813
diff
changeset
|
330 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
|
331 return NULL; |
| 5071 | 332 Py_BEGIN_ALLOW_THREADS |
|
1620
8454579ab52f
As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents:
1522
diff
changeset
|
333 res = lseek(fd, (long)where, how); |
| 5071 | 334 Py_END_ALLOW_THREADS |
|
1620
8454579ab52f
As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents:
1522
diff
changeset
|
335 if (res < 0) |
|
8454579ab52f
As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents:
1522
diff
changeset
|
336 return mac_error(); |
| 5071 | 337 return PyInt_FromLong(res); |
|
1620
8454579ab52f
As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents:
1522
diff
changeset
|
338 } |
| 3394 | 339 |
| 5071 | 340 static PyObject * |
| 1495 | 341 mac_mkdir(self, args) |
| 5071 | 342 PyObject *self; |
| 343 PyObject *args; | |
| 1495 | 344 { |
|
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
|
345 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
|
346 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
|
347 int mode = 0777; /* Unused */ |
| 5071 | 348 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
|
349 return NULL; |
| 5071 | 350 Py_BEGIN_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
|
351 res = mkdir(path, mode); |
| 5071 | 352 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
|
353 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
|
354 return mac_error(); |
| 5071 | 355 Py_INCREF(Py_None); |
| 356 return Py_None; | |
|
1620
8454579ab52f
As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents:
1522
diff
changeset
|
357 } |
|
8454579ab52f
As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents:
1522
diff
changeset
|
358 |
| 5071 | 359 static PyObject * |
|
1620
8454579ab52f
As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents:
1522
diff
changeset
|
360 mac_open(self, args) |
| 5071 | 361 PyObject *self; |
| 362 PyObject *args; | |
|
1620
8454579ab52f
As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents:
1522
diff
changeset
|
363 { |
| 1495 | 364 char *path; |
| 365 int mode; | |
|
18960
9aa5d66cd13d
(Finally) converted to new-style args.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17813
diff
changeset
|
366 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
|
367 int fd; |
|
18960
9aa5d66cd13d
(Finally) converted to new-style args.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17813
diff
changeset
|
368 if (!PyArg_ParseTuple(args, "si|i", &path, &mode, &perm)) |
| 1495 | 369 return NULL; |
| 5071 | 370 Py_BEGIN_ALLOW_THREADS |
|
1620
8454579ab52f
As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents:
1522
diff
changeset
|
371 fd = open(path, mode); |
| 5071 | 372 Py_END_ALLOW_THREADS |
|
1620
8454579ab52f
As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents:
1522
diff
changeset
|
373 if (fd < 0) |
|
8454579ab52f
As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents:
1522
diff
changeset
|
374 return mac_error(); |
| 5071 | 375 return PyInt_FromLong((long)fd); |
| 1495 | 376 } |
| 377 | |
| 5071 | 378 static PyObject * |
|
1620
8454579ab52f
As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents:
1522
diff
changeset
|
379 mac_read(self, args) |
| 5071 | 380 PyObject *self; |
| 381 PyObject *args; | |
|
1620
8454579ab52f
As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents:
1522
diff
changeset
|
382 { |
|
8454579ab52f
As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents:
1522
diff
changeset
|
383 int fd, size; |
| 5071 | 384 PyObject *buffer; |
|
18960
9aa5d66cd13d
(Finally) converted to new-style args.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17813
diff
changeset
|
385 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
|
386 return NULL; |
| 5071 | 387 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
|
388 if (buffer == NULL) |
|
8454579ab52f
As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents:
1522
diff
changeset
|
389 return NULL; |
| 5071 | 390 Py_BEGIN_ALLOW_THREADS |
| 391 size = read(fd, PyString_AsString(buffer), size); | |
| 392 Py_END_ALLOW_THREADS | |
|
1620
8454579ab52f
As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents:
1522
diff
changeset
|
393 if (size < 0) { |
| 5071 | 394 Py_DECREF(buffer); |
|
1620
8454579ab52f
As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents:
1522
diff
changeset
|
395 return mac_error(); |
|
8454579ab52f
As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents:
1522
diff
changeset
|
396 } |
| 5071 | 397 _PyString_Resize(&buffer, size); |
|
1620
8454579ab52f
As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents:
1522
diff
changeset
|
398 return buffer; |
|
8454579ab52f
As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents:
1522
diff
changeset
|
399 } |
| 1495 | 400 |
| 5071 | 401 static PyObject * |
| 1495 | 402 mac_rename(self, args) |
| 5071 | 403 PyObject *self; |
| 404 PyObject *args; | |
| 1495 | 405 { |
|
1620
8454579ab52f
As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents:
1522
diff
changeset
|
406 return mac_2str(args, rename); |
| 1495 | 407 } |
| 408 | |
| 5071 | 409 static PyObject * |
| 1495 | 410 mac_rmdir(self, args) |
| 5071 | 411 PyObject *self; |
| 412 PyObject *args; | |
| 1495 | 413 { |
|
1620
8454579ab52f
As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents:
1522
diff
changeset
|
414 return mac_1str(args, rmdir); |
| 1495 | 415 } |
| 416 | |
|
20539
2d599a36b67a
SF patch #462296: Add attributes to os.stat results; by Nick Mathewson.
Guido van Rossum <guido@python.org>
parents:
19181
diff
changeset
|
417 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
|
418 "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
|
419 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
|
420 (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
|
421 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
|
422 \n\ |
|
2d599a36b67a
SF patch #462296: Add attributes to os.stat results; by Nick Mathewson.
Guido van Rossum <guido@python.org>
parents:
19181
diff
changeset
|
423 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
|
424 |
|
2d599a36b67a
SF patch #462296: Add attributes to os.stat results; by Nick Mathewson.
Guido van Rossum <guido@python.org>
parents:
19181
diff
changeset
|
425 #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
|
426 { "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
|
427 { "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
|
428 { "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
|
429 { "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
|
430 { "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
|
431 { "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
|
432 { "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
|
433 { "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
|
434 { "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
|
435 { "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
|
436 |
|
2d599a36b67a
SF patch #462296: Add attributes to os.stat results; by Nick Mathewson.
Guido van Rossum <guido@python.org>
parents:
19181
diff
changeset
|
437 |
|
2d599a36b67a
SF patch #462296: Add attributes to os.stat results; by Nick Mathewson.
Guido van Rossum <guido@python.org>
parents:
19181
diff
changeset
|
438 |
|
2d599a36b67a
SF patch #462296: Add attributes to os.stat results; by Nick Mathewson.
Guido van Rossum <guido@python.org>
parents:
19181
diff
changeset
|
439 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
|
440 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
|
441 {0} |
|
2d599a36b67a
SF patch #462296: Add attributes to os.stat results; by Nick Mathewson.
Guido van Rossum <guido@python.org>
parents:
19181
diff
changeset
|
442 }; |
|
2d599a36b67a
SF patch #462296: Add attributes to os.stat results; by Nick Mathewson.
Guido van Rossum <guido@python.org>
parents:
19181
diff
changeset
|
443 |
|
2d599a36b67a
SF patch #462296: Add attributes to os.stat results; by Nick Mathewson.
Guido van Rossum <guido@python.org>
parents:
19181
diff
changeset
|
444 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
|
445 "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
|
446 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
|
447 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
|
448 10 |
|
2d599a36b67a
SF patch #462296: Add attributes to os.stat results; by Nick Mathewson.
Guido van Rossum <guido@python.org>
parents:
19181
diff
changeset
|
449 }; |
|
2d599a36b67a
SF patch #462296: Add attributes to os.stat results; by Nick Mathewson.
Guido van Rossum <guido@python.org>
parents:
19181
diff
changeset
|
450 |
|
2d599a36b67a
SF patch #462296: Add attributes to os.stat results; by Nick Mathewson.
Guido van Rossum <guido@python.org>
parents:
19181
diff
changeset
|
451 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
|
452 |
|
2d599a36b67a
SF patch #462296: Add attributes to os.stat results; by Nick Mathewson.
Guido van Rossum <guido@python.org>
parents:
19181
diff
changeset
|
453 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
|
454 _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
|
455 { |
|
2d599a36b67a
SF patch #462296: Add attributes to os.stat results; by Nick Mathewson.
Guido van Rossum <guido@python.org>
parents:
19181
diff
changeset
|
456 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
|
457 |
|
26610
74d1ad61f843
Getting rid of pre-Carbon (MacOS8) support. All code depending on
Jack Jansen <jack.jansen@cwi.nl>
parents:
22957
diff
changeset
|
458 v = PyStructSequence_New(&StatResultType); |
|
20539
2d599a36b67a
SF patch #462296: Add attributes to os.stat results; by Nick Mathewson.
Guido van Rossum <guido@python.org>
parents:
19181
diff
changeset
|
459 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
|
460 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
|
461 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
|
462 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
|
463 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
|
464 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
|
465 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
|
466 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
|
467 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
|
468 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
|
469 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
|
470 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
|
471 PyFloat_FromDouble((double)st.st_ctime)); |
|
26610
74d1ad61f843
Getting rid of pre-Carbon (MacOS8) support. All code depending on
Jack Jansen <jack.jansen@cwi.nl>
parents:
22957
diff
changeset
|
472 if (PyErr_Occurred()) { |
|
74d1ad61f843
Getting rid of pre-Carbon (MacOS8) support. All code depending on
Jack Jansen <jack.jansen@cwi.nl>
parents:
22957
diff
changeset
|
473 Py_DECREF(v); |
|
74d1ad61f843
Getting rid of pre-Carbon (MacOS8) support. All code depending on
Jack Jansen <jack.jansen@cwi.nl>
parents:
22957
diff
changeset
|
474 return NULL; |
|
20539
2d599a36b67a
SF patch #462296: Add attributes to os.stat results; by Nick Mathewson.
Guido van Rossum <guido@python.org>
parents:
19181
diff
changeset
|
475 } |
|
2d599a36b67a
SF patch #462296: Add attributes to os.stat results; by Nick Mathewson.
Guido van Rossum <guido@python.org>
parents:
19181
diff
changeset
|
476 |
|
26610
74d1ad61f843
Getting rid of pre-Carbon (MacOS8) support. All code depending on
Jack Jansen <jack.jansen@cwi.nl>
parents:
22957
diff
changeset
|
477 return v; |
|
20539
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 |
| 5071 | 481 static PyObject * |
| 1495 | 482 mac_stat(self, args) |
| 5071 | 483 PyObject *self; |
| 484 PyObject *args; | |
| 1495 | 485 { |
|
4414
02a68d623805
Fixed xstat to again include resroucefork size, creator, type. Obtain
Jack Jansen <jack.jansen@cwi.nl>
parents:
3942
diff
changeset
|
486 struct stat st; |
| 1495 | 487 char *path; |
|
1620
8454579ab52f
As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents:
1522
diff
changeset
|
488 int res; |
|
18960
9aa5d66cd13d
(Finally) converted to new-style args.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17813
diff
changeset
|
489 if (!PyArg_ParseTuple(args, "s", &path)) |
| 1495 | 490 return NULL; |
| 5071 | 491 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
|
492 res = stat(path, &st); |
| 5071 | 493 Py_END_ALLOW_THREADS |
|
1620
8454579ab52f
As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents:
1522
diff
changeset
|
494 if (res != 0) |
|
8454579ab52f
As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents:
1522
diff
changeset
|
495 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
|
496 |
|
2d599a36b67a
SF patch #462296: Add attributes to os.stat results; by Nick Mathewson.
Guido van Rossum <guido@python.org>
parents:
19181
diff
changeset
|
497 return _pystat_from_struct_stat(st, NULL); |
|
7434
3de0cb82e61a
Add fstat() if using GUSI
Jack Jansen <jack.jansen@cwi.nl>
parents:
6442
diff
changeset
|
498 } |
|
3de0cb82e61a
Add fstat() if using GUSI
Jack Jansen <jack.jansen@cwi.nl>
parents:
6442
diff
changeset
|
499 |
|
3de0cb82e61a
Add fstat() if using GUSI
Jack Jansen <jack.jansen@cwi.nl>
parents:
6442
diff
changeset
|
500 #ifdef WEHAVE_FSTAT |
|
3de0cb82e61a
Add fstat() if using GUSI
Jack Jansen <jack.jansen@cwi.nl>
parents:
6442
diff
changeset
|
501 static PyObject * |
|
3de0cb82e61a
Add fstat() if using GUSI
Jack Jansen <jack.jansen@cwi.nl>
parents:
6442
diff
changeset
|
502 mac_fstat(self, args) |
|
3de0cb82e61a
Add fstat() if using GUSI
Jack Jansen <jack.jansen@cwi.nl>
parents:
6442
diff
changeset
|
503 PyObject *self; |
|
3de0cb82e61a
Add fstat() if using GUSI
Jack Jansen <jack.jansen@cwi.nl>
parents:
6442
diff
changeset
|
504 PyObject *args; |
|
3de0cb82e61a
Add fstat() if using GUSI
Jack Jansen <jack.jansen@cwi.nl>
parents:
6442
diff
changeset
|
505 { |
|
3de0cb82e61a
Add fstat() if using GUSI
Jack Jansen <jack.jansen@cwi.nl>
parents:
6442
diff
changeset
|
506 struct stat st; |
|
3de0cb82e61a
Add fstat() if using GUSI
Jack Jansen <jack.jansen@cwi.nl>
parents:
6442
diff
changeset
|
507 long fd; |
|
3de0cb82e61a
Add fstat() if using GUSI
Jack Jansen <jack.jansen@cwi.nl>
parents:
6442
diff
changeset
|
508 int res; |
|
18960
9aa5d66cd13d
(Finally) converted to new-style args.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17813
diff
changeset
|
509 if (!PyArg_ParseTuple(args, "l", &fd)) |
|
7434
3de0cb82e61a
Add fstat() if using GUSI
Jack Jansen <jack.jansen@cwi.nl>
parents:
6442
diff
changeset
|
510 return NULL; |
|
3de0cb82e61a
Add fstat() if using GUSI
Jack Jansen <jack.jansen@cwi.nl>
parents:
6442
diff
changeset
|
511 Py_BEGIN_ALLOW_THREADS |
|
3de0cb82e61a
Add fstat() if using GUSI
Jack Jansen <jack.jansen@cwi.nl>
parents:
6442
diff
changeset
|
512 res = fstat((int)fd, &st); |
|
3de0cb82e61a
Add fstat() if using GUSI
Jack Jansen <jack.jansen@cwi.nl>
parents:
6442
diff
changeset
|
513 Py_END_ALLOW_THREADS |
|
3de0cb82e61a
Add fstat() if using GUSI
Jack Jansen <jack.jansen@cwi.nl>
parents:
6442
diff
changeset
|
514 if (res != 0) |
|
3de0cb82e61a
Add fstat() if using GUSI
Jack Jansen <jack.jansen@cwi.nl>
parents:
6442
diff
changeset
|
515 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
|
516 |
|
2d599a36b67a
SF patch #462296: Add attributes to os.stat results; by Nick Mathewson.
Guido van Rossum <guido@python.org>
parents:
19181
diff
changeset
|
517 return _pystat_from_struct_stat(st, NULL); |
| 1495 | 518 } |
|
7434
3de0cb82e61a
Add fstat() if using GUSI
Jack Jansen <jack.jansen@cwi.nl>
parents:
6442
diff
changeset
|
519 #endif /* WEHAVE_FSTAT */ |
| 1495 | 520 |
| 5071 | 521 static PyObject * |
| 1495 | 522 mac_sync(self, args) |
| 5071 | 523 PyObject *self; |
| 524 PyObject *args; | |
| 1495 | 525 { |
|
1620
8454579ab52f
As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents:
1522
diff
changeset
|
526 int res; |
|
18960
9aa5d66cd13d
(Finally) converted to new-style args.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17813
diff
changeset
|
527 if (!PyArg_ParseTuple(args, "")) |
| 1495 | 528 return NULL; |
| 5071 | 529 Py_BEGIN_ALLOW_THREADS |
|
22430
7002f24f818f
Solve sync() signature conflict differently: manually return 0 if
Jack Jansen <jack.jansen@cwi.nl>
parents:
21313
diff
changeset
|
530 #ifdef USE_GUSI2 |
|
7002f24f818f
Solve sync() signature conflict differently: manually return 0 if
Jack Jansen <jack.jansen@cwi.nl>
parents:
21313
diff
changeset
|
531 sync(); |
|
7002f24f818f
Solve sync() signature conflict differently: manually return 0 if
Jack Jansen <jack.jansen@cwi.nl>
parents:
21313
diff
changeset
|
532 res = 0; |
|
7002f24f818f
Solve sync() signature conflict differently: manually return 0 if
Jack Jansen <jack.jansen@cwi.nl>
parents:
21313
diff
changeset
|
533 #else |
|
1620
8454579ab52f
As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents:
1522
diff
changeset
|
534 res = sync(); |
|
22430
7002f24f818f
Solve sync() signature conflict differently: manually return 0 if
Jack Jansen <jack.jansen@cwi.nl>
parents:
21313
diff
changeset
|
535 #endif |
| 5071 | 536 Py_END_ALLOW_THREADS |
|
1620
8454579ab52f
As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents:
1522
diff
changeset
|
537 if (res != 0) |
|
8454579ab52f
As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents:
1522
diff
changeset
|
538 return mac_error(); |
| 5071 | 539 Py_INCREF(Py_None); |
| 540 return Py_None; | |
| 1495 | 541 } |
| 542 | |
| 5071 | 543 static PyObject * |
| 1495 | 544 mac_unlink(self, args) |
| 5071 | 545 PyObject *self; |
| 546 PyObject *args; | |
| 1495 | 547 { |
|
1822
76d0f2b3b9ee
Completed (hopefully) the unification of THINK 6.0 and MPW 3.2
Guido van Rossum <guido@python.org>
parents:
1821
diff
changeset
|
548 return mac_1str(args, (int (*)(const char *))unlink); |
| 1495 | 549 } |
| 550 | |
| 5071 | 551 static PyObject * |
|
1620
8454579ab52f
As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents:
1522
diff
changeset
|
552 mac_write(self, args) |
| 5071 | 553 PyObject *self; |
| 554 PyObject *args; | |
|
1620
8454579ab52f
As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents:
1522
diff
changeset
|
555 { |
|
8454579ab52f
As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents:
1522
diff
changeset
|
556 int fd, size; |
|
8454579ab52f
As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents:
1522
diff
changeset
|
557 char *buffer; |
|
18960
9aa5d66cd13d
(Finally) converted to new-style args.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17813
diff
changeset
|
558 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
|
559 return NULL; |
| 5071 | 560 Py_BEGIN_ALLOW_THREADS |
|
1620
8454579ab52f
As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents:
1522
diff
changeset
|
561 size = write(fd, buffer, size); |
| 5071 | 562 Py_END_ALLOW_THREADS |
|
1620
8454579ab52f
As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents:
1522
diff
changeset
|
563 if (size < 0) |
|
8454579ab52f
As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents:
1522
diff
changeset
|
564 return mac_error(); |
| 5071 | 565 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
|
566 } |
| 1495 | 567 |
|
4468
600f5b8a16cb
Malloc debugging now flagged with USE_MALLOC_DEBUG
Jack Jansen <jack.jansen@cwi.nl>
parents:
4414
diff
changeset
|
568 #ifdef USE_MALLOC_DEBUG |
|
14205
3ae185b8ff03
Added a prototype for mstats().
Jack Jansen <jack.jansen@cwi.nl>
parents:
13608
diff
changeset
|
569 void *mstats(char *); |
|
3ae185b8ff03
Added a prototype for mstats().
Jack Jansen <jack.jansen@cwi.nl>
parents:
13608
diff
changeset
|
570 |
| 5071 | 571 static PyObject * |
|
2179
8da03decef59
More Pstring() stuff and some cosmetics
Jack Jansen <jack.jansen@cwi.nl>
parents:
2091
diff
changeset
|
572 mac_mstats(self, args) |
| 5071 | 573 PyObject*self; |
| 574 PyObject *args; | |
|
2179
8da03decef59
More Pstring() stuff and some cosmetics
Jack Jansen <jack.jansen@cwi.nl>
parents:
2091
diff
changeset
|
575 { |
|
8da03decef59
More Pstring() stuff and some cosmetics
Jack Jansen <jack.jansen@cwi.nl>
parents:
2091
diff
changeset
|
576 mstats("python"); |
| 5071 | 577 Py_INCREF(Py_None); |
| 578 return Py_None; | |
|
2179
8da03decef59
More Pstring() stuff and some cosmetics
Jack Jansen <jack.jansen@cwi.nl>
parents:
2091
diff
changeset
|
579 } |
|
5141
a4c8b8871376
Comments around identifier after #endif
Jack Jansen <jack.jansen@cwi.nl>
parents:
5079
diff
changeset
|
580 #endif /* USE_MALLOC_DEBUG */ |
|
2179
8da03decef59
More Pstring() stuff and some cosmetics
Jack Jansen <jack.jansen@cwi.nl>
parents:
2091
diff
changeset
|
581 |
| 5071 | 582 static struct PyMethodDef mac_methods[] = { |
|
18960
9aa5d66cd13d
(Finally) converted to new-style args.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17813
diff
changeset
|
583 {"chdir", mac_chdir, 1}, |
|
9aa5d66cd13d
(Finally) converted to new-style args.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17813
diff
changeset
|
584 {"close", mac_close, 1}, |
| 3400 | 585 #ifdef WEHAVE_DUP |
|
18960
9aa5d66cd13d
(Finally) converted to new-style args.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17813
diff
changeset
|
586 {"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
|
587 #endif |
| 3400 | 588 #ifdef WEHAVE_FDOPEN |
|
18960
9aa5d66cd13d
(Finally) converted to new-style args.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17813
diff
changeset
|
589 {"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
|
590 #endif |
|
7434
3de0cb82e61a
Add fstat() if using GUSI
Jack Jansen <jack.jansen@cwi.nl>
parents:
6442
diff
changeset
|
591 #ifdef WEHAVE_FSTAT |
|
18960
9aa5d66cd13d
(Finally) converted to new-style args.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17813
diff
changeset
|
592 {"fstat", mac_fstat, 1}, |
|
7434
3de0cb82e61a
Add fstat() if using GUSI
Jack Jansen <jack.jansen@cwi.nl>
parents:
6442
diff
changeset
|
593 #endif |
|
18960
9aa5d66cd13d
(Finally) converted to new-style args.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17813
diff
changeset
|
594 {"getcwd", mac_getcwd, 1}, |
|
9aa5d66cd13d
(Finally) converted to new-style args.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17813
diff
changeset
|
595 {"listdir", mac_listdir, 1}, |
|
9aa5d66cd13d
(Finally) converted to new-style args.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17813
diff
changeset
|
596 {"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
|
597 {"mkdir", mac_mkdir, 1}, |
|
18960
9aa5d66cd13d
(Finally) converted to new-style args.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17813
diff
changeset
|
598 {"open", mac_open, 1}, |
|
9aa5d66cd13d
(Finally) converted to new-style args.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17813
diff
changeset
|
599 {"read", mac_read, 1}, |
|
9aa5d66cd13d
(Finally) converted to new-style args.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17813
diff
changeset
|
600 {"rename", mac_rename, 1}, |
|
9aa5d66cd13d
(Finally) converted to new-style args.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17813
diff
changeset
|
601 {"rmdir", mac_rmdir, 1}, |
|
9aa5d66cd13d
(Finally) converted to new-style args.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17813
diff
changeset
|
602 {"stat", mac_stat, 1}, |
|
9aa5d66cd13d
(Finally) converted to new-style args.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17813
diff
changeset
|
603 {"sync", mac_sync, 1}, |
|
9aa5d66cd13d
(Finally) converted to new-style args.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17813
diff
changeset
|
604 {"remove", mac_unlink, 1}, |
|
9aa5d66cd13d
(Finally) converted to new-style args.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17813
diff
changeset
|
605 {"unlink", mac_unlink, 1}, |
|
9aa5d66cd13d
(Finally) converted to new-style args.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17813
diff
changeset
|
606 {"write", mac_write, 1}, |
|
4468
600f5b8a16cb
Malloc debugging now flagged with USE_MALLOC_DEBUG
Jack Jansen <jack.jansen@cwi.nl>
parents:
4414
diff
changeset
|
607 #ifdef USE_MALLOC_DEBUG |
|
18960
9aa5d66cd13d
(Finally) converted to new-style args.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17813
diff
changeset
|
608 {"mstats", mac_mstats, 1}, |
|
2179
8da03decef59
More Pstring() stuff and some cosmetics
Jack Jansen <jack.jansen@cwi.nl>
parents:
2091
diff
changeset
|
609 #endif |
|
1620
8454579ab52f
As extended by Richard M Walker for MPW
Guido van Rossum <guido@python.org>
parents:
1522
diff
changeset
|
610 |
| 1495 | 611 {NULL, NULL} /* Sentinel */ |
| 612 }; | |
| 613 | |
|
18960
9aa5d66cd13d
(Finally) converted to new-style args.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17813
diff
changeset
|
614 static int |
|
9aa5d66cd13d
(Finally) converted to new-style args.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17813
diff
changeset
|
615 ins(PyObject *d, char *symbol, long value) |
|
9aa5d66cd13d
(Finally) converted to new-style args.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17813
diff
changeset
|
616 { |
|
9aa5d66cd13d
(Finally) converted to new-style args.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17813
diff
changeset
|
617 PyObject* v = PyInt_FromLong(value); |
|
9aa5d66cd13d
(Finally) converted to new-style args.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17813
diff
changeset
|
618 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
|
619 return -1; /* triggers fatal error */ |
|
9aa5d66cd13d
(Finally) converted to new-style args.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17813
diff
changeset
|
620 |
|
9aa5d66cd13d
(Finally) converted to new-style args.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17813
diff
changeset
|
621 Py_DECREF(v); |
|
9aa5d66cd13d
(Finally) converted to new-style args.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17813
diff
changeset
|
622 return 0; |
|
9aa5d66cd13d
(Finally) converted to new-style args.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17813
diff
changeset
|
623 } |
|
9aa5d66cd13d
(Finally) converted to new-style args.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17813
diff
changeset
|
624 |
|
9aa5d66cd13d
(Finally) converted to new-style args.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17813
diff
changeset
|
625 static int |
|
9aa5d66cd13d
(Finally) converted to new-style args.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17813
diff
changeset
|
626 all_ins(PyObject *d) |
|
9aa5d66cd13d
(Finally) converted to new-style args.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17813
diff
changeset
|
627 { |
|
9aa5d66cd13d
(Finally) converted to new-style args.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17813
diff
changeset
|
628 #ifdef F_OK |
|
9aa5d66cd13d
(Finally) converted to new-style args.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17813
diff
changeset
|
629 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
|
630 #endif |
|
9aa5d66cd13d
(Finally) converted to new-style args.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17813
diff
changeset
|
631 #ifdef R_OK |
|
9aa5d66cd13d
(Finally) converted to new-style args.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17813
diff
changeset
|
632 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
|
633 #endif |
|
9aa5d66cd13d
(Finally) converted to new-style args.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17813
diff
changeset
|
634 #ifdef W_OK |
|
9aa5d66cd13d
(Finally) converted to new-style args.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17813
diff
changeset
|
635 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
|
636 #endif |
|
9aa5d66cd13d
(Finally) converted to new-style args.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17813
diff
changeset
|
637 #ifdef X_OK |
|
9aa5d66cd13d
(Finally) converted to new-style args.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17813
diff
changeset
|
638 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
|
639 #endif |
|
9aa5d66cd13d
(Finally) converted to new-style args.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17813
diff
changeset
|
640 #ifdef NGROUPS_MAX |
|
9aa5d66cd13d
(Finally) converted to new-style args.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17813
diff
changeset
|
641 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
|
642 #endif |
|
9aa5d66cd13d
(Finally) converted to new-style args.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17813
diff
changeset
|
643 #ifdef TMP_MAX |
|
9aa5d66cd13d
(Finally) converted to new-style args.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17813
diff
changeset
|
644 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
|
645 #endif |
|
9aa5d66cd13d
(Finally) converted to new-style args.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17813
diff
changeset
|
646 #ifdef WNOHANG |
|
9aa5d66cd13d
(Finally) converted to new-style args.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17813
diff
changeset
|
647 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
|
648 #endif |
|
9aa5d66cd13d
(Finally) converted to new-style args.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17813
diff
changeset
|
649 #ifdef O_RDONLY |
|
9aa5d66cd13d
(Finally) converted to new-style args.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17813
diff
changeset
|
650 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
|
651 #endif |
|
9aa5d66cd13d
(Finally) converted to new-style args.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17813
diff
changeset
|
652 #ifdef O_WRONLY |
|
9aa5d66cd13d
(Finally) converted to new-style args.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17813
diff
changeset
|
653 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
|
654 #endif |
|
9aa5d66cd13d
(Finally) converted to new-style args.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17813
diff
changeset
|
655 #ifdef O_RDWR |
|
9aa5d66cd13d
(Finally) converted to new-style args.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17813
diff
changeset
|
656 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
|
657 #endif |
|
9aa5d66cd13d
(Finally) converted to new-style args.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17813
diff
changeset
|
658 #ifdef O_NDELAY |
|
9aa5d66cd13d
(Finally) converted to new-style args.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17813
diff
changeset
|
659 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
|
660 #endif |
|
9aa5d66cd13d
(Finally) converted to new-style args.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17813
diff
changeset
|
661 #ifdef O_NONBLOCK |
|
9aa5d66cd13d
(Finally) converted to new-style args.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17813
diff
changeset
|
662 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
|
663 #endif |
|
9aa5d66cd13d
(Finally) converted to new-style args.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17813
diff
changeset
|
664 #ifdef O_APPEND |
|
9aa5d66cd13d
(Finally) converted to new-style args.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17813
diff
changeset
|
665 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
|
666 #endif |
|
9aa5d66cd13d
(Finally) converted to new-style args.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17813
diff
changeset
|
667 #ifdef O_DSYNC |
|
9aa5d66cd13d
(Finally) converted to new-style args.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17813
diff
changeset
|
668 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
|
669 #endif |
|
9aa5d66cd13d
(Finally) converted to new-style args.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17813
diff
changeset
|
670 #ifdef O_RSYNC |
|
9aa5d66cd13d
(Finally) converted to new-style args.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17813
diff
changeset
|
671 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
|
672 #endif |
|
9aa5d66cd13d
(Finally) converted to new-style args.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17813
diff
changeset
|
673 #ifdef O_SYNC |
|
9aa5d66cd13d
(Finally) converted to new-style args.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17813
diff
changeset
|
674 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
|
675 #endif |
|
9aa5d66cd13d
(Finally) converted to new-style args.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17813
diff
changeset
|
676 #ifdef O_NOCTTY |
|
9aa5d66cd13d
(Finally) converted to new-style args.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17813
diff
changeset
|
677 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
|
678 #endif |
|
9aa5d66cd13d
(Finally) converted to new-style args.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17813
diff
changeset
|
679 #ifdef O_CREAT |
|
9aa5d66cd13d
(Finally) converted to new-style args.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17813
diff
changeset
|
680 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
|
681 #endif |
|
9aa5d66cd13d
(Finally) converted to new-style args.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17813
diff
changeset
|
682 #ifdef O_EXCL |
|
9aa5d66cd13d
(Finally) converted to new-style args.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17813
diff
changeset
|
683 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
|
684 #endif |
|
9aa5d66cd13d
(Finally) converted to new-style args.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17813
diff
changeset
|
685 #ifdef O_TRUNC |
|
9aa5d66cd13d
(Finally) converted to new-style args.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17813
diff
changeset
|
686 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
|
687 #endif |
|
9aa5d66cd13d
(Finally) converted to new-style args.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17813
diff
changeset
|
688 #ifdef O_BINARY |
|
9aa5d66cd13d
(Finally) converted to new-style args.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17813
diff
changeset
|
689 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
|
690 #endif |
|
9aa5d66cd13d
(Finally) converted to new-style args.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17813
diff
changeset
|
691 #ifdef O_TEXT |
|
9aa5d66cd13d
(Finally) converted to new-style args.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17813
diff
changeset
|
692 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
|
693 #endif |
|
9aa5d66cd13d
(Finally) converted to new-style args.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17813
diff
changeset
|
694 |
|
9aa5d66cd13d
(Finally) converted to new-style args.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17813
diff
changeset
|
695 #ifdef HAVE_SPAWNV |
|
9aa5d66cd13d
(Finally) converted to new-style args.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17813
diff
changeset
|
696 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
|
697 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
|
698 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
|
699 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
|
700 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
|
701 #endif |
|
9aa5d66cd13d
(Finally) converted to new-style args.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17813
diff
changeset
|
702 |
|
9aa5d66cd13d
(Finally) converted to new-style args.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17813
diff
changeset
|
703 #if defined(PYOS_OS2) |
|
9aa5d66cd13d
(Finally) converted to new-style args.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17813
diff
changeset
|
704 if (insertvalues(d)) return -1; |
|
9aa5d66cd13d
(Finally) converted to new-style args.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17813
diff
changeset
|
705 #endif |
|
9aa5d66cd13d
(Finally) converted to new-style args.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17813
diff
changeset
|
706 return 0; |
|
9aa5d66cd13d
(Finally) converted to new-style args.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17813
diff
changeset
|
707 } |
|
9aa5d66cd13d
(Finally) converted to new-style args.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17813
diff
changeset
|
708 |
| 1495 | 709 |
| 710 void | |
| 711 initmac() | |
| 712 { | |
| 5071 | 713 PyObject *m, *d; |
| 1495 | 714 |
| 5071 | 715 m = Py_InitModule("mac", mac_methods); |
| 716 d = PyModule_GetDict(m); | |
| 1495 | 717 |
|
18960
9aa5d66cd13d
(Finally) converted to new-style args.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17813
diff
changeset
|
718 if (all_ins(d)) |
|
9aa5d66cd13d
(Finally) converted to new-style args.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17813
diff
changeset
|
719 return; |
|
9aa5d66cd13d
(Finally) converted to new-style args.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17813
diff
changeset
|
720 |
| 1495 | 721 /* 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
|
722 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
|
723 |
|
2d599a36b67a
SF patch #462296: Add attributes to os.stat results; by Nick Mathewson.
Guido van Rossum <guido@python.org>
parents:
19181
diff
changeset
|
724 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
|
725 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
|
726 |
| 1495 | 727 } |
