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
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
1495
877073b9f8c3 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
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
b4d982c648bb 1995 copyright
Guido van Rossum <guido@python.org>
parents: 2032
diff changeset
3 The Netherlands.
1495
877073b9f8c3 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
4
877073b9f8c3 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
5 All Rights Reserved
877073b9f8c3 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
6
877073b9f8c3 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
7 Permission to use, copy, modify, and distribute this software and its
877073b9f8c3 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
8 documentation for any purpose and without fee is hereby granted,
877073b9f8c3 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
9 provided that the above copyright notice appear in all copies and that
877073b9f8c3 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
10 both that copyright notice and this permission notice appear in
877073b9f8c3 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
11 supporting documentation, and that the names of Stichting Mathematisch
877073b9f8c3 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
12 Centrum or CWI not be used in advertising or publicity pertaining to
877073b9f8c3 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
13 distribution of the software without specific, written prior permission.
877073b9f8c3 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
14
877073b9f8c3 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
15 STICHTING MATHEMATISCH CENTRUM DISCLAIMS ALL WARRANTIES WITH REGARD TO
877073b9f8c3 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
16 THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
877073b9f8c3 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
17 FITNESS, IN NO EVENT SHALL STICHTING MATHEMATISCH CENTRUM BE LIABLE
877073b9f8c3 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
18 FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
877073b9f8c3 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
19 WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
877073b9f8c3 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
20 ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT
877073b9f8c3 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
21 OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
877073b9f8c3 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
22
877073b9f8c3 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
23 ******************************************************************/
877073b9f8c3 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
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
877073b9f8c3 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
26
5071
44bdf0b56c0b Renamed
Jack Jansen <jack.jansen@cwi.nl>
parents: 4468
diff changeset
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
877073b9f8c3 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
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
4fea6cd94dfa Modified for GUSI
Jack Jansen <jack.jansen@cwi.nl>
parents: 2929
diff changeset
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
116db7347d01 - Added Guido's fixes
Jack Jansen <jack.jansen@cwi.nl>
parents: 3394
diff changeset
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
4fea6cd94dfa Modified for GUSI
Jack Jansen <jack.jansen@cwi.nl>
parents: 2929
diff changeset
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
4fea6cd94dfa Modified for GUSI
Jack Jansen <jack.jansen@cwi.nl>
parents: 2929
diff changeset
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
116db7347d01 - Added Guido's fixes
Jack Jansen <jack.jansen@cwi.nl>
parents: 3394
diff changeset
75 /* Optional routines, for some compiler/runtime combinations */
116db7347d01 - Added Guido's fixes
Jack Jansen <jack.jansen@cwi.nl>
parents: 3394
diff changeset
76 #if defined(USE_GUSI) || !defined(__MWERKS__)
116db7347d01 - Added Guido's fixes
Jack Jansen <jack.jansen@cwi.nl>
parents: 3394
diff changeset
77 #define WEHAVE_FDOPEN
116db7347d01 - Added Guido's fixes
Jack Jansen <jack.jansen@cwi.nl>
parents: 3394
diff changeset
78 #endif
116db7347d01 - Added Guido's fixes
Jack Jansen <jack.jansen@cwi.nl>
parents: 3394
diff changeset
79 #if defined(MPW) || defined(USE_GUSI)
116db7347d01 - Added Guido's fixes
Jack Jansen <jack.jansen@cwi.nl>
parents: 3394
diff changeset
80 #define WEHAVE_DUP
116db7347d01 - Added Guido's fixes
Jack Jansen <jack.jansen@cwi.nl>
parents: 3394
diff changeset
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
4fea6cd94dfa Modified for GUSI
Jack Jansen <jack.jansen@cwi.nl>
parents: 2929
diff changeset
87 #ifdef USE_GUSI
4fea6cd94dfa Modified for GUSI
Jack Jansen <jack.jansen@cwi.nl>
parents: 2929
diff changeset
88 #include <dirent.h>
4fea6cd94dfa Modified for GUSI
Jack Jansen <jack.jansen@cwi.nl>
parents: 2929
diff changeset
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
4fea6cd94dfa Modified for GUSI
Jack Jansen <jack.jansen@cwi.nl>
parents: 2929
diff changeset
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
116db7347d01 - Added Guido's fixes
Jack Jansen <jack.jansen@cwi.nl>
parents: 3394
diff changeset
99 #ifndef USE_GUSI
116db7347d01 - Added Guido's fixes
Jack Jansen <jack.jansen@cwi.nl>
parents: 3394
diff changeset
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
116db7347d01 - Added Guido's fixes
Jack Jansen <jack.jansen@cwi.nl>
parents: 3394
diff changeset
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
116db7347d01 - Added Guido's fixes
Jack Jansen <jack.jansen@cwi.nl>
parents: 3394
diff changeset
111 #endif /* USE_GUSI */
116db7347d01 - Added Guido's fixes
Jack Jansen <jack.jansen@cwi.nl>
parents: 3394
diff changeset
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
44bdf0b56c0b Renamed
Jack Jansen <jack.jansen@cwi.nl>
parents: 4468
diff changeset
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
877073b9f8c3 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
126
5071
44bdf0b56c0b Renamed
Jack Jansen <jack.jansen@cwi.nl>
parents: 4468
diff changeset
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
44bdf0b56c0b Renamed
Jack Jansen <jack.jansen@cwi.nl>
parents: 4468
diff changeset
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
44bdf0b56c0b Renamed
Jack Jansen <jack.jansen@cwi.nl>
parents: 4468
diff changeset
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
44bdf0b56c0b Renamed
Jack Jansen <jack.jansen@cwi.nl>
parents: 4468
diff changeset
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
44bdf0b56c0b Renamed
Jack Jansen <jack.jansen@cwi.nl>
parents: 4468
diff changeset
141 Py_INCREF(Py_None);
44bdf0b56c0b Renamed
Jack Jansen <jack.jansen@cwi.nl>
parents: 4468
diff changeset
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
877073b9f8c3 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
144
5071
44bdf0b56c0b Renamed
Jack Jansen <jack.jansen@cwi.nl>
parents: 4468
diff changeset
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
44bdf0b56c0b Renamed
Jack Jansen <jack.jansen@cwi.nl>
parents: 4468
diff changeset
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
44bdf0b56c0b Renamed
Jack Jansen <jack.jansen@cwi.nl>
parents: 4468
diff changeset
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
44bdf0b56c0b Renamed
Jack Jansen <jack.jansen@cwi.nl>
parents: 4468
diff changeset
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
44bdf0b56c0b Renamed
Jack Jansen <jack.jansen@cwi.nl>
parents: 4468
diff changeset
159 Py_INCREF(Py_None);
44bdf0b56c0b Renamed
Jack Jansen <jack.jansen@cwi.nl>
parents: 4468
diff changeset
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
877073b9f8c3 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
162
5071
44bdf0b56c0b Renamed
Jack Jansen <jack.jansen@cwi.nl>
parents: 4468
diff changeset
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
44bdf0b56c0b Renamed
Jack Jansen <jack.jansen@cwi.nl>
parents: 4468
diff changeset
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
44bdf0b56c0b Renamed
Jack Jansen <jack.jansen@cwi.nl>
parents: 4468
diff changeset
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
44bdf0b56c0b Renamed
Jack Jansen <jack.jansen@cwi.nl>
parents: 4468
diff changeset
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
44bdf0b56c0b Renamed
Jack Jansen <jack.jansen@cwi.nl>
parents: 4468
diff changeset
178 Py_INCREF(Py_None);
44bdf0b56c0b Renamed
Jack Jansen <jack.jansen@cwi.nl>
parents: 4468
diff changeset
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
44bdf0b56c0b Renamed
Jack Jansen <jack.jansen@cwi.nl>
parents: 4468
diff changeset
182 static PyObject *
1495
877073b9f8c3 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
183 mac_chdir(self, args)
5071
44bdf0b56c0b Renamed
Jack Jansen <jack.jansen@cwi.nl>
parents: 4468
diff changeset
184 PyObject *self;
44bdf0b56c0b Renamed
Jack Jansen <jack.jansen@cwi.nl>
parents: 4468
diff changeset
185 PyObject *args;
1495
877073b9f8c3 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
186 {
12284
9c96e5d437a8 Started on GUSI2 and threading support.
Jack Jansen <jack.jansen@cwi.nl>
parents: 7434
diff changeset
187 #ifdef USE_GUSI1
5071
44bdf0b56c0b Renamed
Jack Jansen <jack.jansen@cwi.nl>
parents: 4468
diff changeset
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
44bdf0b56c0b Renamed
Jack Jansen <jack.jansen@cwi.nl>
parents: 4468
diff changeset
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
44bdf0b56c0b Renamed
Jack Jansen <jack.jansen@cwi.nl>
parents: 4468
diff changeset
202 PyObject *self;
44bdf0b56c0b Renamed
Jack Jansen <jack.jansen@cwi.nl>
parents: 4468
diff changeset
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
877073b9f8c3 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
207 return NULL;
5071
44bdf0b56c0b Renamed
Jack Jansen <jack.jansen@cwi.nl>
parents: 4468
diff changeset
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
44bdf0b56c0b Renamed
Jack Jansen <jack.jansen@cwi.nl>
parents: 4468
diff changeset
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
116db7347d01 - Added Guido's fixes
Jack Jansen <jack.jansen@cwi.nl>
parents: 3394
diff changeset
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
116db7347d01 - Added Guido's fixes
Jack Jansen <jack.jansen@cwi.nl>
parents: 3394
diff changeset
215 #endif
5071
44bdf0b56c0b Renamed
Jack Jansen <jack.jansen@cwi.nl>
parents: 4468
diff changeset
216 Py_INCREF(Py_None);
44bdf0b56c0b Renamed
Jack Jansen <jack.jansen@cwi.nl>
parents: 4468
diff changeset
217 return Py_None;
1495
877073b9f8c3 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
218 }
877073b9f8c3 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
219
3400
116db7347d01 - Added Guido's fixes
Jack Jansen <jack.jansen@cwi.nl>
parents: 3394
diff changeset
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
44bdf0b56c0b Renamed
Jack Jansen <jack.jansen@cwi.nl>
parents: 4468
diff changeset
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
44bdf0b56c0b Renamed
Jack Jansen <jack.jansen@cwi.nl>
parents: 4468
diff changeset
224 PyObject *self;
44bdf0b56c0b Renamed
Jack Jansen <jack.jansen@cwi.nl>
parents: 4468
diff changeset
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
44bdf0b56c0b Renamed
Jack Jansen <jack.jansen@cwi.nl>
parents: 4468
diff changeset
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
44bdf0b56c0b Renamed
Jack Jansen <jack.jansen@cwi.nl>
parents: 4468
diff changeset
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
44bdf0b56c0b Renamed
Jack Jansen <jack.jansen@cwi.nl>
parents: 4468
diff changeset
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
116db7347d01 - Added Guido's fixes
Jack Jansen <jack.jansen@cwi.nl>
parents: 3394
diff changeset
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
116db7347d01 - Added Guido's fixes
Jack Jansen <jack.jansen@cwi.nl>
parents: 3394
diff changeset
240 #ifdef WEHAVE_FDOPEN
5071
44bdf0b56c0b Renamed
Jack Jansen <jack.jansen@cwi.nl>
parents: 4468
diff changeset
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
44bdf0b56c0b Renamed
Jack Jansen <jack.jansen@cwi.nl>
parents: 4468
diff changeset
243 PyObject *self;
44bdf0b56c0b Renamed
Jack Jansen <jack.jansen@cwi.nl>
parents: 4468
diff changeset
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
44bdf0b56c0b Renamed
Jack Jansen <jack.jansen@cwi.nl>
parents: 4468
diff changeset
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
44bdf0b56c0b Renamed
Jack Jansen <jack.jansen@cwi.nl>
parents: 4468
diff changeset
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
44bdf0b56c0b Renamed
Jack Jansen <jack.jansen@cwi.nl>
parents: 4468
diff changeset
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
44bdf0b56c0b Renamed
Jack Jansen <jack.jansen@cwi.nl>
parents: 4468
diff changeset
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
44bdf0b56c0b Renamed
Jack Jansen <jack.jansen@cwi.nl>
parents: 4468
diff changeset
264 PyObject *self;
44bdf0b56c0b Renamed
Jack Jansen <jack.jansen@cwi.nl>
parents: 4468
diff changeset
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
44bdf0b56c0b Renamed
Jack Jansen <jack.jansen@cwi.nl>
parents: 4468
diff changeset
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
44bdf0b56c0b Renamed
Jack Jansen <jack.jansen@cwi.nl>
parents: 4468
diff changeset
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
44bdf0b56c0b Renamed
Jack Jansen <jack.jansen@cwi.nl>
parents: 4468
diff changeset
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
877073b9f8c3 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
278
5071
44bdf0b56c0b Renamed
Jack Jansen <jack.jansen@cwi.nl>
parents: 4468
diff changeset
279 static PyObject *
1495
877073b9f8c3 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
280 mac_getcwd(self, args)
5071
44bdf0b56c0b Renamed
Jack Jansen <jack.jansen@cwi.nl>
parents: 4468
diff changeset
281 PyObject *self;
44bdf0b56c0b Renamed
Jack Jansen <jack.jansen@cwi.nl>
parents: 4468
diff changeset
282 PyObject *args;
1495
877073b9f8c3 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
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
877073b9f8c3 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
287 return NULL;
5071
44bdf0b56c0b Renamed
Jack Jansen <jack.jansen@cwi.nl>
parents: 4468
diff changeset
288 Py_BEGIN_ALLOW_THREADS
3400
116db7347d01 - Added Guido's fixes
Jack Jansen <jack.jansen@cwi.nl>
parents: 3394
diff changeset
289 #ifdef USE_GUSI
116db7347d01 - Added Guido's fixes
Jack Jansen <jack.jansen@cwi.nl>
parents: 3394
diff changeset
290 res = getcwd(path, sizeof path);
116db7347d01 - Added Guido's fixes
Jack Jansen <jack.jansen@cwi.nl>
parents: 3394
diff changeset
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
116db7347d01 - Added Guido's fixes
Jack Jansen <jack.jansen@cwi.nl>
parents: 3394
diff changeset
293 #endif
5071
44bdf0b56c0b Renamed
Jack Jansen <jack.jansen@cwi.nl>
parents: 4468
diff changeset
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
877073b9f8c3 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
297 }
5071
44bdf0b56c0b Renamed
Jack Jansen <jack.jansen@cwi.nl>
parents: 4468
diff changeset
298 return PyString_FromString(res);
1495
877073b9f8c3 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
299 }
877073b9f8c3 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
300
5071
44bdf0b56c0b Renamed
Jack Jansen <jack.jansen@cwi.nl>
parents: 4468
diff changeset
301 static PyObject *
1495
877073b9f8c3 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
302 mac_listdir(self, args)
5071
44bdf0b56c0b Renamed
Jack Jansen <jack.jansen@cwi.nl>
parents: 4468
diff changeset
303 PyObject *self;
44bdf0b56c0b Renamed
Jack Jansen <jack.jansen@cwi.nl>
parents: 4468
diff changeset
304 PyObject *args;
1495
877073b9f8c3 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
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
44bdf0b56c0b Renamed
Jack Jansen <jack.jansen@cwi.nl>
parents: 4468
diff changeset
307 PyObject *d, *v;
1495
877073b9f8c3 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
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
877073b9f8c3 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
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
44bdf0b56c0b Renamed
Jack Jansen <jack.jansen@cwi.nl>
parents: 4468
diff changeset
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
44bdf0b56c0b Renamed
Jack Jansen <jack.jansen@cwi.nl>
parents: 4468
diff changeset
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
44bdf0b56c0b Renamed
Jack Jansen <jack.jansen@cwi.nl>
parents: 4468
diff changeset
335 if ((d = PyList_New(0)) == NULL) {
1495
877073b9f8c3 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
336 closedir(dirp);
5071
44bdf0b56c0b Renamed
Jack Jansen <jack.jansen@cwi.nl>
parents: 4468
diff changeset
337 Py_BLOCK_THREADS
1495
877073b9f8c3 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
338 return NULL;
877073b9f8c3 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
339 }
877073b9f8c3 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
340 while ((ep = readdir(dirp)) != NULL) {
5071
44bdf0b56c0b Renamed
Jack Jansen <jack.jansen@cwi.nl>
parents: 4468
diff changeset
341 v = PyString_FromString(ep->d_name);
1495
877073b9f8c3 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
342 if (v == NULL) {
5071
44bdf0b56c0b Renamed
Jack Jansen <jack.jansen@cwi.nl>
parents: 4468
diff changeset
343 Py_DECREF(d);
1495
877073b9f8c3 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
344 d = NULL;
877073b9f8c3 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
345 break;
877073b9f8c3 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
346 }
5071
44bdf0b56c0b Renamed
Jack Jansen <jack.jansen@cwi.nl>
parents: 4468
diff changeset
347 if (PyList_Append(d, v) != 0) {
44bdf0b56c0b Renamed
Jack Jansen <jack.jansen@cwi.nl>
parents: 4468
diff changeset
348 Py_DECREF(v);
44bdf0b56c0b Renamed
Jack Jansen <jack.jansen@cwi.nl>
parents: 4468
diff changeset
349 Py_DECREF(d);
1495
877073b9f8c3 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
350 d = NULL;
877073b9f8c3 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
351 break;
877073b9f8c3 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
352 }
5071
44bdf0b56c0b Renamed
Jack Jansen <jack.jansen@cwi.nl>
parents: 4468
diff changeset
353 Py_DECREF(v);
1495
877073b9f8c3 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
354 }
877073b9f8c3 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
355 closedir(dirp);
5071
44bdf0b56c0b Renamed
Jack Jansen <jack.jansen@cwi.nl>
parents: 4468
diff changeset
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
877073b9f8c3 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
358 return d;
877073b9f8c3 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
359 }
877073b9f8c3 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
360
5071
44bdf0b56c0b Renamed
Jack Jansen <jack.jansen@cwi.nl>
parents: 4468
diff changeset
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
44bdf0b56c0b Renamed
Jack Jansen <jack.jansen@cwi.nl>
parents: 4468
diff changeset
363 PyObject *self;
44bdf0b56c0b Renamed
Jack Jansen <jack.jansen@cwi.nl>
parents: 4468
diff changeset
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
44bdf0b56c0b Renamed
Jack Jansen <jack.jansen@cwi.nl>
parents: 4468
diff changeset
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
44bdf0b56c0b Renamed
Jack Jansen <jack.jansen@cwi.nl>
parents: 4468
diff changeset
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
44bdf0b56c0b Renamed
Jack Jansen <jack.jansen@cwi.nl>
parents: 4468
diff changeset
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
4fea6cd94dfa Modified for GUSI
Jack Jansen <jack.jansen@cwi.nl>
parents: 2929
diff changeset
379
5071
44bdf0b56c0b Renamed
Jack Jansen <jack.jansen@cwi.nl>
parents: 4468
diff changeset
380 static PyObject *
1495
877073b9f8c3 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
381 mac_mkdir(self, args)
5071
44bdf0b56c0b Renamed
Jack Jansen <jack.jansen@cwi.nl>
parents: 4468
diff changeset
382 PyObject *self;
44bdf0b56c0b Renamed
Jack Jansen <jack.jansen@cwi.nl>
parents: 4468
diff changeset
383 PyObject *args;
1495
877073b9f8c3 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
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
44bdf0b56c0b Renamed
Jack Jansen <jack.jansen@cwi.nl>
parents: 4468
diff changeset
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
44bdf0b56c0b Renamed
Jack Jansen <jack.jansen@cwi.nl>
parents: 4468
diff changeset
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
44bdf0b56c0b Renamed
Jack Jansen <jack.jansen@cwi.nl>
parents: 4468
diff changeset
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
44bdf0b56c0b Renamed
Jack Jansen <jack.jansen@cwi.nl>
parents: 4468
diff changeset
399 Py_INCREF(Py_None);
44bdf0b56c0b Renamed
Jack Jansen <jack.jansen@cwi.nl>
parents: 4468
diff changeset
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
44bdf0b56c0b Renamed
Jack Jansen <jack.jansen@cwi.nl>
parents: 4468
diff changeset
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
44bdf0b56c0b Renamed
Jack Jansen <jack.jansen@cwi.nl>
parents: 4468
diff changeset
405 PyObject *self;
44bdf0b56c0b Renamed
Jack Jansen <jack.jansen@cwi.nl>
parents: 4468
diff changeset
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
877073b9f8c3 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
408 char *path;
877073b9f8c3 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
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
877073b9f8c3 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
413 return NULL;
5071
44bdf0b56c0b Renamed
Jack Jansen <jack.jansen@cwi.nl>
parents: 4468
diff changeset
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
44bdf0b56c0b Renamed
Jack Jansen <jack.jansen@cwi.nl>
parents: 4468
diff changeset
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
44bdf0b56c0b Renamed
Jack Jansen <jack.jansen@cwi.nl>
parents: 4468
diff changeset
419 return PyInt_FromLong((long)fd);
1495
877073b9f8c3 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
420 }
877073b9f8c3 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
421
5071
44bdf0b56c0b Renamed
Jack Jansen <jack.jansen@cwi.nl>
parents: 4468
diff changeset
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
44bdf0b56c0b Renamed
Jack Jansen <jack.jansen@cwi.nl>
parents: 4468
diff changeset
424 PyObject *self;
44bdf0b56c0b Renamed
Jack Jansen <jack.jansen@cwi.nl>
parents: 4468
diff changeset
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
44bdf0b56c0b Renamed
Jack Jansen <jack.jansen@cwi.nl>
parents: 4468
diff changeset
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
44bdf0b56c0b Renamed
Jack Jansen <jack.jansen@cwi.nl>
parents: 4468
diff changeset
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
44bdf0b56c0b Renamed
Jack Jansen <jack.jansen@cwi.nl>
parents: 4468
diff changeset
434 Py_BEGIN_ALLOW_THREADS
44bdf0b56c0b Renamed
Jack Jansen <jack.jansen@cwi.nl>
parents: 4468
diff changeset
435 size = read(fd, PyString_AsString(buffer), size);
44bdf0b56c0b Renamed
Jack Jansen <jack.jansen@cwi.nl>
parents: 4468
diff changeset
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
44bdf0b56c0b Renamed
Jack Jansen <jack.jansen@cwi.nl>
parents: 4468
diff changeset
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
44bdf0b56c0b Renamed
Jack Jansen <jack.jansen@cwi.nl>
parents: 4468
diff changeset
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
877073b9f8c3 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
444
5071
44bdf0b56c0b Renamed
Jack Jansen <jack.jansen@cwi.nl>
parents: 4468
diff changeset
445 static PyObject *
1495
877073b9f8c3 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
446 mac_rename(self, args)
5071
44bdf0b56c0b Renamed
Jack Jansen <jack.jansen@cwi.nl>
parents: 4468
diff changeset
447 PyObject *self;
44bdf0b56c0b Renamed
Jack Jansen <jack.jansen@cwi.nl>
parents: 4468
diff changeset
448 PyObject *args;
1495
877073b9f8c3 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
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
877073b9f8c3 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
451 }
877073b9f8c3 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
452
5071
44bdf0b56c0b Renamed
Jack Jansen <jack.jansen@cwi.nl>
parents: 4468
diff changeset
453 static PyObject *
1495
877073b9f8c3 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
454 mac_rmdir(self, args)
5071
44bdf0b56c0b Renamed
Jack Jansen <jack.jansen@cwi.nl>
parents: 4468
diff changeset
455 PyObject *self;
44bdf0b56c0b Renamed
Jack Jansen <jack.jansen@cwi.nl>
parents: 4468
diff changeset
456 PyObject *args;
1495
877073b9f8c3 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
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
877073b9f8c3 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
459 }
877073b9f8c3 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
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
44bdf0b56c0b Renamed
Jack Jansen <jack.jansen@cwi.nl>
parents: 4468
diff changeset
565 static PyObject *
1495
877073b9f8c3 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
566 mac_stat(self, args)
5071
44bdf0b56c0b Renamed
Jack Jansen <jack.jansen@cwi.nl>
parents: 4468
diff changeset
567 PyObject *self;
44bdf0b56c0b Renamed
Jack Jansen <jack.jansen@cwi.nl>
parents: 4468
diff changeset
568 PyObject *args;
1495
877073b9f8c3 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
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
877073b9f8c3 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
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
877073b9f8c3 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
574 return NULL;
5071
44bdf0b56c0b Renamed
Jack Jansen <jack.jansen@cwi.nl>
parents: 4468
diff changeset
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
44bdf0b56c0b Renamed
Jack Jansen <jack.jansen@cwi.nl>
parents: 4468
diff changeset
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
877073b9f8c3 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
602 }
7434
3de0cb82e61a Add fstat() if using GUSI
Jack Jansen <jack.jansen@cwi.nl>
parents: 6442
diff changeset
603 #endif /* WEHAVE_FSTAT */
1495
877073b9f8c3 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
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
44bdf0b56c0b Renamed
Jack Jansen <jack.jansen@cwi.nl>
parents: 4468
diff changeset
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
44bdf0b56c0b Renamed
Jack Jansen <jack.jansen@cwi.nl>
parents: 4468
diff changeset
608 PyObject *self;
44bdf0b56c0b Renamed
Jack Jansen <jack.jansen@cwi.nl>
parents: 4468
diff changeset
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
44bdf0b56c0b Renamed
Jack Jansen <jack.jansen@cwi.nl>
parents: 4468
diff changeset
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
44bdf0b56c0b Renamed
Jack Jansen <jack.jansen@cwi.nl>
parents: 4468
diff changeset
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
44bdf0b56c0b Renamed
Jack Jansen <jack.jansen@cwi.nl>
parents: 4468
diff changeset
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
44bdf0b56c0b Renamed
Jack Jansen <jack.jansen@cwi.nl>
parents: 4468
diff changeset
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
44bdf0b56c0b Renamed
Jack Jansen <jack.jansen@cwi.nl>
parents: 4468
diff changeset
637 static PyObject *
1495
877073b9f8c3 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
638 mac_sync(self, args)
5071
44bdf0b56c0b Renamed
Jack Jansen <jack.jansen@cwi.nl>
parents: 4468
diff changeset
639 PyObject *self;
44bdf0b56c0b Renamed
Jack Jansen <jack.jansen@cwi.nl>
parents: 4468
diff changeset
640 PyObject *args;
1495
877073b9f8c3 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
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
877073b9f8c3 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
644 return NULL;
5071
44bdf0b56c0b Renamed
Jack Jansen <jack.jansen@cwi.nl>
parents: 4468
diff changeset
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
44bdf0b56c0b Renamed
Jack Jansen <jack.jansen@cwi.nl>
parents: 4468
diff changeset
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
44bdf0b56c0b Renamed
Jack Jansen <jack.jansen@cwi.nl>
parents: 4468
diff changeset
650 Py_INCREF(Py_None);
44bdf0b56c0b Renamed
Jack Jansen <jack.jansen@cwi.nl>
parents: 4468
diff changeset
651 return Py_None;
1495
877073b9f8c3 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
652 }
877073b9f8c3 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
653
5071
44bdf0b56c0b Renamed
Jack Jansen <jack.jansen@cwi.nl>
parents: 4468
diff changeset
654 static PyObject *
1495
877073b9f8c3 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
655 mac_unlink(self, args)
5071
44bdf0b56c0b Renamed
Jack Jansen <jack.jansen@cwi.nl>
parents: 4468
diff changeset
656 PyObject *self;
44bdf0b56c0b Renamed
Jack Jansen <jack.jansen@cwi.nl>
parents: 4468
diff changeset
657 PyObject *args;
1495
877073b9f8c3 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
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
877073b9f8c3 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
660 }
877073b9f8c3 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
661
5071
44bdf0b56c0b Renamed
Jack Jansen <jack.jansen@cwi.nl>
parents: 4468
diff changeset
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
44bdf0b56c0b Renamed
Jack Jansen <jack.jansen@cwi.nl>
parents: 4468
diff changeset
664 PyObject *self;
44bdf0b56c0b Renamed
Jack Jansen <jack.jansen@cwi.nl>
parents: 4468
diff changeset
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
44bdf0b56c0b Renamed
Jack Jansen <jack.jansen@cwi.nl>
parents: 4468
diff changeset
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
44bdf0b56c0b Renamed
Jack Jansen <jack.jansen@cwi.nl>
parents: 4468
diff changeset
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
44bdf0b56c0b Renamed
Jack Jansen <jack.jansen@cwi.nl>
parents: 4468
diff changeset
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
877073b9f8c3 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
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
44bdf0b56c0b Renamed
Jack Jansen <jack.jansen@cwi.nl>
parents: 4468
diff changeset
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
44bdf0b56c0b Renamed
Jack Jansen <jack.jansen@cwi.nl>
parents: 4468
diff changeset
684 PyObject*self;
44bdf0b56c0b Renamed
Jack Jansen <jack.jansen@cwi.nl>
parents: 4468
diff changeset
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
44bdf0b56c0b Renamed
Jack Jansen <jack.jansen@cwi.nl>
parents: 4468
diff changeset
688 Py_INCREF(Py_None);
44bdf0b56c0b Renamed
Jack Jansen <jack.jansen@cwi.nl>
parents: 4468
diff changeset
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
44bdf0b56c0b Renamed
Jack Jansen <jack.jansen@cwi.nl>
parents: 4468
diff changeset
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
116db7347d01 - Added Guido's fixes
Jack Jansen <jack.jansen@cwi.nl>
parents: 3394
diff changeset
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
116db7347d01 - Added Guido's fixes
Jack Jansen <jack.jansen@cwi.nl>
parents: 3394
diff changeset
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
877073b9f8c3 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
728 {NULL, NULL} /* Sentinel */
877073b9f8c3 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
729 };
877073b9f8c3 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
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
877073b9f8c3 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
826
877073b9f8c3 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
827 void
877073b9f8c3 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
828 initmac()
877073b9f8c3 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
829 {
5071
44bdf0b56c0b Renamed
Jack Jansen <jack.jansen@cwi.nl>
parents: 4468
diff changeset
830 PyObject *m, *d;
1495
877073b9f8c3 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
831
5071
44bdf0b56c0b Renamed
Jack Jansen <jack.jansen@cwi.nl>
parents: 4468
diff changeset
832 m = Py_InitModule("mac", mac_methods);
44bdf0b56c0b Renamed
Jack Jansen <jack.jansen@cwi.nl>
parents: 4468
diff changeset
833 d = PyModule_GetDict(m);
1495
877073b9f8c3 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
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
877073b9f8c3 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
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
877073b9f8c3 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
848 }