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