Mercurial > cpython-lru_cache-weakref
annotate Mac/Modules/macfsmodule.c @ 21283:d4907cdcc299 legacy-trunk
Use an immutable tuple for __slots instead of a mutable list
Bump version number
| author | Andrew M. Kuchling <amk@amk.ca> |
|---|---|
| date | Fri, 07 Dec 2001 14:22:13 +0000 |
| parents | ba6a7a5c32e8 |
| children | 91dd223829c6 |
| rev | line source |
|---|---|
|
2180
9b451c84a7bf
Initial version of FSSpec and Alias code. Non-functional as of now.
Jack Jansen <jack.jansen@cwi.nl>
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, |
|
2254
67e8ef698a42
added (method) casts and 1995 copyright
Guido van Rossum <guido@python.org>
parents:
2249
diff
changeset
|
3 The Netherlands. |
|
2180
9b451c84a7bf
Initial version of FSSpec and Alias code. Non-functional as of now.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
4 |
|
9b451c84a7bf
Initial version of FSSpec and Alias code. Non-functional as of now.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
5 All Rights Reserved |
|
9b451c84a7bf
Initial version of FSSpec and Alias code. Non-functional as of now.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
6 |
|
9b451c84a7bf
Initial version of FSSpec and Alias code. Non-functional as of now.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
7 Permission to use, copy, modify, and distribute this software and its |
|
9b451c84a7bf
Initial version of FSSpec and Alias code. Non-functional as of now.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
8 documentation for any purpose and without fee is hereby granted, |
|
9b451c84a7bf
Initial version of FSSpec and Alias code. Non-functional as of now.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
9 provided that the above copyright notice appear in all copies and that |
|
9b451c84a7bf
Initial version of FSSpec and Alias code. Non-functional as of now.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
10 both that copyright notice and this permission notice appear in |
|
9b451c84a7bf
Initial version of FSSpec and Alias code. Non-functional as of now.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
11 supporting documentation, and that the names of Stichting Mathematisch |
|
9b451c84a7bf
Initial version of FSSpec and Alias code. Non-functional as of now.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
12 Centrum or CWI not be used in advertising or publicity pertaining to |
|
9b451c84a7bf
Initial version of FSSpec and Alias code. Non-functional as of now.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
13 distribution of the software without specific, written prior permission. |
|
9b451c84a7bf
Initial version of FSSpec and Alias code. Non-functional as of now.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
14 |
|
9b451c84a7bf
Initial version of FSSpec and Alias code. Non-functional as of now.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
15 STICHTING MATHEMATISCH CENTRUM DISCLAIMS ALL WARRANTIES WITH REGARD TO |
|
9b451c84a7bf
Initial version of FSSpec and Alias code. Non-functional as of now.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
16 THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND |
|
9b451c84a7bf
Initial version of FSSpec and Alias code. Non-functional as of now.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
17 FITNESS, IN NO EVENT SHALL STICHTING MATHEMATISCH CENTRUM BE LIABLE |
|
9b451c84a7bf
Initial version of FSSpec and Alias code. Non-functional as of now.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
18 FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES |
|
9b451c84a7bf
Initial version of FSSpec and Alias code. Non-functional as of now.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
19 WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN |
|
9b451c84a7bf
Initial version of FSSpec and Alias code. Non-functional as of now.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
20 ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT |
|
9b451c84a7bf
Initial version of FSSpec and Alias code. Non-functional as of now.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
21 OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. |
|
9b451c84a7bf
Initial version of FSSpec and Alias code. Non-functional as of now.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
22 |
|
9b451c84a7bf
Initial version of FSSpec and Alias code. Non-functional as of now.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
23 ******************************************************************/ |
|
9b451c84a7bf
Initial version of FSSpec and Alias code. Non-functional as of now.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
24 |
| 5071 | 25 #include "Python.h" |
|
2180
9b451c84a7bf
Initial version of FSSpec and Alias code. Non-functional as of now.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
26 #include "macglue.h" |
|
18979
3dd8e64f512e
PyMac_GetFSSpec must be called via the dylib glue code on OSX.
Jack Jansen <jack.jansen@cwi.nl>
parents:
18962
diff
changeset
|
27 #include "pymactoolbox.h" |
|
2180
9b451c84a7bf
Initial version of FSSpec and Alias code. Non-functional as of now.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
28 |
|
17864
be969e717b91
Include Carbon/Carbon.h in stead of universal headers, if appropriate.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17049
diff
changeset
|
29 #ifdef WITHOUT_FRAMEWORKS |
| 2337 | 30 #include <Memory.h> |
|
2180
9b451c84a7bf
Initial version of FSSpec and Alias code. Non-functional as of now.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
31 #include <Files.h> |
|
2748
39cd25678b41
Added FindFolder interface
Jack Jansen <jack.jansen@cwi.nl>
parents:
2717
diff
changeset
|
32 #include <Folders.h> |
|
2180
9b451c84a7bf
Initial version of FSSpec and Alias code. Non-functional as of now.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
33 #include <StandardFile.h> |
|
9b451c84a7bf
Initial version of FSSpec and Alias code. Non-functional as of now.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
34 #include <Aliases.h> |
|
3787
7766360b85b8
Added SetFolder method which sets Standard File initial folder
Jack Jansen <jack.jansen@cwi.nl>
parents:
3140
diff
changeset
|
35 #include <LowMem.h> |
|
17864
be969e717b91
Include Carbon/Carbon.h in stead of universal headers, if appropriate.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17049
diff
changeset
|
36 #else |
|
be969e717b91
Include Carbon/Carbon.h in stead of universal headers, if appropriate.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17049
diff
changeset
|
37 #include <Carbon/Carbon.h> |
|
be969e717b91
Include Carbon/Carbon.h in stead of universal headers, if appropriate.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17049
diff
changeset
|
38 #endif |
|
2180
9b451c84a7bf
Initial version of FSSpec and Alias code. Non-functional as of now.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
39 |
|
4319
97133996e22f
Added macfs.FindApplication() to find application FSSpec given signature.
Jack Jansen <jack.jansen@cwi.nl>
parents:
4308
diff
changeset
|
40 #include "getapplbycreator.h" |
|
2180
9b451c84a7bf
Initial version of FSSpec and Alias code. Non-functional as of now.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
41 |
|
20806
42f22ea6a0f1
Under MachO-Python unconditionally import macfsn.
Jack Jansen <jack.jansen@cwi.nl>
parents:
20794
diff
changeset
|
42 #ifndef TARGET_API_MAC_OSX |
|
20794
83a3e21a7cc3
Moved macfsn hackery from macmain.c to macfsmodule.c so it loads
Just van Rossum <just@letterror.com>
parents:
19841
diff
changeset
|
43 #include "pythonresources.h" |
|
83a3e21a7cc3
Moved macfsn hackery from macmain.c to macfsmodule.c so it loads
Just van Rossum <just@letterror.com>
parents:
19841
diff
changeset
|
44 extern PyMac_PrefRecord PyMac_options; |
|
20806
42f22ea6a0f1
Under MachO-Python unconditionally import macfsn.
Jack Jansen <jack.jansen@cwi.nl>
parents:
20794
diff
changeset
|
45 #endif |
|
20794
83a3e21a7cc3
Moved macfsn hackery from macmain.c to macfsmodule.c so it loads
Just van Rossum <just@letterror.com>
parents:
19841
diff
changeset
|
46 |
|
18979
3dd8e64f512e
PyMac_GetFSSpec must be called via the dylib glue code on OSX.
Jack Jansen <jack.jansen@cwi.nl>
parents:
18962
diff
changeset
|
47 #ifdef USE_TOOLBOX_OBJECT_GLUE |
|
3dd8e64f512e
PyMac_GetFSSpec must be called via the dylib glue code on OSX.
Jack Jansen <jack.jansen@cwi.nl>
parents:
18962
diff
changeset
|
48 extern int _PyMac_GetFSSpec(PyObject *, FSSpec *); |
| 19649 | 49 extern PyObject *_PyMac_BuildFSSpec(FSSpec *); |
| 50 extern int _PyMac_GetFSRef(PyObject *, FSRef *); | |
|
19645
d55b75ac2fb4
Added glue routine for PyMac_BuildFSSpec, PyMac_GetFSRef and PyMac_BuildFSRef.
Jack Jansen <jack.jansen@cwi.nl>
parents:
19066
diff
changeset
|
51 extern PyObject *_PyMac_BuildFSRef(FSRef *); |
|
18979
3dd8e64f512e
PyMac_GetFSSpec must be called via the dylib glue code on OSX.
Jack Jansen <jack.jansen@cwi.nl>
parents:
18962
diff
changeset
|
52 #define PyMac_GetFSSpec _PyMac_GetFSSpec |
|
19645
d55b75ac2fb4
Added glue routine for PyMac_BuildFSSpec, PyMac_GetFSRef and PyMac_BuildFSRef.
Jack Jansen <jack.jansen@cwi.nl>
parents:
19066
diff
changeset
|
53 #define PyMac_BuildFSSpec _PyMac_BuildFSSpec |
|
d55b75ac2fb4
Added glue routine for PyMac_BuildFSSpec, PyMac_GetFSRef and PyMac_BuildFSRef.
Jack Jansen <jack.jansen@cwi.nl>
parents:
19066
diff
changeset
|
54 #define PyMac_GetFSRef _PyMac_GetFSRef |
|
d55b75ac2fb4
Added glue routine for PyMac_BuildFSSpec, PyMac_GetFSRef and PyMac_BuildFSRef.
Jack Jansen <jack.jansen@cwi.nl>
parents:
19066
diff
changeset
|
55 #define PyMac_BuildFSRef _PyMac_BuildFSRef |
|
18979
3dd8e64f512e
PyMac_GetFSSpec must be called via the dylib glue code on OSX.
Jack Jansen <jack.jansen@cwi.nl>
parents:
18962
diff
changeset
|
56 #endif |
| 5071 | 57 static PyObject *ErrorObject; |
|
2180
9b451c84a7bf
Initial version of FSSpec and Alias code. Non-functional as of now.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
58 |
|
19841
d8dd75e3b304
Replaced PyMac_FullPath by PyMac_FullPathname, which has an extra 'length'
Jack Jansen <jack.jansen@cwi.nl>
parents:
19649
diff
changeset
|
59 #ifdef TARGET_API_MAC_OSX |
|
d8dd75e3b304
Replaced PyMac_FullPath by PyMac_FullPathname, which has an extra 'length'
Jack Jansen <jack.jansen@cwi.nl>
parents:
19649
diff
changeset
|
60 #define PATHNAMELEN 1024 |
|
d8dd75e3b304
Replaced PyMac_FullPath by PyMac_FullPathname, which has an extra 'length'
Jack Jansen <jack.jansen@cwi.nl>
parents:
19649
diff
changeset
|
61 #else |
|
d8dd75e3b304
Replaced PyMac_FullPath by PyMac_FullPathname, which has an extra 'length'
Jack Jansen <jack.jansen@cwi.nl>
parents:
19649
diff
changeset
|
62 #define PATHNAMELEN 256 |
|
d8dd75e3b304
Replaced PyMac_FullPath by PyMac_FullPathname, which has an extra 'length'
Jack Jansen <jack.jansen@cwi.nl>
parents:
19649
diff
changeset
|
63 #endif |
|
d8dd75e3b304
Replaced PyMac_FullPath by PyMac_FullPathname, which has an extra 'length'
Jack Jansen <jack.jansen@cwi.nl>
parents:
19649
diff
changeset
|
64 |
|
2180
9b451c84a7bf
Initial version of FSSpec and Alias code. Non-functional as of now.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
65 /* ----------------------------------------------------- */ |
| 2249 | 66 /* Declarations for objects of type Alias */ |
| 67 | |
| 68 typedef struct { | |
| 5071 | 69 PyObject_HEAD |
| 2249 | 70 AliasHandle alias; |
| 71 } mfsaobject; | |
| 72 | |
| 5071 | 73 staticforward PyTypeObject Mfsatype; |
| 2249 | 74 |
| 75 #define is_mfsaobject(v) ((v)->ob_type == &Mfsatype) | |
| 76 | |
| 77 /* ---------------------------------------------------------------- */ | |
| 78 /* Declarations for objects of type FSSpec */ | |
| 79 | |
| 80 typedef struct { | |
| 5071 | 81 PyObject_HEAD |
| 2249 | 82 FSSpec fsspec; |
| 83 } mfssobject; | |
| 84 | |
| 5071 | 85 staticforward PyTypeObject Mfsstype; |
| 2249 | 86 |
| 87 #define is_mfssobject(v) ((v)->ob_type == &Mfsstype) | |
| 88 | |
|
18434
f7f076bfcae9
Implemented minimal FSRef support, plus conversion between FSRefs, FSSpecs and pathnames where applicable.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17864
diff
changeset
|
89 /* ---------------------------------------------------------------- */ |
|
f7f076bfcae9
Implemented minimal FSRef support, plus conversion between FSRefs, FSSpecs and pathnames where applicable.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17864
diff
changeset
|
90 /* Declarations for objects of type FSRef */ |
|
f7f076bfcae9
Implemented minimal FSRef support, plus conversion between FSRefs, FSSpecs and pathnames where applicable.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17864
diff
changeset
|
91 |
|
f7f076bfcae9
Implemented minimal FSRef support, plus conversion between FSRefs, FSSpecs and pathnames where applicable.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17864
diff
changeset
|
92 typedef struct { |
|
f7f076bfcae9
Implemented minimal FSRef support, plus conversion between FSRefs, FSSpecs and pathnames where applicable.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17864
diff
changeset
|
93 PyObject_HEAD |
|
f7f076bfcae9
Implemented minimal FSRef support, plus conversion between FSRefs, FSSpecs and pathnames where applicable.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17864
diff
changeset
|
94 FSRef fsref; |
|
f7f076bfcae9
Implemented minimal FSRef support, plus conversion between FSRefs, FSSpecs and pathnames where applicable.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17864
diff
changeset
|
95 } mfsrobject; |
|
f7f076bfcae9
Implemented minimal FSRef support, plus conversion between FSRefs, FSSpecs and pathnames where applicable.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17864
diff
changeset
|
96 |
|
f7f076bfcae9
Implemented minimal FSRef support, plus conversion between FSRefs, FSSpecs and pathnames where applicable.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17864
diff
changeset
|
97 staticforward PyTypeObject Mfsrtype; |
|
f7f076bfcae9
Implemented minimal FSRef support, plus conversion between FSRefs, FSSpecs and pathnames where applicable.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17864
diff
changeset
|
98 |
|
f7f076bfcae9
Implemented minimal FSRef support, plus conversion between FSRefs, FSSpecs and pathnames where applicable.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17864
diff
changeset
|
99 #define is_mfsrobject(v) ((v)->ob_type == &Mfsrtype) |
|
f7f076bfcae9
Implemented minimal FSRef support, plus conversion between FSRefs, FSSpecs and pathnames where applicable.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17864
diff
changeset
|
100 |
|
2254
67e8ef698a42
added (method) casts and 1995 copyright
Guido van Rossum <guido@python.org>
parents:
2249
diff
changeset
|
101 |
|
2909
f9b1069a3e26
Added interfaces to {Get,Set}FInfo and accompanying objects
Jack Jansen <jack.jansen@cwi.nl>
parents:
2748
diff
changeset
|
102 /* ---------------------------------------------------------------- */ |
|
f9b1069a3e26
Added interfaces to {Get,Set}FInfo and accompanying objects
Jack Jansen <jack.jansen@cwi.nl>
parents:
2748
diff
changeset
|
103 /* Declarations for objects of type FInfo */ |
|
f9b1069a3e26
Added interfaces to {Get,Set}FInfo and accompanying objects
Jack Jansen <jack.jansen@cwi.nl>
parents:
2748
diff
changeset
|
104 |
|
f9b1069a3e26
Added interfaces to {Get,Set}FInfo and accompanying objects
Jack Jansen <jack.jansen@cwi.nl>
parents:
2748
diff
changeset
|
105 typedef struct { |
| 5071 | 106 PyObject_HEAD |
|
2909
f9b1069a3e26
Added interfaces to {Get,Set}FInfo and accompanying objects
Jack Jansen <jack.jansen@cwi.nl>
parents:
2748
diff
changeset
|
107 FInfo finfo; |
|
f9b1069a3e26
Added interfaces to {Get,Set}FInfo and accompanying objects
Jack Jansen <jack.jansen@cwi.nl>
parents:
2748
diff
changeset
|
108 } mfsiobject; |
|
f9b1069a3e26
Added interfaces to {Get,Set}FInfo and accompanying objects
Jack Jansen <jack.jansen@cwi.nl>
parents:
2748
diff
changeset
|
109 |
| 5071 | 110 staticforward PyTypeObject Mfsitype; |
|
2909
f9b1069a3e26
Added interfaces to {Get,Set}FInfo and accompanying objects
Jack Jansen <jack.jansen@cwi.nl>
parents:
2748
diff
changeset
|
111 |
|
f9b1069a3e26
Added interfaces to {Get,Set}FInfo and accompanying objects
Jack Jansen <jack.jansen@cwi.nl>
parents:
2748
diff
changeset
|
112 #define is_mfsiobject(v) ((v)->ob_type == &Mfsitype) |
|
f9b1069a3e26
Added interfaces to {Get,Set}FInfo and accompanying objects
Jack Jansen <jack.jansen@cwi.nl>
parents:
2748
diff
changeset
|
113 |
|
f9b1069a3e26
Added interfaces to {Get,Set}FInfo and accompanying objects
Jack Jansen <jack.jansen@cwi.nl>
parents:
2748
diff
changeset
|
114 |
|
18434
f7f076bfcae9
Implemented minimal FSRef support, plus conversion between FSRefs, FSSpecs and pathnames where applicable.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17864
diff
changeset
|
115 staticforward mfssobject *newmfssobject(FSSpec *fss); /* Forward */ |
|
f7f076bfcae9
Implemented minimal FSRef support, plus conversion between FSRefs, FSSpecs and pathnames where applicable.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17864
diff
changeset
|
116 staticforward mfsrobject *newmfsrobject(FSRef *fsr); /* Forward */ |
|
2254
67e8ef698a42
added (method) casts and 1995 copyright
Guido van Rossum <guido@python.org>
parents:
2249
diff
changeset
|
117 |
| 2249 | 118 /* ---------------------------------------------------------------- */ |
|
2180
9b451c84a7bf
Initial version of FSSpec and Alias code. Non-functional as of now.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
119 |
| 5071 | 120 static PyObject * |
|
19066
a1b4f3a1ee07
- Don't return mac-style pathnames in unix-Python.
Jack Jansen <jack.jansen@cwi.nl>
parents:
19030
diff
changeset
|
121 mfsa_Resolve(mfsaobject *self, PyObject *args) |
|
2180
9b451c84a7bf
Initial version of FSSpec and Alias code. Non-functional as of now.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
122 { |
| 2249 | 123 FSSpec from, *fromp, result; |
| 124 Boolean changed; | |
| 125 OSErr err; | |
|
2180
9b451c84a7bf
Initial version of FSSpec and Alias code. Non-functional as of now.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
126 |
| 2249 | 127 from.name[0] = 0; |
| 5071 | 128 if (!PyArg_ParseTuple(args, "|O&", PyMac_GetFSSpec, &from)) |
| 2249 | 129 return NULL; |
| 130 if (from.name[0] ) | |
| 131 fromp = &from; | |
| 132 else | |
| 133 fromp = NULL; | |
| 134 err = ResolveAlias(fromp, self->alias, &result, &changed); | |
|
5743
c606dd61544a
Added NewAliasMinimalFromFullPath(), and allow alias.Resolve() to return
Jack Jansen <jack.jansen@cwi.nl>
parents:
5429
diff
changeset
|
135 if ( err && err != fnfErr ) { |
| 2249 | 136 PyErr_Mac(ErrorObject, err); |
|
2180
9b451c84a7bf
Initial version of FSSpec and Alias code. Non-functional as of now.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
137 return NULL; |
| 2249 | 138 } |
| 5071 | 139 return Py_BuildValue("(Oi)", newmfssobject(&result), (int)changed); |
| 2249 | 140 } |
|
2180
9b451c84a7bf
Initial version of FSSpec and Alias code. Non-functional as of now.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
141 |
| 5071 | 142 static PyObject * |
|
19066
a1b4f3a1ee07
- Don't return mac-style pathnames in unix-Python.
Jack Jansen <jack.jansen@cwi.nl>
parents:
19030
diff
changeset
|
143 mfsa_GetInfo(mfsaobject *self, PyObject *args) |
| 2249 | 144 { |
| 145 Str63 value; | |
| 146 int i; | |
| 147 OSErr err; | |
| 148 | |
| 5071 | 149 if (!PyArg_ParseTuple(args, "i", &i)) |
| 2249 | 150 return NULL; |
| 151 err = GetAliasInfo(self->alias, (AliasInfoType)i, value); | |
| 152 if ( err ) { | |
| 153 PyErr_Mac(ErrorObject, err); | |
| 154 return 0; | |
| 155 } | |
| 5071 | 156 return PyString_FromStringAndSize((char *)&value[1], value[0]); |
|
2180
9b451c84a7bf
Initial version of FSSpec and Alias code. Non-functional as of now.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
157 } |
|
9b451c84a7bf
Initial version of FSSpec and Alias code. Non-functional as of now.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
158 |
| 5071 | 159 static PyObject * |
|
19066
a1b4f3a1ee07
- Don't return mac-style pathnames in unix-Python.
Jack Jansen <jack.jansen@cwi.nl>
parents:
19030
diff
changeset
|
160 mfsa_Update(mfsaobject *self, PyObject *args) |
|
2180
9b451c84a7bf
Initial version of FSSpec and Alias code. Non-functional as of now.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
161 { |
| 2249 | 162 FSSpec target, fromfile, *fromfilep; |
| 163 OSErr err; | |
| 164 Boolean changed; | |
| 165 | |
| 166 fromfile.name[0] = 0; | |
| 5071 | 167 if (!PyArg_ParseTuple(args, "O&|O&", PyMac_GetFSSpec, &target, |
| 2249 | 168 PyMac_GetFSSpec, &fromfile)) |
| 169 return NULL; | |
| 170 if ( fromfile.name[0] ) | |
| 171 fromfilep = &fromfile; | |
| 172 else | |
| 173 fromfilep = NULL; | |
| 174 err = UpdateAlias(fromfilep, &target, self->alias, &changed); | |
| 175 if ( err ) { | |
| 176 PyErr_Mac(ErrorObject, err); | |
| 177 return 0; | |
| 178 } | |
| 5071 | 179 return Py_BuildValue("i", (int)changed); |
| 2249 | 180 } |
| 181 | |
| 5071 | 182 static struct PyMethodDef mfsa_methods[] = { |
| 183 {"Resolve", (PyCFunction)mfsa_Resolve, 1}, | |
| 184 {"GetInfo", (PyCFunction)mfsa_GetInfo, 1}, | |
| 185 {"Update", (PyCFunction)mfsa_Update, 1}, | |
| 2249 | 186 |
| 187 {NULL, NULL} /* sentinel */ | |
| 188 }; | |
| 189 | |
| 190 /* ---------- */ | |
| 191 | |
| 5071 | 192 static PyObject * |
|
19066
a1b4f3a1ee07
- Don't return mac-style pathnames in unix-Python.
Jack Jansen <jack.jansen@cwi.nl>
parents:
19030
diff
changeset
|
193 mfsa_getattr(mfsaobject *self, char *name) |
| 2249 | 194 { |
|
2319
1e7207128167
Added RawFSSpec and RawAlias methods which turn their string arguments
Jack Jansen <jack.jansen@cwi.nl>
parents:
2275
diff
changeset
|
195 if ( strcmp(name, "data") == 0 ) { |
|
1e7207128167
Added RawFSSpec and RawAlias methods which turn their string arguments
Jack Jansen <jack.jansen@cwi.nl>
parents:
2275
diff
changeset
|
196 int size; |
|
1e7207128167
Added RawFSSpec and RawAlias methods which turn their string arguments
Jack Jansen <jack.jansen@cwi.nl>
parents:
2275
diff
changeset
|
197 PyObject *rv; |
|
1e7207128167
Added RawFSSpec and RawAlias methods which turn their string arguments
Jack Jansen <jack.jansen@cwi.nl>
parents:
2275
diff
changeset
|
198 |
|
1e7207128167
Added RawFSSpec and RawAlias methods which turn their string arguments
Jack Jansen <jack.jansen@cwi.nl>
parents:
2275
diff
changeset
|
199 size = GetHandleSize((Handle)self->alias); |
|
1e7207128167
Added RawFSSpec and RawAlias methods which turn their string arguments
Jack Jansen <jack.jansen@cwi.nl>
parents:
2275
diff
changeset
|
200 HLock((Handle)self->alias); |
|
1e7207128167
Added RawFSSpec and RawAlias methods which turn their string arguments
Jack Jansen <jack.jansen@cwi.nl>
parents:
2275
diff
changeset
|
201 rv = PyString_FromStringAndSize(*(Handle)self->alias, size); |
|
1e7207128167
Added RawFSSpec and RawAlias methods which turn their string arguments
Jack Jansen <jack.jansen@cwi.nl>
parents:
2275
diff
changeset
|
202 HUnlock((Handle)self->alias); |
|
1e7207128167
Added RawFSSpec and RawAlias methods which turn their string arguments
Jack Jansen <jack.jansen@cwi.nl>
parents:
2275
diff
changeset
|
203 return rv; |
|
1e7207128167
Added RawFSSpec and RawAlias methods which turn their string arguments
Jack Jansen <jack.jansen@cwi.nl>
parents:
2275
diff
changeset
|
204 } |
| 5071 | 205 return Py_FindMethod(mfsa_methods, (PyObject *)self, name); |
| 2249 | 206 } |
| 207 | |
|
13547
db963a615bc9
ANSIfication step 2: make sure all needed prototypes are available, and all needed
Jack Jansen <jack.jansen@cwi.nl>
parents:
13398
diff
changeset
|
208 static mfsaobject * |
|
db963a615bc9
ANSIfication step 2: make sure all needed prototypes are available, and all needed
Jack Jansen <jack.jansen@cwi.nl>
parents:
13398
diff
changeset
|
209 newmfsaobject(AliasHandle alias) |
| 2249 | 210 { |
| 211 mfsaobject *self; | |
| 212 | |
| 5071 | 213 self = PyObject_NEW(mfsaobject, &Mfsatype); |
| 2249 | 214 if (self == NULL) |
| 215 return NULL; | |
| 216 self->alias = alias; | |
| 217 return self; | |
| 218 } | |
| 219 | |
| 220 | |
| 221 static void | |
|
19066
a1b4f3a1ee07
- Don't return mac-style pathnames in unix-Python.
Jack Jansen <jack.jansen@cwi.nl>
parents:
19030
diff
changeset
|
222 mfsa_dealloc(mfsaobject *self) |
| 2249 | 223 { |
| 224 #if 0 | |
| 225 if ( self->alias ) { | |
| 226 should we do something here? | |
| 227 } | |
| 228 #endif | |
| 229 | |
| 5071 | 230 PyMem_DEL(self); |
| 2249 | 231 } |
| 232 | |
| 5071 | 233 statichere PyTypeObject Mfsatype = { |
| 234 PyObject_HEAD_INIT(&PyType_Type) | |
| 2249 | 235 0, /*ob_size*/ |
| 236 "Alias", /*tp_name*/ | |
| 237 sizeof(mfsaobject), /*tp_basicsize*/ | |
| 238 0, /*tp_itemsize*/ | |
| 239 /* methods */ | |
| 240 (destructor)mfsa_dealloc, /*tp_dealloc*/ | |
|
2408
77eb63716b4f
replace %#s with portable solution
Guido van Rossum <guido@python.org>
parents:
2400
diff
changeset
|
241 (printfunc)0, /*tp_print*/ |
| 2249 | 242 (getattrfunc)mfsa_getattr, /*tp_getattr*/ |
|
2408
77eb63716b4f
replace %#s with portable solution
Guido van Rossum <guido@python.org>
parents:
2400
diff
changeset
|
243 (setattrfunc)0, /*tp_setattr*/ |
|
77eb63716b4f
replace %#s with portable solution
Guido van Rossum <guido@python.org>
parents:
2400
diff
changeset
|
244 (cmpfunc)0, /*tp_compare*/ |
|
77eb63716b4f
replace %#s with portable solution
Guido van Rossum <guido@python.org>
parents:
2400
diff
changeset
|
245 (reprfunc)0, /*tp_repr*/ |
|
77eb63716b4f
replace %#s with portable solution
Guido van Rossum <guido@python.org>
parents:
2400
diff
changeset
|
246 0, /*tp_as_number*/ |
|
77eb63716b4f
replace %#s with portable solution
Guido van Rossum <guido@python.org>
parents:
2400
diff
changeset
|
247 0, /*tp_as_sequence*/ |
|
77eb63716b4f
replace %#s with portable solution
Guido van Rossum <guido@python.org>
parents:
2400
diff
changeset
|
248 0, /*tp_as_mapping*/ |
|
77eb63716b4f
replace %#s with portable solution
Guido van Rossum <guido@python.org>
parents:
2400
diff
changeset
|
249 (hashfunc)0, /*tp_hash*/ |
| 2249 | 250 }; |
| 251 | |
| 252 /* End of code for Alias objects */ | |
| 253 /* -------------------------------------------------------- */ | |
| 254 | |
|
2909
f9b1069a3e26
Added interfaces to {Get,Set}FInfo and accompanying objects
Jack Jansen <jack.jansen@cwi.nl>
parents:
2748
diff
changeset
|
255 /* ---------------------------------------------------------------- */ |
|
f9b1069a3e26
Added interfaces to {Get,Set}FInfo and accompanying objects
Jack Jansen <jack.jansen@cwi.nl>
parents:
2748
diff
changeset
|
256 |
| 5071 | 257 static struct PyMethodDef mfsi_methods[] = { |
|
2909
f9b1069a3e26
Added interfaces to {Get,Set}FInfo and accompanying objects
Jack Jansen <jack.jansen@cwi.nl>
parents:
2748
diff
changeset
|
258 |
|
f9b1069a3e26
Added interfaces to {Get,Set}FInfo and accompanying objects
Jack Jansen <jack.jansen@cwi.nl>
parents:
2748
diff
changeset
|
259 {NULL, NULL} /* sentinel */ |
|
f9b1069a3e26
Added interfaces to {Get,Set}FInfo and accompanying objects
Jack Jansen <jack.jansen@cwi.nl>
parents:
2748
diff
changeset
|
260 }; |
|
f9b1069a3e26
Added interfaces to {Get,Set}FInfo and accompanying objects
Jack Jansen <jack.jansen@cwi.nl>
parents:
2748
diff
changeset
|
261 |
|
f9b1069a3e26
Added interfaces to {Get,Set}FInfo and accompanying objects
Jack Jansen <jack.jansen@cwi.nl>
parents:
2748
diff
changeset
|
262 /* ---------- */ |
|
f9b1069a3e26
Added interfaces to {Get,Set}FInfo and accompanying objects
Jack Jansen <jack.jansen@cwi.nl>
parents:
2748
diff
changeset
|
263 |
|
f9b1069a3e26
Added interfaces to {Get,Set}FInfo and accompanying objects
Jack Jansen <jack.jansen@cwi.nl>
parents:
2748
diff
changeset
|
264 static mfsiobject * |
|
19066
a1b4f3a1ee07
- Don't return mac-style pathnames in unix-Python.
Jack Jansen <jack.jansen@cwi.nl>
parents:
19030
diff
changeset
|
265 newmfsiobject(void) |
|
2909
f9b1069a3e26
Added interfaces to {Get,Set}FInfo and accompanying objects
Jack Jansen <jack.jansen@cwi.nl>
parents:
2748
diff
changeset
|
266 { |
|
f9b1069a3e26
Added interfaces to {Get,Set}FInfo and accompanying objects
Jack Jansen <jack.jansen@cwi.nl>
parents:
2748
diff
changeset
|
267 mfsiobject *self; |
|
f9b1069a3e26
Added interfaces to {Get,Set}FInfo and accompanying objects
Jack Jansen <jack.jansen@cwi.nl>
parents:
2748
diff
changeset
|
268 |
| 5071 | 269 self = PyObject_NEW(mfsiobject, &Mfsitype); |
|
2909
f9b1069a3e26
Added interfaces to {Get,Set}FInfo and accompanying objects
Jack Jansen <jack.jansen@cwi.nl>
parents:
2748
diff
changeset
|
270 if (self == NULL) |
|
f9b1069a3e26
Added interfaces to {Get,Set}FInfo and accompanying objects
Jack Jansen <jack.jansen@cwi.nl>
parents:
2748
diff
changeset
|
271 return NULL; |
|
f9b1069a3e26
Added interfaces to {Get,Set}FInfo and accompanying objects
Jack Jansen <jack.jansen@cwi.nl>
parents:
2748
diff
changeset
|
272 memset((char *)&self->finfo, '\0', sizeof(self->finfo)); |
|
f9b1069a3e26
Added interfaces to {Get,Set}FInfo and accompanying objects
Jack Jansen <jack.jansen@cwi.nl>
parents:
2748
diff
changeset
|
273 return self; |
|
f9b1069a3e26
Added interfaces to {Get,Set}FInfo and accompanying objects
Jack Jansen <jack.jansen@cwi.nl>
parents:
2748
diff
changeset
|
274 } |
|
f9b1069a3e26
Added interfaces to {Get,Set}FInfo and accompanying objects
Jack Jansen <jack.jansen@cwi.nl>
parents:
2748
diff
changeset
|
275 |
|
f9b1069a3e26
Added interfaces to {Get,Set}FInfo and accompanying objects
Jack Jansen <jack.jansen@cwi.nl>
parents:
2748
diff
changeset
|
276 static void |
|
19066
a1b4f3a1ee07
- Don't return mac-style pathnames in unix-Python.
Jack Jansen <jack.jansen@cwi.nl>
parents:
19030
diff
changeset
|
277 mfsi_dealloc(mfsiobject *self) |
|
2909
f9b1069a3e26
Added interfaces to {Get,Set}FInfo and accompanying objects
Jack Jansen <jack.jansen@cwi.nl>
parents:
2748
diff
changeset
|
278 { |
| 5071 | 279 PyMem_DEL(self); |
|
2909
f9b1069a3e26
Added interfaces to {Get,Set}FInfo and accompanying objects
Jack Jansen <jack.jansen@cwi.nl>
parents:
2748
diff
changeset
|
280 } |
|
f9b1069a3e26
Added interfaces to {Get,Set}FInfo and accompanying objects
Jack Jansen <jack.jansen@cwi.nl>
parents:
2748
diff
changeset
|
281 |
| 5071 | 282 static PyObject * |
|
19066
a1b4f3a1ee07
- Don't return mac-style pathnames in unix-Python.
Jack Jansen <jack.jansen@cwi.nl>
parents:
19030
diff
changeset
|
283 mfsi_getattr(mfsiobject *self, char *name) |
|
2909
f9b1069a3e26
Added interfaces to {Get,Set}FInfo and accompanying objects
Jack Jansen <jack.jansen@cwi.nl>
parents:
2748
diff
changeset
|
284 { |
|
f9b1069a3e26
Added interfaces to {Get,Set}FInfo and accompanying objects
Jack Jansen <jack.jansen@cwi.nl>
parents:
2748
diff
changeset
|
285 if ( strcmp(name, "Type") == 0 ) |
|
f9b1069a3e26
Added interfaces to {Get,Set}FInfo and accompanying objects
Jack Jansen <jack.jansen@cwi.nl>
parents:
2748
diff
changeset
|
286 return PyMac_BuildOSType(self->finfo.fdType); |
|
f9b1069a3e26
Added interfaces to {Get,Set}FInfo and accompanying objects
Jack Jansen <jack.jansen@cwi.nl>
parents:
2748
diff
changeset
|
287 else if ( strcmp(name, "Creator") == 0 ) |
|
f9b1069a3e26
Added interfaces to {Get,Set}FInfo and accompanying objects
Jack Jansen <jack.jansen@cwi.nl>
parents:
2748
diff
changeset
|
288 return PyMac_BuildOSType(self->finfo.fdCreator); |
|
f9b1069a3e26
Added interfaces to {Get,Set}FInfo and accompanying objects
Jack Jansen <jack.jansen@cwi.nl>
parents:
2748
diff
changeset
|
289 else if ( strcmp(name, "Flags") == 0 ) |
|
f9b1069a3e26
Added interfaces to {Get,Set}FInfo and accompanying objects
Jack Jansen <jack.jansen@cwi.nl>
parents:
2748
diff
changeset
|
290 return Py_BuildValue("i", (int)self->finfo.fdFlags); |
|
f9b1069a3e26
Added interfaces to {Get,Set}FInfo and accompanying objects
Jack Jansen <jack.jansen@cwi.nl>
parents:
2748
diff
changeset
|
291 else if ( strcmp(name, "Location") == 0 ) |
|
f9b1069a3e26
Added interfaces to {Get,Set}FInfo and accompanying objects
Jack Jansen <jack.jansen@cwi.nl>
parents:
2748
diff
changeset
|
292 return PyMac_BuildPoint(self->finfo.fdLocation); |
|
f9b1069a3e26
Added interfaces to {Get,Set}FInfo and accompanying objects
Jack Jansen <jack.jansen@cwi.nl>
parents:
2748
diff
changeset
|
293 else if ( strcmp(name, "Fldr") == 0 ) |
|
f9b1069a3e26
Added interfaces to {Get,Set}FInfo and accompanying objects
Jack Jansen <jack.jansen@cwi.nl>
parents:
2748
diff
changeset
|
294 return Py_BuildValue("i", (int)self->finfo.fdFldr); |
|
f9b1069a3e26
Added interfaces to {Get,Set}FInfo and accompanying objects
Jack Jansen <jack.jansen@cwi.nl>
parents:
2748
diff
changeset
|
295 else |
| 5071 | 296 return Py_FindMethod(mfsi_methods, (PyObject *)self, name); |
|
2909
f9b1069a3e26
Added interfaces to {Get,Set}FInfo and accompanying objects
Jack Jansen <jack.jansen@cwi.nl>
parents:
2748
diff
changeset
|
297 } |
|
f9b1069a3e26
Added interfaces to {Get,Set}FInfo and accompanying objects
Jack Jansen <jack.jansen@cwi.nl>
parents:
2748
diff
changeset
|
298 |
|
f9b1069a3e26
Added interfaces to {Get,Set}FInfo and accompanying objects
Jack Jansen <jack.jansen@cwi.nl>
parents:
2748
diff
changeset
|
299 |
|
f9b1069a3e26
Added interfaces to {Get,Set}FInfo and accompanying objects
Jack Jansen <jack.jansen@cwi.nl>
parents:
2748
diff
changeset
|
300 static int |
|
19066
a1b4f3a1ee07
- Don't return mac-style pathnames in unix-Python.
Jack Jansen <jack.jansen@cwi.nl>
parents:
19030
diff
changeset
|
301 mfsi_setattr(mfsiobject *self, char *name, PyObject *v) |
|
2909
f9b1069a3e26
Added interfaces to {Get,Set}FInfo and accompanying objects
Jack Jansen <jack.jansen@cwi.nl>
parents:
2748
diff
changeset
|
302 { |
|
f9b1069a3e26
Added interfaces to {Get,Set}FInfo and accompanying objects
Jack Jansen <jack.jansen@cwi.nl>
parents:
2748
diff
changeset
|
303 int rv; |
|
f9b1069a3e26
Added interfaces to {Get,Set}FInfo and accompanying objects
Jack Jansen <jack.jansen@cwi.nl>
parents:
2748
diff
changeset
|
304 int i; |
|
f9b1069a3e26
Added interfaces to {Get,Set}FInfo and accompanying objects
Jack Jansen <jack.jansen@cwi.nl>
parents:
2748
diff
changeset
|
305 |
|
f9b1069a3e26
Added interfaces to {Get,Set}FInfo and accompanying objects
Jack Jansen <jack.jansen@cwi.nl>
parents:
2748
diff
changeset
|
306 if ( v == NULL ) { |
| 5071 | 307 PyErr_SetString(PyExc_AttributeError, "Cannot delete attribute"); |
|
2909
f9b1069a3e26
Added interfaces to {Get,Set}FInfo and accompanying objects
Jack Jansen <jack.jansen@cwi.nl>
parents:
2748
diff
changeset
|
308 return -1; |
|
f9b1069a3e26
Added interfaces to {Get,Set}FInfo and accompanying objects
Jack Jansen <jack.jansen@cwi.nl>
parents:
2748
diff
changeset
|
309 } |
|
f9b1069a3e26
Added interfaces to {Get,Set}FInfo and accompanying objects
Jack Jansen <jack.jansen@cwi.nl>
parents:
2748
diff
changeset
|
310 if ( strcmp(name, "Type") == 0 ) |
|
f9b1069a3e26
Added interfaces to {Get,Set}FInfo and accompanying objects
Jack Jansen <jack.jansen@cwi.nl>
parents:
2748
diff
changeset
|
311 rv = PyMac_GetOSType(v, &self->finfo.fdType); |
|
f9b1069a3e26
Added interfaces to {Get,Set}FInfo and accompanying objects
Jack Jansen <jack.jansen@cwi.nl>
parents:
2748
diff
changeset
|
312 else if ( strcmp(name, "Creator") == 0 ) |
|
f9b1069a3e26
Added interfaces to {Get,Set}FInfo and accompanying objects
Jack Jansen <jack.jansen@cwi.nl>
parents:
2748
diff
changeset
|
313 rv = PyMac_GetOSType(v, &self->finfo.fdCreator); |
|
f9b1069a3e26
Added interfaces to {Get,Set}FInfo and accompanying objects
Jack Jansen <jack.jansen@cwi.nl>
parents:
2748
diff
changeset
|
314 else if ( strcmp(name, "Flags") == 0 ) { |
|
f9b1069a3e26
Added interfaces to {Get,Set}FInfo and accompanying objects
Jack Jansen <jack.jansen@cwi.nl>
parents:
2748
diff
changeset
|
315 rv = PyArg_Parse(v, "i", &i); |
|
f9b1069a3e26
Added interfaces to {Get,Set}FInfo and accompanying objects
Jack Jansen <jack.jansen@cwi.nl>
parents:
2748
diff
changeset
|
316 self->finfo.fdFlags = (short)i; |
|
f9b1069a3e26
Added interfaces to {Get,Set}FInfo and accompanying objects
Jack Jansen <jack.jansen@cwi.nl>
parents:
2748
diff
changeset
|
317 } else if ( strcmp(name, "Location") == 0 ) |
|
f9b1069a3e26
Added interfaces to {Get,Set}FInfo and accompanying objects
Jack Jansen <jack.jansen@cwi.nl>
parents:
2748
diff
changeset
|
318 rv = PyMac_GetPoint(v, &self->finfo.fdLocation); |
|
f9b1069a3e26
Added interfaces to {Get,Set}FInfo and accompanying objects
Jack Jansen <jack.jansen@cwi.nl>
parents:
2748
diff
changeset
|
319 else if ( strcmp(name, "Fldr") == 0 ) { |
|
f9b1069a3e26
Added interfaces to {Get,Set}FInfo and accompanying objects
Jack Jansen <jack.jansen@cwi.nl>
parents:
2748
diff
changeset
|
320 rv = PyArg_Parse(v, "i", &i); |
|
f9b1069a3e26
Added interfaces to {Get,Set}FInfo and accompanying objects
Jack Jansen <jack.jansen@cwi.nl>
parents:
2748
diff
changeset
|
321 self->finfo.fdFldr = (short)i; |
|
f9b1069a3e26
Added interfaces to {Get,Set}FInfo and accompanying objects
Jack Jansen <jack.jansen@cwi.nl>
parents:
2748
diff
changeset
|
322 } else { |
| 5071 | 323 PyErr_SetString(PyExc_AttributeError, "No such attribute"); |
|
2909
f9b1069a3e26
Added interfaces to {Get,Set}FInfo and accompanying objects
Jack Jansen <jack.jansen@cwi.nl>
parents:
2748
diff
changeset
|
324 return -1; |
|
f9b1069a3e26
Added interfaces to {Get,Set}FInfo and accompanying objects
Jack Jansen <jack.jansen@cwi.nl>
parents:
2748
diff
changeset
|
325 } |
|
f9b1069a3e26
Added interfaces to {Get,Set}FInfo and accompanying objects
Jack Jansen <jack.jansen@cwi.nl>
parents:
2748
diff
changeset
|
326 if (rv) |
|
f9b1069a3e26
Added interfaces to {Get,Set}FInfo and accompanying objects
Jack Jansen <jack.jansen@cwi.nl>
parents:
2748
diff
changeset
|
327 return 0; |
|
f9b1069a3e26
Added interfaces to {Get,Set}FInfo and accompanying objects
Jack Jansen <jack.jansen@cwi.nl>
parents:
2748
diff
changeset
|
328 return -1; |
|
f9b1069a3e26
Added interfaces to {Get,Set}FInfo and accompanying objects
Jack Jansen <jack.jansen@cwi.nl>
parents:
2748
diff
changeset
|
329 } |
|
f9b1069a3e26
Added interfaces to {Get,Set}FInfo and accompanying objects
Jack Jansen <jack.jansen@cwi.nl>
parents:
2748
diff
changeset
|
330 |
|
f9b1069a3e26
Added interfaces to {Get,Set}FInfo and accompanying objects
Jack Jansen <jack.jansen@cwi.nl>
parents:
2748
diff
changeset
|
331 |
| 5071 | 332 static PyTypeObject Mfsitype = { |
| 333 PyObject_HEAD_INIT(&PyType_Type) | |
|
2909
f9b1069a3e26
Added interfaces to {Get,Set}FInfo and accompanying objects
Jack Jansen <jack.jansen@cwi.nl>
parents:
2748
diff
changeset
|
334 0, /*ob_size*/ |
|
6330
172c7febd755
Export type objects to Python
Jack Jansen <jack.jansen@cwi.nl>
parents:
5743
diff
changeset
|
335 "FInfo", /*tp_name*/ |
|
2909
f9b1069a3e26
Added interfaces to {Get,Set}FInfo and accompanying objects
Jack Jansen <jack.jansen@cwi.nl>
parents:
2748
diff
changeset
|
336 sizeof(mfsiobject), /*tp_basicsize*/ |
|
f9b1069a3e26
Added interfaces to {Get,Set}FInfo and accompanying objects
Jack Jansen <jack.jansen@cwi.nl>
parents:
2748
diff
changeset
|
337 0, /*tp_itemsize*/ |
|
f9b1069a3e26
Added interfaces to {Get,Set}FInfo and accompanying objects
Jack Jansen <jack.jansen@cwi.nl>
parents:
2748
diff
changeset
|
338 /* methods */ |
|
f9b1069a3e26
Added interfaces to {Get,Set}FInfo and accompanying objects
Jack Jansen <jack.jansen@cwi.nl>
parents:
2748
diff
changeset
|
339 (destructor)mfsi_dealloc, /*tp_dealloc*/ |
|
f9b1069a3e26
Added interfaces to {Get,Set}FInfo and accompanying objects
Jack Jansen <jack.jansen@cwi.nl>
parents:
2748
diff
changeset
|
340 (printfunc)0, /*tp_print*/ |
|
f9b1069a3e26
Added interfaces to {Get,Set}FInfo and accompanying objects
Jack Jansen <jack.jansen@cwi.nl>
parents:
2748
diff
changeset
|
341 (getattrfunc)mfsi_getattr, /*tp_getattr*/ |
|
f9b1069a3e26
Added interfaces to {Get,Set}FInfo and accompanying objects
Jack Jansen <jack.jansen@cwi.nl>
parents:
2748
diff
changeset
|
342 (setattrfunc)mfsi_setattr, /*tp_setattr*/ |
|
f9b1069a3e26
Added interfaces to {Get,Set}FInfo and accompanying objects
Jack Jansen <jack.jansen@cwi.nl>
parents:
2748
diff
changeset
|
343 (cmpfunc)0, /*tp_compare*/ |
|
f9b1069a3e26
Added interfaces to {Get,Set}FInfo and accompanying objects
Jack Jansen <jack.jansen@cwi.nl>
parents:
2748
diff
changeset
|
344 (reprfunc)0, /*tp_repr*/ |
|
f9b1069a3e26
Added interfaces to {Get,Set}FInfo and accompanying objects
Jack Jansen <jack.jansen@cwi.nl>
parents:
2748
diff
changeset
|
345 0, /*tp_as_number*/ |
|
f9b1069a3e26
Added interfaces to {Get,Set}FInfo and accompanying objects
Jack Jansen <jack.jansen@cwi.nl>
parents:
2748
diff
changeset
|
346 0, /*tp_as_sequence*/ |
|
f9b1069a3e26
Added interfaces to {Get,Set}FInfo and accompanying objects
Jack Jansen <jack.jansen@cwi.nl>
parents:
2748
diff
changeset
|
347 0, /*tp_as_mapping*/ |
|
f9b1069a3e26
Added interfaces to {Get,Set}FInfo and accompanying objects
Jack Jansen <jack.jansen@cwi.nl>
parents:
2748
diff
changeset
|
348 (hashfunc)0, /*tp_hash*/ |
|
f9b1069a3e26
Added interfaces to {Get,Set}FInfo and accompanying objects
Jack Jansen <jack.jansen@cwi.nl>
parents:
2748
diff
changeset
|
349 }; |
|
f9b1069a3e26
Added interfaces to {Get,Set}FInfo and accompanying objects
Jack Jansen <jack.jansen@cwi.nl>
parents:
2748
diff
changeset
|
350 |
|
f9b1069a3e26
Added interfaces to {Get,Set}FInfo and accompanying objects
Jack Jansen <jack.jansen@cwi.nl>
parents:
2748
diff
changeset
|
351 /* End of code for FInfo object objects */ |
|
f9b1069a3e26
Added interfaces to {Get,Set}FInfo and accompanying objects
Jack Jansen <jack.jansen@cwi.nl>
parents:
2748
diff
changeset
|
352 /* -------------------------------------------------------- */ |
|
f9b1069a3e26
Added interfaces to {Get,Set}FInfo and accompanying objects
Jack Jansen <jack.jansen@cwi.nl>
parents:
2748
diff
changeset
|
353 |
|
f9b1069a3e26
Added interfaces to {Get,Set}FInfo and accompanying objects
Jack Jansen <jack.jansen@cwi.nl>
parents:
2748
diff
changeset
|
354 |
| 2249 | 355 /* |
|
18434
f7f076bfcae9
Implemented minimal FSRef support, plus conversion between FSRefs, FSSpecs and pathnames where applicable.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17864
diff
changeset
|
356 ** Helper routines for the FSRef and FSSpec creators in macglue.c |
|
f7f076bfcae9
Implemented minimal FSRef support, plus conversion between FSRefs, FSSpecs and pathnames where applicable.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17864
diff
changeset
|
357 ** They return an FSSpec/FSRef if the Python object encapsulating |
|
f7f076bfcae9
Implemented minimal FSRef support, plus conversion between FSRefs, FSSpecs and pathnames where applicable.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17864
diff
changeset
|
358 ** either is passed. They return a boolean success indicator. |
|
f7f076bfcae9
Implemented minimal FSRef support, plus conversion between FSRefs, FSSpecs and pathnames where applicable.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17864
diff
changeset
|
359 ** Note that they do not set an exception on failure, they're only |
|
f7f076bfcae9
Implemented minimal FSRef support, plus conversion between FSRefs, FSSpecs and pathnames where applicable.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17864
diff
changeset
|
360 ** helper routines. |
| 2249 | 361 */ |
|
18434
f7f076bfcae9
Implemented minimal FSRef support, plus conversion between FSRefs, FSSpecs and pathnames where applicable.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17864
diff
changeset
|
362 static int |
|
f7f076bfcae9
Implemented minimal FSRef support, plus conversion between FSRefs, FSSpecs and pathnames where applicable.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17864
diff
changeset
|
363 _mfs_GetFSSpecFromFSSpec(PyObject *self, FSSpec *fssp) |
|
f7f076bfcae9
Implemented minimal FSRef support, plus conversion between FSRefs, FSSpecs and pathnames where applicable.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17864
diff
changeset
|
364 { |
|
f7f076bfcae9
Implemented minimal FSRef support, plus conversion between FSRefs, FSSpecs and pathnames where applicable.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17864
diff
changeset
|
365 if ( is_mfssobject(self) ) { |
|
f7f076bfcae9
Implemented minimal FSRef support, plus conversion between FSRefs, FSSpecs and pathnames where applicable.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17864
diff
changeset
|
366 *fssp = ((mfssobject *)self)->fsspec; |
|
f7f076bfcae9
Implemented minimal FSRef support, plus conversion between FSRefs, FSSpecs and pathnames where applicable.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17864
diff
changeset
|
367 return 1; |
|
f7f076bfcae9
Implemented minimal FSRef support, plus conversion between FSRefs, FSSpecs and pathnames where applicable.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17864
diff
changeset
|
368 } |
|
f7f076bfcae9
Implemented minimal FSRef support, plus conversion between FSRefs, FSSpecs and pathnames where applicable.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17864
diff
changeset
|
369 return 0; |
|
f7f076bfcae9
Implemented minimal FSRef support, plus conversion between FSRefs, FSSpecs and pathnames where applicable.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17864
diff
changeset
|
370 } |
|
f7f076bfcae9
Implemented minimal FSRef support, plus conversion between FSRefs, FSSpecs and pathnames where applicable.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17864
diff
changeset
|
371 |
|
f7f076bfcae9
Implemented minimal FSRef support, plus conversion between FSRefs, FSSpecs and pathnames where applicable.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17864
diff
changeset
|
372 /* Return an FSSpec if this is an FSref */ |
|
f7f076bfcae9
Implemented minimal FSRef support, plus conversion between FSRefs, FSSpecs and pathnames where applicable.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17864
diff
changeset
|
373 static int |
|
f7f076bfcae9
Implemented minimal FSRef support, plus conversion between FSRefs, FSSpecs and pathnames where applicable.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17864
diff
changeset
|
374 _mfs_GetFSSpecFromFSRef(PyObject *self, FSSpec *fssp) |
| 2249 | 375 { |
|
18962
d7590122f9a2
Merging appropriate 2.1.1 fixes back into the main trunk.
Jack Jansen <jack.jansen@cwi.nl>
parents:
18434
diff
changeset
|
376 #if !TARGET_API_MAC_OS8 |
|
18434
f7f076bfcae9
Implemented minimal FSRef support, plus conversion between FSRefs, FSSpecs and pathnames where applicable.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17864
diff
changeset
|
377 static FSRef *fsrp; |
|
f7f076bfcae9
Implemented minimal FSRef support, plus conversion between FSRefs, FSSpecs and pathnames where applicable.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17864
diff
changeset
|
378 |
|
f7f076bfcae9
Implemented minimal FSRef support, plus conversion between FSRefs, FSSpecs and pathnames where applicable.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17864
diff
changeset
|
379 if ( is_mfsrobject(self) ) { |
|
f7f076bfcae9
Implemented minimal FSRef support, plus conversion between FSRefs, FSSpecs and pathnames where applicable.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17864
diff
changeset
|
380 fsrp = &((mfsrobject *)self)->fsref; |
|
f7f076bfcae9
Implemented minimal FSRef support, plus conversion between FSRefs, FSSpecs and pathnames where applicable.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17864
diff
changeset
|
381 if ( FSGetCatalogInfo(&((mfsrobject *)self)->fsref, kFSCatInfoNone, NULL, NULL, fssp, NULL) == noErr ) |
|
f7f076bfcae9
Implemented minimal FSRef support, plus conversion between FSRefs, FSSpecs and pathnames where applicable.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17864
diff
changeset
|
382 return 1; |
|
f7f076bfcae9
Implemented minimal FSRef support, plus conversion between FSRefs, FSSpecs and pathnames where applicable.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17864
diff
changeset
|
383 } |
|
18962
d7590122f9a2
Merging appropriate 2.1.1 fixes back into the main trunk.
Jack Jansen <jack.jansen@cwi.nl>
parents:
18434
diff
changeset
|
384 #endif |
|
18434
f7f076bfcae9
Implemented minimal FSRef support, plus conversion between FSRefs, FSSpecs and pathnames where applicable.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17864
diff
changeset
|
385 return 0; |
|
f7f076bfcae9
Implemented minimal FSRef support, plus conversion between FSRefs, FSSpecs and pathnames where applicable.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17864
diff
changeset
|
386 } |
|
f7f076bfcae9
Implemented minimal FSRef support, plus conversion between FSRefs, FSSpecs and pathnames where applicable.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17864
diff
changeset
|
387 |
|
f7f076bfcae9
Implemented minimal FSRef support, plus conversion between FSRefs, FSSpecs and pathnames where applicable.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17864
diff
changeset
|
388 /* Return an FSRef if this is an FSRef */ |
|
f7f076bfcae9
Implemented minimal FSRef support, plus conversion between FSRefs, FSSpecs and pathnames where applicable.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17864
diff
changeset
|
389 static int |
|
f7f076bfcae9
Implemented minimal FSRef support, plus conversion between FSRefs, FSSpecs and pathnames where applicable.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17864
diff
changeset
|
390 _mfs_GetFSRefFromFSRef(PyObject *self, FSRef *fsrp) |
|
f7f076bfcae9
Implemented minimal FSRef support, plus conversion between FSRefs, FSSpecs and pathnames where applicable.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17864
diff
changeset
|
391 { |
|
18962
d7590122f9a2
Merging appropriate 2.1.1 fixes back into the main trunk.
Jack Jansen <jack.jansen@cwi.nl>
parents:
18434
diff
changeset
|
392 #if !TARGET_API_MAC_OS8 |
|
18434
f7f076bfcae9
Implemented minimal FSRef support, plus conversion between FSRefs, FSSpecs and pathnames where applicable.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17864
diff
changeset
|
393 if ( is_mfsrobject(self) ) { |
|
f7f076bfcae9
Implemented minimal FSRef support, plus conversion between FSRefs, FSSpecs and pathnames where applicable.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17864
diff
changeset
|
394 *fsrp = ((mfsrobject *)self)->fsref; |
|
f7f076bfcae9
Implemented minimal FSRef support, plus conversion between FSRefs, FSSpecs and pathnames where applicable.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17864
diff
changeset
|
395 return 1; |
|
f7f076bfcae9
Implemented minimal FSRef support, plus conversion between FSRefs, FSSpecs and pathnames where applicable.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17864
diff
changeset
|
396 } |
|
18962
d7590122f9a2
Merging appropriate 2.1.1 fixes back into the main trunk.
Jack Jansen <jack.jansen@cwi.nl>
parents:
18434
diff
changeset
|
397 #endif |
|
18434
f7f076bfcae9
Implemented minimal FSRef support, plus conversion between FSRefs, FSSpecs and pathnames where applicable.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17864
diff
changeset
|
398 return 0; |
|
f7f076bfcae9
Implemented minimal FSRef support, plus conversion between FSRefs, FSSpecs and pathnames where applicable.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17864
diff
changeset
|
399 } |
|
f7f076bfcae9
Implemented minimal FSRef support, plus conversion between FSRefs, FSSpecs and pathnames where applicable.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17864
diff
changeset
|
400 |
|
f7f076bfcae9
Implemented minimal FSRef support, plus conversion between FSRefs, FSSpecs and pathnames where applicable.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17864
diff
changeset
|
401 /* Return an FSRef if this is an FSSpec */ |
|
f7f076bfcae9
Implemented minimal FSRef support, plus conversion between FSRefs, FSSpecs and pathnames where applicable.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17864
diff
changeset
|
402 static int |
|
f7f076bfcae9
Implemented minimal FSRef support, plus conversion between FSRefs, FSSpecs and pathnames where applicable.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17864
diff
changeset
|
403 _mfs_GetFSRefFromFSSpec(PyObject *self, FSRef *fsrp) |
|
f7f076bfcae9
Implemented minimal FSRef support, plus conversion between FSRefs, FSSpecs and pathnames where applicable.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17864
diff
changeset
|
404 { |
|
18962
d7590122f9a2
Merging appropriate 2.1.1 fixes back into the main trunk.
Jack Jansen <jack.jansen@cwi.nl>
parents:
18434
diff
changeset
|
405 #if !TARGET_API_MAC_OS8 |
|
18434
f7f076bfcae9
Implemented minimal FSRef support, plus conversion between FSRefs, FSSpecs and pathnames where applicable.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17864
diff
changeset
|
406 if ( is_mfssobject(self) ) { |
|
f7f076bfcae9
Implemented minimal FSRef support, plus conversion between FSRefs, FSSpecs and pathnames where applicable.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17864
diff
changeset
|
407 if ( FSpMakeFSRef(&((mfssobject *)self)->fsspec, fsrp) == noErr ) |
|
f7f076bfcae9
Implemented minimal FSRef support, plus conversion between FSRefs, FSSpecs and pathnames where applicable.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17864
diff
changeset
|
408 return 1; |
|
f7f076bfcae9
Implemented minimal FSRef support, plus conversion between FSRefs, FSSpecs and pathnames where applicable.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17864
diff
changeset
|
409 } |
|
18962
d7590122f9a2
Merging appropriate 2.1.1 fixes back into the main trunk.
Jack Jansen <jack.jansen@cwi.nl>
parents:
18434
diff
changeset
|
410 #endif |
|
18434
f7f076bfcae9
Implemented minimal FSRef support, plus conversion between FSRefs, FSSpecs and pathnames where applicable.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17864
diff
changeset
|
411 return 0; |
| 2249 | 412 } |
| 413 | |
|
4308
1a0f34c18163
Added [GS]etDates methods to get and set creation, modification and
Jack Jansen <jack.jansen@cwi.nl>
parents:
3787
diff
changeset
|
414 /* |
|
1a0f34c18163
Added [GS]etDates methods to get and set creation, modification and
Jack Jansen <jack.jansen@cwi.nl>
parents:
3787
diff
changeset
|
415 ** Two generally useful routines |
|
1a0f34c18163
Added [GS]etDates methods to get and set creation, modification and
Jack Jansen <jack.jansen@cwi.nl>
parents:
3787
diff
changeset
|
416 */ |
|
1a0f34c18163
Added [GS]etDates methods to get and set creation, modification and
Jack Jansen <jack.jansen@cwi.nl>
parents:
3787
diff
changeset
|
417 static OSErr |
|
19066
a1b4f3a1ee07
- Don't return mac-style pathnames in unix-Python.
Jack Jansen <jack.jansen@cwi.nl>
parents:
19030
diff
changeset
|
418 PyMac_GetFileDates(FSSpec *fss, unsigned long *crdat, unsigned long *mddat, |
|
a1b4f3a1ee07
- Don't return mac-style pathnames in unix-Python.
Jack Jansen <jack.jansen@cwi.nl>
parents:
19030
diff
changeset
|
419 unsigned long *bkdat) |
|
4308
1a0f34c18163
Added [GS]etDates methods to get and set creation, modification and
Jack Jansen <jack.jansen@cwi.nl>
parents:
3787
diff
changeset
|
420 { |
|
1a0f34c18163
Added [GS]etDates methods to get and set creation, modification and
Jack Jansen <jack.jansen@cwi.nl>
parents:
3787
diff
changeset
|
421 CInfoPBRec pb; |
|
1a0f34c18163
Added [GS]etDates methods to get and set creation, modification and
Jack Jansen <jack.jansen@cwi.nl>
parents:
3787
diff
changeset
|
422 OSErr error; |
|
1a0f34c18163
Added [GS]etDates methods to get and set creation, modification and
Jack Jansen <jack.jansen@cwi.nl>
parents:
3787
diff
changeset
|
423 |
|
1a0f34c18163
Added [GS]etDates methods to get and set creation, modification and
Jack Jansen <jack.jansen@cwi.nl>
parents:
3787
diff
changeset
|
424 pb.dirInfo.ioNamePtr = fss->name; |
|
1a0f34c18163
Added [GS]etDates methods to get and set creation, modification and
Jack Jansen <jack.jansen@cwi.nl>
parents:
3787
diff
changeset
|
425 pb.dirInfo.ioFDirIndex = 0; |
|
1a0f34c18163
Added [GS]etDates methods to get and set creation, modification and
Jack Jansen <jack.jansen@cwi.nl>
parents:
3787
diff
changeset
|
426 pb.dirInfo.ioVRefNum = fss->vRefNum; |
|
1a0f34c18163
Added [GS]etDates methods to get and set creation, modification and
Jack Jansen <jack.jansen@cwi.nl>
parents:
3787
diff
changeset
|
427 pb.dirInfo.ioDrDirID = fss->parID; |
|
1a0f34c18163
Added [GS]etDates methods to get and set creation, modification and
Jack Jansen <jack.jansen@cwi.nl>
parents:
3787
diff
changeset
|
428 error = PBGetCatInfoSync(&pb); |
|
1a0f34c18163
Added [GS]etDates methods to get and set creation, modification and
Jack Jansen <jack.jansen@cwi.nl>
parents:
3787
diff
changeset
|
429 if ( error ) return error; |
|
1a0f34c18163
Added [GS]etDates methods to get and set creation, modification and
Jack Jansen <jack.jansen@cwi.nl>
parents:
3787
diff
changeset
|
430 *crdat = pb.hFileInfo.ioFlCrDat; |
|
1a0f34c18163
Added [GS]etDates methods to get and set creation, modification and
Jack Jansen <jack.jansen@cwi.nl>
parents:
3787
diff
changeset
|
431 *mddat = pb.hFileInfo.ioFlMdDat; |
|
1a0f34c18163
Added [GS]etDates methods to get and set creation, modification and
Jack Jansen <jack.jansen@cwi.nl>
parents:
3787
diff
changeset
|
432 *bkdat = pb.hFileInfo.ioFlBkDat; |
|
1a0f34c18163
Added [GS]etDates methods to get and set creation, modification and
Jack Jansen <jack.jansen@cwi.nl>
parents:
3787
diff
changeset
|
433 return 0; |
|
1a0f34c18163
Added [GS]etDates methods to get and set creation, modification and
Jack Jansen <jack.jansen@cwi.nl>
parents:
3787
diff
changeset
|
434 } |
|
1a0f34c18163
Added [GS]etDates methods to get and set creation, modification and
Jack Jansen <jack.jansen@cwi.nl>
parents:
3787
diff
changeset
|
435 |
|
1a0f34c18163
Added [GS]etDates methods to get and set creation, modification and
Jack Jansen <jack.jansen@cwi.nl>
parents:
3787
diff
changeset
|
436 static OSErr |
|
19066
a1b4f3a1ee07
- Don't return mac-style pathnames in unix-Python.
Jack Jansen <jack.jansen@cwi.nl>
parents:
19030
diff
changeset
|
437 PyMac_SetFileDates(FSSpec *fss, unsigned long crdat, unsigned long mddat, |
|
a1b4f3a1ee07
- Don't return mac-style pathnames in unix-Python.
Jack Jansen <jack.jansen@cwi.nl>
parents:
19030
diff
changeset
|
438 unsigned long bkdat) |
|
4308
1a0f34c18163
Added [GS]etDates methods to get and set creation, modification and
Jack Jansen <jack.jansen@cwi.nl>
parents:
3787
diff
changeset
|
439 { |
|
1a0f34c18163
Added [GS]etDates methods to get and set creation, modification and
Jack Jansen <jack.jansen@cwi.nl>
parents:
3787
diff
changeset
|
440 CInfoPBRec pb; |
|
1a0f34c18163
Added [GS]etDates methods to get and set creation, modification and
Jack Jansen <jack.jansen@cwi.nl>
parents:
3787
diff
changeset
|
441 OSErr error; |
|
1a0f34c18163
Added [GS]etDates methods to get and set creation, modification and
Jack Jansen <jack.jansen@cwi.nl>
parents:
3787
diff
changeset
|
442 |
|
1a0f34c18163
Added [GS]etDates methods to get and set creation, modification and
Jack Jansen <jack.jansen@cwi.nl>
parents:
3787
diff
changeset
|
443 pb.dirInfo.ioNamePtr = fss->name; |
|
1a0f34c18163
Added [GS]etDates methods to get and set creation, modification and
Jack Jansen <jack.jansen@cwi.nl>
parents:
3787
diff
changeset
|
444 pb.dirInfo.ioFDirIndex = 0; |
|
1a0f34c18163
Added [GS]etDates methods to get and set creation, modification and
Jack Jansen <jack.jansen@cwi.nl>
parents:
3787
diff
changeset
|
445 pb.dirInfo.ioVRefNum = fss->vRefNum; |
|
1a0f34c18163
Added [GS]etDates methods to get and set creation, modification and
Jack Jansen <jack.jansen@cwi.nl>
parents:
3787
diff
changeset
|
446 pb.dirInfo.ioDrDirID = fss->parID; |
|
1a0f34c18163
Added [GS]etDates methods to get and set creation, modification and
Jack Jansen <jack.jansen@cwi.nl>
parents:
3787
diff
changeset
|
447 error = PBGetCatInfoSync(&pb); |
|
1a0f34c18163
Added [GS]etDates methods to get and set creation, modification and
Jack Jansen <jack.jansen@cwi.nl>
parents:
3787
diff
changeset
|
448 if ( error ) return error; |
|
1a0f34c18163
Added [GS]etDates methods to get and set creation, modification and
Jack Jansen <jack.jansen@cwi.nl>
parents:
3787
diff
changeset
|
449 pb.dirInfo.ioNamePtr = fss->name; |
|
1a0f34c18163
Added [GS]etDates methods to get and set creation, modification and
Jack Jansen <jack.jansen@cwi.nl>
parents:
3787
diff
changeset
|
450 pb.dirInfo.ioFDirIndex = 0; |
|
1a0f34c18163
Added [GS]etDates methods to get and set creation, modification and
Jack Jansen <jack.jansen@cwi.nl>
parents:
3787
diff
changeset
|
451 pb.dirInfo.ioVRefNum = fss->vRefNum; |
|
1a0f34c18163
Added [GS]etDates methods to get and set creation, modification and
Jack Jansen <jack.jansen@cwi.nl>
parents:
3787
diff
changeset
|
452 pb.dirInfo.ioDrDirID = fss->parID; |
|
1a0f34c18163
Added [GS]etDates methods to get and set creation, modification and
Jack Jansen <jack.jansen@cwi.nl>
parents:
3787
diff
changeset
|
453 pb.hFileInfo.ioFlCrDat = crdat; |
|
1a0f34c18163
Added [GS]etDates methods to get and set creation, modification and
Jack Jansen <jack.jansen@cwi.nl>
parents:
3787
diff
changeset
|
454 pb.hFileInfo.ioFlMdDat = mddat; |
|
1a0f34c18163
Added [GS]etDates methods to get and set creation, modification and
Jack Jansen <jack.jansen@cwi.nl>
parents:
3787
diff
changeset
|
455 pb.hFileInfo.ioFlBkDat = bkdat; |
|
1a0f34c18163
Added [GS]etDates methods to get and set creation, modification and
Jack Jansen <jack.jansen@cwi.nl>
parents:
3787
diff
changeset
|
456 error = PBSetCatInfoSync(&pb); |
|
1a0f34c18163
Added [GS]etDates methods to get and set creation, modification and
Jack Jansen <jack.jansen@cwi.nl>
parents:
3787
diff
changeset
|
457 return error; |
|
1a0f34c18163
Added [GS]etDates methods to get and set creation, modification and
Jack Jansen <jack.jansen@cwi.nl>
parents:
3787
diff
changeset
|
458 } |
|
1a0f34c18163
Added [GS]etDates methods to get and set creation, modification and
Jack Jansen <jack.jansen@cwi.nl>
parents:
3787
diff
changeset
|
459 |
| 5071 | 460 static PyObject * |
|
19066
a1b4f3a1ee07
- Don't return mac-style pathnames in unix-Python.
Jack Jansen <jack.jansen@cwi.nl>
parents:
19030
diff
changeset
|
461 mfss_as_pathname(mfssobject *self, PyObject *args) |
| 2249 | 462 { |
|
19841
d8dd75e3b304
Replaced PyMac_FullPath by PyMac_FullPathname, which has an extra 'length'
Jack Jansen <jack.jansen@cwi.nl>
parents:
19649
diff
changeset
|
463 char strbuf[PATHNAMELEN]; |
| 2249 | 464 OSErr err; |
|
2180
9b451c84a7bf
Initial version of FSSpec and Alias code. Non-functional as of now.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
465 |
| 5071 | 466 if (!PyArg_ParseTuple(args, "")) |
|
2180
9b451c84a7bf
Initial version of FSSpec and Alias code. Non-functional as of now.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
467 return NULL; |
|
19841
d8dd75e3b304
Replaced PyMac_FullPath by PyMac_FullPathname, which has an extra 'length'
Jack Jansen <jack.jansen@cwi.nl>
parents:
19649
diff
changeset
|
468 err = PyMac_GetFullPathname(&self->fsspec, strbuf, PATHNAMELEN); |
| 2249 | 469 if ( err ) { |
| 470 PyErr_Mac(ErrorObject, err); | |
| 471 return NULL; | |
| 472 } | |
| 5071 | 473 return PyString_FromString(strbuf); |
| 2249 | 474 } |
| 475 | |
| 5071 | 476 static PyObject * |
|
19066
a1b4f3a1ee07
- Don't return mac-style pathnames in unix-Python.
Jack Jansen <jack.jansen@cwi.nl>
parents:
19030
diff
changeset
|
477 mfss_as_tuple(mfssobject *self, PyObject *args) |
| 2249 | 478 { |
| 5071 | 479 if (!PyArg_ParseTuple(args, "")) |
| 2249 | 480 return NULL; |
| 481 return Py_BuildValue("(iis#)", self->fsspec.vRefNum, self->fsspec.parID, | |
| 482 &self->fsspec.name[1], self->fsspec.name[0]); | |
| 483 } | |
| 484 | |
| 5071 | 485 static PyObject * |
|
19066
a1b4f3a1ee07
- Don't return mac-style pathnames in unix-Python.
Jack Jansen <jack.jansen@cwi.nl>
parents:
19030
diff
changeset
|
486 mfss_NewAlias(mfssobject *self, PyObject *args) |
| 2249 | 487 { |
| 488 FSSpec src, *srcp; | |
| 489 OSErr err; | |
| 490 AliasHandle alias; | |
| 491 | |
| 492 src.name[0] = 0; | |
| 5071 | 493 if (!PyArg_ParseTuple(args, "|O&", PyMac_GetFSSpec, &src)) |
| 2249 | 494 return NULL; |
| 495 if ( src.name[0] ) | |
| 496 srcp = &src; | |
| 497 else | |
| 498 srcp = NULL; | |
| 499 err = NewAlias(srcp, &self->fsspec, &alias); | |
| 500 if ( err ) { | |
| 501 PyErr_Mac(ErrorObject, err); | |
| 502 return NULL; | |
| 503 } | |
| 504 | |
| 5071 | 505 return (PyObject *)newmfsaobject(alias); |
| 2249 | 506 } |
| 507 | |
| 5071 | 508 static PyObject * |
|
19066
a1b4f3a1ee07
- Don't return mac-style pathnames in unix-Python.
Jack Jansen <jack.jansen@cwi.nl>
parents:
19030
diff
changeset
|
509 mfss_NewAliasMinimal(mfssobject *self, PyObject *args) |
| 2249 | 510 { |
| 511 OSErr err; | |
| 512 AliasHandle alias; | |
| 513 | |
| 5071 | 514 if (!PyArg_ParseTuple(args, "")) |
| 2249 | 515 return NULL; |
| 516 err = NewAliasMinimal(&self->fsspec, &alias); | |
| 517 if ( err ) { | |
| 518 PyErr_Mac(ErrorObject, err); | |
| 519 return NULL; | |
| 520 } | |
| 5071 | 521 return (PyObject *)newmfsaobject(alias); |
|
2180
9b451c84a7bf
Initial version of FSSpec and Alias code. Non-functional as of now.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
522 } |
|
9b451c84a7bf
Initial version of FSSpec and Alias code. Non-functional as of now.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
523 |
|
18434
f7f076bfcae9
Implemented minimal FSRef support, plus conversion between FSRefs, FSSpecs and pathnames where applicable.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17864
diff
changeset
|
524 static PyObject * |
|
19066
a1b4f3a1ee07
- Don't return mac-style pathnames in unix-Python.
Jack Jansen <jack.jansen@cwi.nl>
parents:
19030
diff
changeset
|
525 mfss_FSpMakeFSRef(mfssobject *self, PyObject *args) |
|
18434
f7f076bfcae9
Implemented minimal FSRef support, plus conversion between FSRefs, FSSpecs and pathnames where applicable.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17864
diff
changeset
|
526 { |
|
18962
d7590122f9a2
Merging appropriate 2.1.1 fixes back into the main trunk.
Jack Jansen <jack.jansen@cwi.nl>
parents:
18434
diff
changeset
|
527 #if TARGET_API_MAC_OS8 |
|
d7590122f9a2
Merging appropriate 2.1.1 fixes back into the main trunk.
Jack Jansen <jack.jansen@cwi.nl>
parents:
18434
diff
changeset
|
528 PyErr_SetString(PyExc_NotImplementedError, "FSRef objects not supported on this platform"); |
|
d7590122f9a2
Merging appropriate 2.1.1 fixes back into the main trunk.
Jack Jansen <jack.jansen@cwi.nl>
parents:
18434
diff
changeset
|
529 return 0; |
|
d7590122f9a2
Merging appropriate 2.1.1 fixes back into the main trunk.
Jack Jansen <jack.jansen@cwi.nl>
parents:
18434
diff
changeset
|
530 #else |
|
18434
f7f076bfcae9
Implemented minimal FSRef support, plus conversion between FSRefs, FSSpecs and pathnames where applicable.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17864
diff
changeset
|
531 OSErr err; |
|
f7f076bfcae9
Implemented minimal FSRef support, plus conversion between FSRefs, FSSpecs and pathnames where applicable.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17864
diff
changeset
|
532 FSRef fsref; |
|
f7f076bfcae9
Implemented minimal FSRef support, plus conversion between FSRefs, FSSpecs and pathnames where applicable.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17864
diff
changeset
|
533 |
|
f7f076bfcae9
Implemented minimal FSRef support, plus conversion between FSRefs, FSSpecs and pathnames where applicable.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17864
diff
changeset
|
534 if (!PyArg_ParseTuple(args, "")) |
|
f7f076bfcae9
Implemented minimal FSRef support, plus conversion between FSRefs, FSSpecs and pathnames where applicable.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17864
diff
changeset
|
535 return NULL; |
|
f7f076bfcae9
Implemented minimal FSRef support, plus conversion between FSRefs, FSSpecs and pathnames where applicable.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17864
diff
changeset
|
536 err = FSpMakeFSRef(&self->fsspec, &fsref); |
|
f7f076bfcae9
Implemented minimal FSRef support, plus conversion between FSRefs, FSSpecs and pathnames where applicable.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17864
diff
changeset
|
537 if ( err ) { |
|
f7f076bfcae9
Implemented minimal FSRef support, plus conversion between FSRefs, FSSpecs and pathnames where applicable.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17864
diff
changeset
|
538 PyErr_Mac(ErrorObject, err); |
|
f7f076bfcae9
Implemented minimal FSRef support, plus conversion between FSRefs, FSSpecs and pathnames where applicable.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17864
diff
changeset
|
539 return NULL; |
|
f7f076bfcae9
Implemented minimal FSRef support, plus conversion between FSRefs, FSSpecs and pathnames where applicable.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17864
diff
changeset
|
540 } |
|
f7f076bfcae9
Implemented minimal FSRef support, plus conversion between FSRefs, FSSpecs and pathnames where applicable.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17864
diff
changeset
|
541 return (PyObject *)newmfsrobject(&fsref); |
|
18962
d7590122f9a2
Merging appropriate 2.1.1 fixes back into the main trunk.
Jack Jansen <jack.jansen@cwi.nl>
parents:
18434
diff
changeset
|
542 #endif |
|
18434
f7f076bfcae9
Implemented minimal FSRef support, plus conversion between FSRefs, FSSpecs and pathnames where applicable.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17864
diff
changeset
|
543 } |
|
f7f076bfcae9
Implemented minimal FSRef support, plus conversion between FSRefs, FSSpecs and pathnames where applicable.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17864
diff
changeset
|
544 |
|
2909
f9b1069a3e26
Added interfaces to {Get,Set}FInfo and accompanying objects
Jack Jansen <jack.jansen@cwi.nl>
parents:
2748
diff
changeset
|
545 /* XXXX These routines should be replaced by a wrapper to the *FInfo routines */ |
| 5071 | 546 static PyObject * |
|
19066
a1b4f3a1ee07
- Don't return mac-style pathnames in unix-Python.
Jack Jansen <jack.jansen@cwi.nl>
parents:
19030
diff
changeset
|
547 mfss_GetCreatorType(mfssobject *self, PyObject *args) |
|
2275
e5b9f644053e
Added [GS]etCreatorType methods to FSSpec objects
Jack Jansen <jack.jansen@cwi.nl>
parents:
2264
diff
changeset
|
548 { |
|
e5b9f644053e
Added [GS]etCreatorType methods to FSSpec objects
Jack Jansen <jack.jansen@cwi.nl>
parents:
2264
diff
changeset
|
549 OSErr err; |
|
e5b9f644053e
Added [GS]etCreatorType methods to FSSpec objects
Jack Jansen <jack.jansen@cwi.nl>
parents:
2264
diff
changeset
|
550 FInfo info; |
|
e5b9f644053e
Added [GS]etCreatorType methods to FSSpec objects
Jack Jansen <jack.jansen@cwi.nl>
parents:
2264
diff
changeset
|
551 |
| 5071 | 552 if (!PyArg_ParseTuple(args, "")) |
|
2275
e5b9f644053e
Added [GS]etCreatorType methods to FSSpec objects
Jack Jansen <jack.jansen@cwi.nl>
parents:
2264
diff
changeset
|
553 return NULL; |
|
e5b9f644053e
Added [GS]etCreatorType methods to FSSpec objects
Jack Jansen <jack.jansen@cwi.nl>
parents:
2264
diff
changeset
|
554 err = FSpGetFInfo(&self->fsspec, &info); |
|
e5b9f644053e
Added [GS]etCreatorType methods to FSSpec objects
Jack Jansen <jack.jansen@cwi.nl>
parents:
2264
diff
changeset
|
555 if ( err ) { |
|
e5b9f644053e
Added [GS]etCreatorType methods to FSSpec objects
Jack Jansen <jack.jansen@cwi.nl>
parents:
2264
diff
changeset
|
556 PyErr_Mac(ErrorObject, err); |
|
e5b9f644053e
Added [GS]etCreatorType methods to FSSpec objects
Jack Jansen <jack.jansen@cwi.nl>
parents:
2264
diff
changeset
|
557 return NULL; |
|
e5b9f644053e
Added [GS]etCreatorType methods to FSSpec objects
Jack Jansen <jack.jansen@cwi.nl>
parents:
2264
diff
changeset
|
558 } |
|
e5b9f644053e
Added [GS]etCreatorType methods to FSSpec objects
Jack Jansen <jack.jansen@cwi.nl>
parents:
2264
diff
changeset
|
559 return Py_BuildValue("(O&O&)", |
|
e5b9f644053e
Added [GS]etCreatorType methods to FSSpec objects
Jack Jansen <jack.jansen@cwi.nl>
parents:
2264
diff
changeset
|
560 PyMac_BuildOSType, info.fdCreator, PyMac_BuildOSType, info.fdType); |
|
e5b9f644053e
Added [GS]etCreatorType methods to FSSpec objects
Jack Jansen <jack.jansen@cwi.nl>
parents:
2264
diff
changeset
|
561 } |
|
e5b9f644053e
Added [GS]etCreatorType methods to FSSpec objects
Jack Jansen <jack.jansen@cwi.nl>
parents:
2264
diff
changeset
|
562 |
| 5071 | 563 static PyObject * |
|
19066
a1b4f3a1ee07
- Don't return mac-style pathnames in unix-Python.
Jack Jansen <jack.jansen@cwi.nl>
parents:
19030
diff
changeset
|
564 mfss_SetCreatorType(mfssobject *self, PyObject *args) |
|
2275
e5b9f644053e
Added [GS]etCreatorType methods to FSSpec objects
Jack Jansen <jack.jansen@cwi.nl>
parents:
2264
diff
changeset
|
565 { |
|
e5b9f644053e
Added [GS]etCreatorType methods to FSSpec objects
Jack Jansen <jack.jansen@cwi.nl>
parents:
2264
diff
changeset
|
566 OSErr err; |
|
e5b9f644053e
Added [GS]etCreatorType methods to FSSpec objects
Jack Jansen <jack.jansen@cwi.nl>
parents:
2264
diff
changeset
|
567 OSType creator, type; |
|
e5b9f644053e
Added [GS]etCreatorType methods to FSSpec objects
Jack Jansen <jack.jansen@cwi.nl>
parents:
2264
diff
changeset
|
568 FInfo info; |
|
e5b9f644053e
Added [GS]etCreatorType methods to FSSpec objects
Jack Jansen <jack.jansen@cwi.nl>
parents:
2264
diff
changeset
|
569 |
| 5071 | 570 if (!PyArg_ParseTuple(args, "O&O&", PyMac_GetOSType, &creator, PyMac_GetOSType, &type)) |
|
2275
e5b9f644053e
Added [GS]etCreatorType methods to FSSpec objects
Jack Jansen <jack.jansen@cwi.nl>
parents:
2264
diff
changeset
|
571 return NULL; |
|
e5b9f644053e
Added [GS]etCreatorType methods to FSSpec objects
Jack Jansen <jack.jansen@cwi.nl>
parents:
2264
diff
changeset
|
572 err = FSpGetFInfo(&self->fsspec, &info); |
|
e5b9f644053e
Added [GS]etCreatorType methods to FSSpec objects
Jack Jansen <jack.jansen@cwi.nl>
parents:
2264
diff
changeset
|
573 if ( err ) { |
|
e5b9f644053e
Added [GS]etCreatorType methods to FSSpec objects
Jack Jansen <jack.jansen@cwi.nl>
parents:
2264
diff
changeset
|
574 PyErr_Mac(ErrorObject, err); |
|
e5b9f644053e
Added [GS]etCreatorType methods to FSSpec objects
Jack Jansen <jack.jansen@cwi.nl>
parents:
2264
diff
changeset
|
575 return NULL; |
|
e5b9f644053e
Added [GS]etCreatorType methods to FSSpec objects
Jack Jansen <jack.jansen@cwi.nl>
parents:
2264
diff
changeset
|
576 } |
|
e5b9f644053e
Added [GS]etCreatorType methods to FSSpec objects
Jack Jansen <jack.jansen@cwi.nl>
parents:
2264
diff
changeset
|
577 info.fdType = type; |
|
e5b9f644053e
Added [GS]etCreatorType methods to FSSpec objects
Jack Jansen <jack.jansen@cwi.nl>
parents:
2264
diff
changeset
|
578 info.fdCreator = creator; |
|
e5b9f644053e
Added [GS]etCreatorType methods to FSSpec objects
Jack Jansen <jack.jansen@cwi.nl>
parents:
2264
diff
changeset
|
579 err = FSpSetFInfo(&self->fsspec, &info); |
|
e5b9f644053e
Added [GS]etCreatorType methods to FSSpec objects
Jack Jansen <jack.jansen@cwi.nl>
parents:
2264
diff
changeset
|
580 if ( err ) { |
|
e5b9f644053e
Added [GS]etCreatorType methods to FSSpec objects
Jack Jansen <jack.jansen@cwi.nl>
parents:
2264
diff
changeset
|
581 PyErr_Mac(ErrorObject, err); |
|
e5b9f644053e
Added [GS]etCreatorType methods to FSSpec objects
Jack Jansen <jack.jansen@cwi.nl>
parents:
2264
diff
changeset
|
582 return NULL; |
|
e5b9f644053e
Added [GS]etCreatorType methods to FSSpec objects
Jack Jansen <jack.jansen@cwi.nl>
parents:
2264
diff
changeset
|
583 } |
| 5071 | 584 Py_INCREF(Py_None); |
| 585 return Py_None; | |
|
2275
e5b9f644053e
Added [GS]etCreatorType methods to FSSpec objects
Jack Jansen <jack.jansen@cwi.nl>
parents:
2264
diff
changeset
|
586 } |
|
e5b9f644053e
Added [GS]etCreatorType methods to FSSpec objects
Jack Jansen <jack.jansen@cwi.nl>
parents:
2264
diff
changeset
|
587 |
| 5071 | 588 static PyObject * |
|
19066
a1b4f3a1ee07
- Don't return mac-style pathnames in unix-Python.
Jack Jansen <jack.jansen@cwi.nl>
parents:
19030
diff
changeset
|
589 mfss_GetFInfo(mfssobject *self, PyObject *args) |
|
2909
f9b1069a3e26
Added interfaces to {Get,Set}FInfo and accompanying objects
Jack Jansen <jack.jansen@cwi.nl>
parents:
2748
diff
changeset
|
590 { |
|
f9b1069a3e26
Added interfaces to {Get,Set}FInfo and accompanying objects
Jack Jansen <jack.jansen@cwi.nl>
parents:
2748
diff
changeset
|
591 OSErr err; |
|
f9b1069a3e26
Added interfaces to {Get,Set}FInfo and accompanying objects
Jack Jansen <jack.jansen@cwi.nl>
parents:
2748
diff
changeset
|
592 mfsiobject *fip; |
|
f9b1069a3e26
Added interfaces to {Get,Set}FInfo and accompanying objects
Jack Jansen <jack.jansen@cwi.nl>
parents:
2748
diff
changeset
|
593 |
|
f9b1069a3e26
Added interfaces to {Get,Set}FInfo and accompanying objects
Jack Jansen <jack.jansen@cwi.nl>
parents:
2748
diff
changeset
|
594 |
| 5071 | 595 if (!PyArg_ParseTuple(args, "")) |
|
2909
f9b1069a3e26
Added interfaces to {Get,Set}FInfo and accompanying objects
Jack Jansen <jack.jansen@cwi.nl>
parents:
2748
diff
changeset
|
596 return NULL; |
|
f9b1069a3e26
Added interfaces to {Get,Set}FInfo and accompanying objects
Jack Jansen <jack.jansen@cwi.nl>
parents:
2748
diff
changeset
|
597 if ( (fip=newmfsiobject()) == NULL ) |
|
f9b1069a3e26
Added interfaces to {Get,Set}FInfo and accompanying objects
Jack Jansen <jack.jansen@cwi.nl>
parents:
2748
diff
changeset
|
598 return NULL; |
|
f9b1069a3e26
Added interfaces to {Get,Set}FInfo and accompanying objects
Jack Jansen <jack.jansen@cwi.nl>
parents:
2748
diff
changeset
|
599 err = FSpGetFInfo(&self->fsspec, &fip->finfo); |
|
f9b1069a3e26
Added interfaces to {Get,Set}FInfo and accompanying objects
Jack Jansen <jack.jansen@cwi.nl>
parents:
2748
diff
changeset
|
600 if ( err ) { |
|
f9b1069a3e26
Added interfaces to {Get,Set}FInfo and accompanying objects
Jack Jansen <jack.jansen@cwi.nl>
parents:
2748
diff
changeset
|
601 PyErr_Mac(ErrorObject, err); |
| 5071 | 602 Py_DECREF(fip); |
|
2909
f9b1069a3e26
Added interfaces to {Get,Set}FInfo and accompanying objects
Jack Jansen <jack.jansen@cwi.nl>
parents:
2748
diff
changeset
|
603 return NULL; |
|
f9b1069a3e26
Added interfaces to {Get,Set}FInfo and accompanying objects
Jack Jansen <jack.jansen@cwi.nl>
parents:
2748
diff
changeset
|
604 } |
| 5071 | 605 return (PyObject *)fip; |
|
2909
f9b1069a3e26
Added interfaces to {Get,Set}FInfo and accompanying objects
Jack Jansen <jack.jansen@cwi.nl>
parents:
2748
diff
changeset
|
606 } |
|
f9b1069a3e26
Added interfaces to {Get,Set}FInfo and accompanying objects
Jack Jansen <jack.jansen@cwi.nl>
parents:
2748
diff
changeset
|
607 |
| 5071 | 608 static PyObject * |
|
19066
a1b4f3a1ee07
- Don't return mac-style pathnames in unix-Python.
Jack Jansen <jack.jansen@cwi.nl>
parents:
19030
diff
changeset
|
609 mfss_SetFInfo(mfssobject *self, PyObject *args) |
|
2909
f9b1069a3e26
Added interfaces to {Get,Set}FInfo and accompanying objects
Jack Jansen <jack.jansen@cwi.nl>
parents:
2748
diff
changeset
|
610 { |
|
f9b1069a3e26
Added interfaces to {Get,Set}FInfo and accompanying objects
Jack Jansen <jack.jansen@cwi.nl>
parents:
2748
diff
changeset
|
611 OSErr err; |
|
f9b1069a3e26
Added interfaces to {Get,Set}FInfo and accompanying objects
Jack Jansen <jack.jansen@cwi.nl>
parents:
2748
diff
changeset
|
612 mfsiobject *fip; |
|
f9b1069a3e26
Added interfaces to {Get,Set}FInfo and accompanying objects
Jack Jansen <jack.jansen@cwi.nl>
parents:
2748
diff
changeset
|
613 |
| 5071 | 614 if (!PyArg_ParseTuple(args, "O!", &Mfsitype, &fip)) |
|
2909
f9b1069a3e26
Added interfaces to {Get,Set}FInfo and accompanying objects
Jack Jansen <jack.jansen@cwi.nl>
parents:
2748
diff
changeset
|
615 return NULL; |
|
f9b1069a3e26
Added interfaces to {Get,Set}FInfo and accompanying objects
Jack Jansen <jack.jansen@cwi.nl>
parents:
2748
diff
changeset
|
616 err = FSpSetFInfo(&self->fsspec, &fip->finfo); |
|
f9b1069a3e26
Added interfaces to {Get,Set}FInfo and accompanying objects
Jack Jansen <jack.jansen@cwi.nl>
parents:
2748
diff
changeset
|
617 if ( err ) { |
|
f9b1069a3e26
Added interfaces to {Get,Set}FInfo and accompanying objects
Jack Jansen <jack.jansen@cwi.nl>
parents:
2748
diff
changeset
|
618 PyErr_Mac(ErrorObject, err); |
|
f9b1069a3e26
Added interfaces to {Get,Set}FInfo and accompanying objects
Jack Jansen <jack.jansen@cwi.nl>
parents:
2748
diff
changeset
|
619 return NULL; |
|
f9b1069a3e26
Added interfaces to {Get,Set}FInfo and accompanying objects
Jack Jansen <jack.jansen@cwi.nl>
parents:
2748
diff
changeset
|
620 } |
| 5071 | 621 Py_INCREF(Py_None); |
| 622 return Py_None; | |
|
2909
f9b1069a3e26
Added interfaces to {Get,Set}FInfo and accompanying objects
Jack Jansen <jack.jansen@cwi.nl>
parents:
2748
diff
changeset
|
623 } |
|
f9b1069a3e26
Added interfaces to {Get,Set}FInfo and accompanying objects
Jack Jansen <jack.jansen@cwi.nl>
parents:
2748
diff
changeset
|
624 |
| 5071 | 625 static PyObject * |
|
19066
a1b4f3a1ee07
- Don't return mac-style pathnames in unix-Python.
Jack Jansen <jack.jansen@cwi.nl>
parents:
19030
diff
changeset
|
626 mfss_GetDates(mfssobject *self, PyObject *args) |
|
4308
1a0f34c18163
Added [GS]etDates methods to get and set creation, modification and
Jack Jansen <jack.jansen@cwi.nl>
parents:
3787
diff
changeset
|
627 { |
|
1a0f34c18163
Added [GS]etDates methods to get and set creation, modification and
Jack Jansen <jack.jansen@cwi.nl>
parents:
3787
diff
changeset
|
628 OSErr err; |
|
1a0f34c18163
Added [GS]etDates methods to get and set creation, modification and
Jack Jansen <jack.jansen@cwi.nl>
parents:
3787
diff
changeset
|
629 unsigned long crdat, mddat, bkdat; |
|
1a0f34c18163
Added [GS]etDates methods to get and set creation, modification and
Jack Jansen <jack.jansen@cwi.nl>
parents:
3787
diff
changeset
|
630 |
| 5071 | 631 if (!PyArg_ParseTuple(args, "")) |
|
4308
1a0f34c18163
Added [GS]etDates methods to get and set creation, modification and
Jack Jansen <jack.jansen@cwi.nl>
parents:
3787
diff
changeset
|
632 return NULL; |
|
1a0f34c18163
Added [GS]etDates methods to get and set creation, modification and
Jack Jansen <jack.jansen@cwi.nl>
parents:
3787
diff
changeset
|
633 err = PyMac_GetFileDates(&self->fsspec, &crdat, &mddat, &bkdat); |
|
1a0f34c18163
Added [GS]etDates methods to get and set creation, modification and
Jack Jansen <jack.jansen@cwi.nl>
parents:
3787
diff
changeset
|
634 if ( err ) { |
|
1a0f34c18163
Added [GS]etDates methods to get and set creation, modification and
Jack Jansen <jack.jansen@cwi.nl>
parents:
3787
diff
changeset
|
635 PyErr_Mac(ErrorObject, err); |
|
1a0f34c18163
Added [GS]etDates methods to get and set creation, modification and
Jack Jansen <jack.jansen@cwi.nl>
parents:
3787
diff
changeset
|
636 return NULL; |
|
1a0f34c18163
Added [GS]etDates methods to get and set creation, modification and
Jack Jansen <jack.jansen@cwi.nl>
parents:
3787
diff
changeset
|
637 } |
| 5071 | 638 return Py_BuildValue("ddd", (double)crdat, (double)mddat, (double)bkdat); |
|
4308
1a0f34c18163
Added [GS]etDates methods to get and set creation, modification and
Jack Jansen <jack.jansen@cwi.nl>
parents:
3787
diff
changeset
|
639 } |
|
1a0f34c18163
Added [GS]etDates methods to get and set creation, modification and
Jack Jansen <jack.jansen@cwi.nl>
parents:
3787
diff
changeset
|
640 |
| 5071 | 641 static PyObject * |
|
19066
a1b4f3a1ee07
- Don't return mac-style pathnames in unix-Python.
Jack Jansen <jack.jansen@cwi.nl>
parents:
19030
diff
changeset
|
642 mfss_SetDates(mfssobject *self, PyObject *args) |
|
4308
1a0f34c18163
Added [GS]etDates methods to get and set creation, modification and
Jack Jansen <jack.jansen@cwi.nl>
parents:
3787
diff
changeset
|
643 { |
|
1a0f34c18163
Added [GS]etDates methods to get and set creation, modification and
Jack Jansen <jack.jansen@cwi.nl>
parents:
3787
diff
changeset
|
644 OSErr err; |
|
1a0f34c18163
Added [GS]etDates methods to get and set creation, modification and
Jack Jansen <jack.jansen@cwi.nl>
parents:
3787
diff
changeset
|
645 double crdat, mddat, bkdat; |
|
1a0f34c18163
Added [GS]etDates methods to get and set creation, modification and
Jack Jansen <jack.jansen@cwi.nl>
parents:
3787
diff
changeset
|
646 |
| 5071 | 647 if (!PyArg_ParseTuple(args, "ddd", &crdat, &mddat, &bkdat)) |
|
4308
1a0f34c18163
Added [GS]etDates methods to get and set creation, modification and
Jack Jansen <jack.jansen@cwi.nl>
parents:
3787
diff
changeset
|
648 return NULL; |
|
1a0f34c18163
Added [GS]etDates methods to get and set creation, modification and
Jack Jansen <jack.jansen@cwi.nl>
parents:
3787
diff
changeset
|
649 err = PyMac_SetFileDates(&self->fsspec, (unsigned long)crdat, |
|
1a0f34c18163
Added [GS]etDates methods to get and set creation, modification and
Jack Jansen <jack.jansen@cwi.nl>
parents:
3787
diff
changeset
|
650 (unsigned long)mddat, (unsigned long)bkdat); |
|
1a0f34c18163
Added [GS]etDates methods to get and set creation, modification and
Jack Jansen <jack.jansen@cwi.nl>
parents:
3787
diff
changeset
|
651 if ( err ) { |
|
1a0f34c18163
Added [GS]etDates methods to get and set creation, modification and
Jack Jansen <jack.jansen@cwi.nl>
parents:
3787
diff
changeset
|
652 PyErr_Mac(ErrorObject, err); |
|
1a0f34c18163
Added [GS]etDates methods to get and set creation, modification and
Jack Jansen <jack.jansen@cwi.nl>
parents:
3787
diff
changeset
|
653 return NULL; |
|
1a0f34c18163
Added [GS]etDates methods to get and set creation, modification and
Jack Jansen <jack.jansen@cwi.nl>
parents:
3787
diff
changeset
|
654 } |
| 5071 | 655 Py_INCREF(Py_None); |
| 656 return Py_None; | |
|
4308
1a0f34c18163
Added [GS]etDates methods to get and set creation, modification and
Jack Jansen <jack.jansen@cwi.nl>
parents:
3787
diff
changeset
|
657 } |
|
1a0f34c18163
Added [GS]etDates methods to get and set creation, modification and
Jack Jansen <jack.jansen@cwi.nl>
parents:
3787
diff
changeset
|
658 |
| 5071 | 659 static struct PyMethodDef mfss_methods[] = { |
| 660 {"as_pathname", (PyCFunction)mfss_as_pathname, 1}, | |
| 661 {"as_tuple", (PyCFunction)mfss_as_tuple, 1}, | |
|
18434
f7f076bfcae9
Implemented minimal FSRef support, plus conversion between FSRefs, FSSpecs and pathnames where applicable.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17864
diff
changeset
|
662 {"as_fsref", (PyCFunction)mfss_FSpMakeFSRef, 1}, |
|
f7f076bfcae9
Implemented minimal FSRef support, plus conversion between FSRefs, FSSpecs and pathnames where applicable.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17864
diff
changeset
|
663 {"FSpMakeFSRef", (PyCFunction)mfss_FSpMakeFSRef, 1}, |
| 5071 | 664 {"NewAlias", (PyCFunction)mfss_NewAlias, 1}, |
| 665 {"NewAliasMinimal", (PyCFunction)mfss_NewAliasMinimal, 1}, | |
| 666 {"GetCreatorType", (PyCFunction)mfss_GetCreatorType, 1}, | |
| 667 {"SetCreatorType", (PyCFunction)mfss_SetCreatorType, 1}, | |
| 668 {"GetFInfo", (PyCFunction)mfss_GetFInfo, 1}, | |
| 669 {"SetFInfo", (PyCFunction)mfss_SetFInfo, 1}, | |
| 670 {"GetDates", (PyCFunction)mfss_GetDates, 1}, | |
| 671 {"SetDates", (PyCFunction)mfss_SetDates, 1}, | |
| 2249 | 672 |
| 673 {NULL, NULL} /* sentinel */ | |
| 674 }; | |
| 675 | |
| 676 /* ---------- */ | |
| 677 | |
| 5071 | 678 static PyObject * |
|
19066
a1b4f3a1ee07
- Don't return mac-style pathnames in unix-Python.
Jack Jansen <jack.jansen@cwi.nl>
parents:
19030
diff
changeset
|
679 mfss_getattr(mfssobject *self, char *name) |
| 2249 | 680 { |
|
2319
1e7207128167
Added RawFSSpec and RawAlias methods which turn their string arguments
Jack Jansen <jack.jansen@cwi.nl>
parents:
2275
diff
changeset
|
681 if ( strcmp(name, "data") == 0) |
|
1e7207128167
Added RawFSSpec and RawAlias methods which turn their string arguments
Jack Jansen <jack.jansen@cwi.nl>
parents:
2275
diff
changeset
|
682 return PyString_FromStringAndSize((char *)&self->fsspec, sizeof(FSSpec)); |
| 5071 | 683 return Py_FindMethod(mfss_methods, (PyObject *)self, name); |
| 2249 | 684 } |
| 685 | |
| 686 mfssobject * | |
|
19066
a1b4f3a1ee07
- Don't return mac-style pathnames in unix-Python.
Jack Jansen <jack.jansen@cwi.nl>
parents:
19030
diff
changeset
|
687 newmfssobject(FSSpec *fss) |
| 2249 | 688 { |
| 689 mfssobject *self; | |
| 690 | |
| 5071 | 691 self = PyObject_NEW(mfssobject, &Mfsstype); |
| 2249 | 692 if (self == NULL) |
| 693 return NULL; | |
| 694 self->fsspec = *fss; | |
| 695 return self; | |
| 696 } | |
| 697 | |
| 698 static void | |
|
19066
a1b4f3a1ee07
- Don't return mac-style pathnames in unix-Python.
Jack Jansen <jack.jansen@cwi.nl>
parents:
19030
diff
changeset
|
699 mfss_dealloc(mfssobject *self) |
| 2249 | 700 { |
| 5071 | 701 PyMem_DEL(self); |
| 2249 | 702 } |
| 703 | |
| 5071 | 704 static PyObject * |
|
19066
a1b4f3a1ee07
- Don't return mac-style pathnames in unix-Python.
Jack Jansen <jack.jansen@cwi.nl>
parents:
19030
diff
changeset
|
705 mfss_repr(mfssobject *self) |
| 2249 | 706 { |
| 707 char buf[512]; | |
| 708 | |
|
21245
ba6a7a5c32e8
Replace sprintf() with PyOS_snprintf().
Jack Jansen <jack.jansen@cwi.nl>
parents:
20900
diff
changeset
|
709 PyOS_snprintf(buf, sizeof(buf), "FSSpec((%d, %ld, '%.*s'))", |
|
2408
77eb63716b4f
replace %#s with portable solution
Guido van Rossum <guido@python.org>
parents:
2400
diff
changeset
|
710 self->fsspec.vRefNum, |
|
77eb63716b4f
replace %#s with portable solution
Guido van Rossum <guido@python.org>
parents:
2400
diff
changeset
|
711 self->fsspec.parID, |
|
77eb63716b4f
replace %#s with portable solution
Guido van Rossum <guido@python.org>
parents:
2400
diff
changeset
|
712 self->fsspec.name[0], self->fsspec.name+1); |
| 5071 | 713 return PyString_FromString(buf); |
| 2249 | 714 } |
| 715 | |
| 716 static int | |
|
19066
a1b4f3a1ee07
- Don't return mac-style pathnames in unix-Python.
Jack Jansen <jack.jansen@cwi.nl>
parents:
19030
diff
changeset
|
717 mfss_compare(mfssobject *v, mfssobject *w) |
| 2249 | 718 { |
| 719 int minlen; | |
| 720 int res; | |
| 721 | |
| 722 if ( v->fsspec.vRefNum < w->fsspec.vRefNum ) return -1; | |
| 723 if ( v->fsspec.vRefNum > w->fsspec.vRefNum ) return 1; | |
| 724 if ( v->fsspec.parID < w->fsspec.parID ) return -1; | |
| 725 if ( v->fsspec.parID > w->fsspec.parID ) return 1; | |
| 726 minlen = v->fsspec.name[0]; | |
| 727 if ( w->fsspec.name[0] < minlen ) minlen = w->fsspec.name[0]; | |
| 728 res = strncmp((char *)v->fsspec.name+1, (char *)w->fsspec.name+1, minlen); | |
| 729 if ( res ) return res; | |
| 730 if ( v->fsspec.name[0] < w->fsspec.name[0] ) return -1; | |
| 731 if ( v->fsspec.name[0] > w->fsspec.name[0] ) return 1; | |
| 732 return res; | |
| 733 } | |
| 734 | |
| 5071 | 735 statichere PyTypeObject Mfsstype = { |
| 736 PyObject_HEAD_INIT(&PyType_Type) | |
| 2249 | 737 0, /*ob_size*/ |
| 738 "FSSpec", /*tp_name*/ | |
| 739 sizeof(mfssobject), /*tp_basicsize*/ | |
| 740 0, /*tp_itemsize*/ | |
| 741 /* methods */ | |
| 742 (destructor)mfss_dealloc, /*tp_dealloc*/ | |
| 743 (printfunc)0, /*tp_print*/ | |
| 744 (getattrfunc)mfss_getattr, /*tp_getattr*/ | |
| 745 (setattrfunc)0, /*tp_setattr*/ | |
| 746 (cmpfunc)mfss_compare, /*tp_compare*/ | |
| 747 (reprfunc)mfss_repr, /*tp_repr*/ | |
| 748 0, /*tp_as_number*/ | |
| 749 0, /*tp_as_sequence*/ | |
| 750 0, /*tp_as_mapping*/ | |
| 751 (hashfunc)0, /*tp_hash*/ | |
| 752 }; | |
| 753 | |
| 754 /* End of code for FSSpec objects */ | |
| 755 /* -------------------------------------------------------- */ | |
|
18962
d7590122f9a2
Merging appropriate 2.1.1 fixes back into the main trunk.
Jack Jansen <jack.jansen@cwi.nl>
parents:
18434
diff
changeset
|
756 #if !TARGET_API_MAC_OS8 |
| 5071 | 757 static PyObject * |
|
19066
a1b4f3a1ee07
- Don't return mac-style pathnames in unix-Python.
Jack Jansen <jack.jansen@cwi.nl>
parents:
19030
diff
changeset
|
758 mfsr_as_fsspec(mfsrobject *self, PyObject *args) |
|
18434
f7f076bfcae9
Implemented minimal FSRef support, plus conversion between FSRefs, FSSpecs and pathnames where applicable.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17864
diff
changeset
|
759 { |
|
f7f076bfcae9
Implemented minimal FSRef support, plus conversion between FSRefs, FSSpecs and pathnames where applicable.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17864
diff
changeset
|
760 OSErr err; |
|
f7f076bfcae9
Implemented minimal FSRef support, plus conversion between FSRefs, FSSpecs and pathnames where applicable.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17864
diff
changeset
|
761 FSSpec fss; |
|
f7f076bfcae9
Implemented minimal FSRef support, plus conversion between FSRefs, FSSpecs and pathnames where applicable.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17864
diff
changeset
|
762 |
|
f7f076bfcae9
Implemented minimal FSRef support, plus conversion between FSRefs, FSSpecs and pathnames where applicable.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17864
diff
changeset
|
763 if (!PyArg_ParseTuple(args, "")) |
|
f7f076bfcae9
Implemented minimal FSRef support, plus conversion between FSRefs, FSSpecs and pathnames where applicable.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17864
diff
changeset
|
764 return NULL; |
|
f7f076bfcae9
Implemented minimal FSRef support, plus conversion between FSRefs, FSSpecs and pathnames where applicable.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17864
diff
changeset
|
765 err = FSGetCatalogInfo(&self->fsref, kFSCatInfoNone, NULL, NULL, &fss, NULL); |
|
f7f076bfcae9
Implemented minimal FSRef support, plus conversion between FSRefs, FSSpecs and pathnames where applicable.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17864
diff
changeset
|
766 if ( err ) { |
|
f7f076bfcae9
Implemented minimal FSRef support, plus conversion between FSRefs, FSSpecs and pathnames where applicable.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17864
diff
changeset
|
767 PyErr_Mac(ErrorObject, err); |
|
f7f076bfcae9
Implemented minimal FSRef support, plus conversion between FSRefs, FSSpecs and pathnames where applicable.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17864
diff
changeset
|
768 return NULL; |
|
f7f076bfcae9
Implemented minimal FSRef support, plus conversion between FSRefs, FSSpecs and pathnames where applicable.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17864
diff
changeset
|
769 } |
|
f7f076bfcae9
Implemented minimal FSRef support, plus conversion between FSRefs, FSSpecs and pathnames where applicable.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17864
diff
changeset
|
770 Py_INCREF(Py_None); |
|
f7f076bfcae9
Implemented minimal FSRef support, plus conversion between FSRefs, FSSpecs and pathnames where applicable.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17864
diff
changeset
|
771 return (PyObject *)newmfssobject(&fss); |
|
f7f076bfcae9
Implemented minimal FSRef support, plus conversion between FSRefs, FSSpecs and pathnames where applicable.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17864
diff
changeset
|
772 } |
|
f7f076bfcae9
Implemented minimal FSRef support, plus conversion between FSRefs, FSSpecs and pathnames where applicable.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17864
diff
changeset
|
773 |
|
f7f076bfcae9
Implemented minimal FSRef support, plus conversion between FSRefs, FSSpecs and pathnames where applicable.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17864
diff
changeset
|
774 static struct PyMethodDef mfsr_methods[] = { |
|
f7f076bfcae9
Implemented minimal FSRef support, plus conversion between FSRefs, FSSpecs and pathnames where applicable.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17864
diff
changeset
|
775 {"as_fsspec", (PyCFunction)mfsr_as_fsspec, 1}, |
|
f7f076bfcae9
Implemented minimal FSRef support, plus conversion between FSRefs, FSSpecs and pathnames where applicable.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17864
diff
changeset
|
776 #if 0 |
|
f7f076bfcae9
Implemented minimal FSRef support, plus conversion between FSRefs, FSSpecs and pathnames where applicable.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17864
diff
changeset
|
777 {"as_pathname", (PyCFunction)mfss_as_pathname, 1}, |
|
f7f076bfcae9
Implemented minimal FSRef support, plus conversion between FSRefs, FSSpecs and pathnames where applicable.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17864
diff
changeset
|
778 {"as_tuple", (PyCFunction)mfss_as_tuple, 1}, |
|
f7f076bfcae9
Implemented minimal FSRef support, plus conversion between FSRefs, FSSpecs and pathnames where applicable.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17864
diff
changeset
|
779 {"NewAlias", (PyCFunction)mfss_NewAlias, 1}, |
|
f7f076bfcae9
Implemented minimal FSRef support, plus conversion between FSRefs, FSSpecs and pathnames where applicable.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17864
diff
changeset
|
780 {"NewAliasMinimal", (PyCFunction)mfss_NewAliasMinimal, 1}, |
|
f7f076bfcae9
Implemented minimal FSRef support, plus conversion between FSRefs, FSSpecs and pathnames where applicable.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17864
diff
changeset
|
781 {"GetCreatorType", (PyCFunction)mfss_GetCreatorType, 1}, |
|
f7f076bfcae9
Implemented minimal FSRef support, plus conversion between FSRefs, FSSpecs and pathnames where applicable.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17864
diff
changeset
|
782 {"SetCreatorType", (PyCFunction)mfss_SetCreatorType, 1}, |
|
f7f076bfcae9
Implemented minimal FSRef support, plus conversion between FSRefs, FSSpecs and pathnames where applicable.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17864
diff
changeset
|
783 {"GetFInfo", (PyCFunction)mfss_GetFInfo, 1}, |
|
f7f076bfcae9
Implemented minimal FSRef support, plus conversion between FSRefs, FSSpecs and pathnames where applicable.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17864
diff
changeset
|
784 {"SetFInfo", (PyCFunction)mfss_SetFInfo, 1}, |
|
f7f076bfcae9
Implemented minimal FSRef support, plus conversion between FSRefs, FSSpecs and pathnames where applicable.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17864
diff
changeset
|
785 {"GetDates", (PyCFunction)mfss_GetDates, 1}, |
|
f7f076bfcae9
Implemented minimal FSRef support, plus conversion between FSRefs, FSSpecs and pathnames where applicable.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17864
diff
changeset
|
786 {"SetDates", (PyCFunction)mfss_SetDates, 1}, |
|
f7f076bfcae9
Implemented minimal FSRef support, plus conversion between FSRefs, FSSpecs and pathnames where applicable.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17864
diff
changeset
|
787 #endif |
|
f7f076bfcae9
Implemented minimal FSRef support, plus conversion between FSRefs, FSSpecs and pathnames where applicable.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17864
diff
changeset
|
788 |
|
f7f076bfcae9
Implemented minimal FSRef support, plus conversion between FSRefs, FSSpecs and pathnames where applicable.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17864
diff
changeset
|
789 {NULL, NULL} /* sentinel */ |
|
f7f076bfcae9
Implemented minimal FSRef support, plus conversion between FSRefs, FSSpecs and pathnames where applicable.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17864
diff
changeset
|
790 }; |
|
f7f076bfcae9
Implemented minimal FSRef support, plus conversion between FSRefs, FSSpecs and pathnames where applicable.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17864
diff
changeset
|
791 |
|
f7f076bfcae9
Implemented minimal FSRef support, plus conversion between FSRefs, FSSpecs and pathnames where applicable.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17864
diff
changeset
|
792 /* ---------- */ |
|
f7f076bfcae9
Implemented minimal FSRef support, plus conversion between FSRefs, FSSpecs and pathnames where applicable.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17864
diff
changeset
|
793 |
|
f7f076bfcae9
Implemented minimal FSRef support, plus conversion between FSRefs, FSSpecs and pathnames where applicable.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17864
diff
changeset
|
794 static PyObject * |
|
19066
a1b4f3a1ee07
- Don't return mac-style pathnames in unix-Python.
Jack Jansen <jack.jansen@cwi.nl>
parents:
19030
diff
changeset
|
795 mfsr_getattr(mfsrobject *self, char *name) |
|
18434
f7f076bfcae9
Implemented minimal FSRef support, plus conversion between FSRefs, FSSpecs and pathnames where applicable.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17864
diff
changeset
|
796 { |
|
f7f076bfcae9
Implemented minimal FSRef support, plus conversion between FSRefs, FSSpecs and pathnames where applicable.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17864
diff
changeset
|
797 if ( strcmp(name, "data") == 0) |
|
f7f076bfcae9
Implemented minimal FSRef support, plus conversion between FSRefs, FSSpecs and pathnames where applicable.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17864
diff
changeset
|
798 return PyString_FromStringAndSize((char *)&self->fsref, sizeof(FSRef)); |
|
f7f076bfcae9
Implemented minimal FSRef support, plus conversion between FSRefs, FSSpecs and pathnames where applicable.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17864
diff
changeset
|
799 return Py_FindMethod(mfsr_methods, (PyObject *)self, name); |
|
f7f076bfcae9
Implemented minimal FSRef support, plus conversion between FSRefs, FSSpecs and pathnames where applicable.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17864
diff
changeset
|
800 } |
|
f7f076bfcae9
Implemented minimal FSRef support, plus conversion between FSRefs, FSSpecs and pathnames where applicable.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17864
diff
changeset
|
801 |
|
f7f076bfcae9
Implemented minimal FSRef support, plus conversion between FSRefs, FSSpecs and pathnames where applicable.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17864
diff
changeset
|
802 mfsrobject * |
|
19066
a1b4f3a1ee07
- Don't return mac-style pathnames in unix-Python.
Jack Jansen <jack.jansen@cwi.nl>
parents:
19030
diff
changeset
|
803 newmfsrobject(FSRef *fsr) |
|
18434
f7f076bfcae9
Implemented minimal FSRef support, plus conversion between FSRefs, FSSpecs and pathnames where applicable.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17864
diff
changeset
|
804 { |
|
f7f076bfcae9
Implemented minimal FSRef support, plus conversion between FSRefs, FSSpecs and pathnames where applicable.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17864
diff
changeset
|
805 mfsrobject *self; |
|
f7f076bfcae9
Implemented minimal FSRef support, plus conversion between FSRefs, FSSpecs and pathnames where applicable.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17864
diff
changeset
|
806 |
|
f7f076bfcae9
Implemented minimal FSRef support, plus conversion between FSRefs, FSSpecs and pathnames where applicable.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17864
diff
changeset
|
807 self = PyObject_NEW(mfsrobject, &Mfsrtype); |
|
f7f076bfcae9
Implemented minimal FSRef support, plus conversion between FSRefs, FSSpecs and pathnames where applicable.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17864
diff
changeset
|
808 if (self == NULL) |
|
f7f076bfcae9
Implemented minimal FSRef support, plus conversion between FSRefs, FSSpecs and pathnames where applicable.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17864
diff
changeset
|
809 return NULL; |
|
f7f076bfcae9
Implemented minimal FSRef support, plus conversion between FSRefs, FSSpecs and pathnames where applicable.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17864
diff
changeset
|
810 self->fsref = *fsr; |
|
f7f076bfcae9
Implemented minimal FSRef support, plus conversion between FSRefs, FSSpecs and pathnames where applicable.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17864
diff
changeset
|
811 return self; |
|
f7f076bfcae9
Implemented minimal FSRef support, plus conversion between FSRefs, FSSpecs and pathnames where applicable.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17864
diff
changeset
|
812 } |
|
f7f076bfcae9
Implemented minimal FSRef support, plus conversion between FSRefs, FSSpecs and pathnames where applicable.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17864
diff
changeset
|
813 |
|
f7f076bfcae9
Implemented minimal FSRef support, plus conversion between FSRefs, FSSpecs and pathnames where applicable.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17864
diff
changeset
|
814 static int |
|
19066
a1b4f3a1ee07
- Don't return mac-style pathnames in unix-Python.
Jack Jansen <jack.jansen@cwi.nl>
parents:
19030
diff
changeset
|
815 mfsr_compare(mfsrobject *v, mfsrobject *w) |
|
18434
f7f076bfcae9
Implemented minimal FSRef support, plus conversion between FSRefs, FSSpecs and pathnames where applicable.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17864
diff
changeset
|
816 { |
|
f7f076bfcae9
Implemented minimal FSRef support, plus conversion between FSRefs, FSSpecs and pathnames where applicable.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17864
diff
changeset
|
817 OSErr err; |
|
f7f076bfcae9
Implemented minimal FSRef support, plus conversion between FSRefs, FSSpecs and pathnames where applicable.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17864
diff
changeset
|
818 |
|
f7f076bfcae9
Implemented minimal FSRef support, plus conversion between FSRefs, FSSpecs and pathnames where applicable.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17864
diff
changeset
|
819 if ( v == w ) return 0; |
|
f7f076bfcae9
Implemented minimal FSRef support, plus conversion between FSRefs, FSSpecs and pathnames where applicable.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17864
diff
changeset
|
820 err = FSCompareFSRefs(&v->fsref, &w->fsref); |
|
f7f076bfcae9
Implemented minimal FSRef support, plus conversion between FSRefs, FSSpecs and pathnames where applicable.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17864
diff
changeset
|
821 if ( err == 0 ) |
|
f7f076bfcae9
Implemented minimal FSRef support, plus conversion between FSRefs, FSSpecs and pathnames where applicable.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17864
diff
changeset
|
822 return 0; |
|
f7f076bfcae9
Implemented minimal FSRef support, plus conversion between FSRefs, FSSpecs and pathnames where applicable.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17864
diff
changeset
|
823 if (v < w ) |
|
f7f076bfcae9
Implemented minimal FSRef support, plus conversion between FSRefs, FSSpecs and pathnames where applicable.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17864
diff
changeset
|
824 return -1; |
|
f7f076bfcae9
Implemented minimal FSRef support, plus conversion between FSRefs, FSSpecs and pathnames where applicable.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17864
diff
changeset
|
825 return 1; |
|
f7f076bfcae9
Implemented minimal FSRef support, plus conversion between FSRefs, FSSpecs and pathnames where applicable.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17864
diff
changeset
|
826 } |
|
f7f076bfcae9
Implemented minimal FSRef support, plus conversion between FSRefs, FSSpecs and pathnames where applicable.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17864
diff
changeset
|
827 |
|
f7f076bfcae9
Implemented minimal FSRef support, plus conversion between FSRefs, FSSpecs and pathnames where applicable.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17864
diff
changeset
|
828 static void |
|
19066
a1b4f3a1ee07
- Don't return mac-style pathnames in unix-Python.
Jack Jansen <jack.jansen@cwi.nl>
parents:
19030
diff
changeset
|
829 mfsr_dealloc(mfsrobject *self) |
|
18434
f7f076bfcae9
Implemented minimal FSRef support, plus conversion between FSRefs, FSSpecs and pathnames where applicable.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17864
diff
changeset
|
830 { |
|
f7f076bfcae9
Implemented minimal FSRef support, plus conversion between FSRefs, FSSpecs and pathnames where applicable.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17864
diff
changeset
|
831 PyMem_DEL(self); |
|
f7f076bfcae9
Implemented minimal FSRef support, plus conversion between FSRefs, FSSpecs and pathnames where applicable.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17864
diff
changeset
|
832 } |
|
f7f076bfcae9
Implemented minimal FSRef support, plus conversion between FSRefs, FSSpecs and pathnames where applicable.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17864
diff
changeset
|
833 |
|
f7f076bfcae9
Implemented minimal FSRef support, plus conversion between FSRefs, FSSpecs and pathnames where applicable.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17864
diff
changeset
|
834 statichere PyTypeObject Mfsrtype = { |
|
f7f076bfcae9
Implemented minimal FSRef support, plus conversion between FSRefs, FSSpecs and pathnames where applicable.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17864
diff
changeset
|
835 PyObject_HEAD_INIT(&PyType_Type) |
|
f7f076bfcae9
Implemented minimal FSRef support, plus conversion between FSRefs, FSSpecs and pathnames where applicable.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17864
diff
changeset
|
836 0, /*ob_size*/ |
|
f7f076bfcae9
Implemented minimal FSRef support, plus conversion between FSRefs, FSSpecs and pathnames where applicable.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17864
diff
changeset
|
837 "FSRef", /*tp_name*/ |
|
f7f076bfcae9
Implemented minimal FSRef support, plus conversion between FSRefs, FSSpecs and pathnames where applicable.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17864
diff
changeset
|
838 sizeof(mfsrobject), /*tp_basicsize*/ |
|
f7f076bfcae9
Implemented minimal FSRef support, plus conversion between FSRefs, FSSpecs and pathnames where applicable.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17864
diff
changeset
|
839 0, /*tp_itemsize*/ |
|
f7f076bfcae9
Implemented minimal FSRef support, plus conversion between FSRefs, FSSpecs and pathnames where applicable.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17864
diff
changeset
|
840 /* methods */ |
|
f7f076bfcae9
Implemented minimal FSRef support, plus conversion between FSRefs, FSSpecs and pathnames where applicable.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17864
diff
changeset
|
841 (destructor)mfsr_dealloc, /*tp_dealloc*/ |
|
f7f076bfcae9
Implemented minimal FSRef support, plus conversion between FSRefs, FSSpecs and pathnames where applicable.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17864
diff
changeset
|
842 (printfunc)0, /*tp_print*/ |
|
f7f076bfcae9
Implemented minimal FSRef support, plus conversion between FSRefs, FSSpecs and pathnames where applicable.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17864
diff
changeset
|
843 (getattrfunc)mfsr_getattr, /*tp_getattr*/ |
|
f7f076bfcae9
Implemented minimal FSRef support, plus conversion between FSRefs, FSSpecs and pathnames where applicable.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17864
diff
changeset
|
844 (setattrfunc)0, /*tp_setattr*/ |
|
f7f076bfcae9
Implemented minimal FSRef support, plus conversion between FSRefs, FSSpecs and pathnames where applicable.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17864
diff
changeset
|
845 (cmpfunc)mfsr_compare, /*tp_compare*/ |
|
f7f076bfcae9
Implemented minimal FSRef support, plus conversion between FSRefs, FSSpecs and pathnames where applicable.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17864
diff
changeset
|
846 (reprfunc)0, /*tp_repr*/ |
|
f7f076bfcae9
Implemented minimal FSRef support, plus conversion between FSRefs, FSSpecs and pathnames where applicable.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17864
diff
changeset
|
847 0, /*tp_as_number*/ |
|
f7f076bfcae9
Implemented minimal FSRef support, plus conversion between FSRefs, FSSpecs and pathnames where applicable.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17864
diff
changeset
|
848 0, /*tp_as_sequence*/ |
|
f7f076bfcae9
Implemented minimal FSRef support, plus conversion between FSRefs, FSSpecs and pathnames where applicable.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17864
diff
changeset
|
849 0, /*tp_as_mapping*/ |
|
f7f076bfcae9
Implemented minimal FSRef support, plus conversion between FSRefs, FSSpecs and pathnames where applicable.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17864
diff
changeset
|
850 (hashfunc)0, /*tp_hash*/ |
|
f7f076bfcae9
Implemented minimal FSRef support, plus conversion between FSRefs, FSSpecs and pathnames where applicable.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17864
diff
changeset
|
851 }; |
|
f7f076bfcae9
Implemented minimal FSRef support, plus conversion between FSRefs, FSSpecs and pathnames where applicable.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17864
diff
changeset
|
852 |
|
f7f076bfcae9
Implemented minimal FSRef support, plus conversion between FSRefs, FSSpecs and pathnames where applicable.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17864
diff
changeset
|
853 /* End of code for FSRef objects */ |
|
18962
d7590122f9a2
Merging appropriate 2.1.1 fixes back into the main trunk.
Jack Jansen <jack.jansen@cwi.nl>
parents:
18434
diff
changeset
|
854 #endif /* !TARGET_API_MAC_OS8 */ |
|
18434
f7f076bfcae9
Implemented minimal FSRef support, plus conversion between FSRefs, FSSpecs and pathnames where applicable.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17864
diff
changeset
|
855 /* -------------------------------------------------------- */ |
|
f7f076bfcae9
Implemented minimal FSRef support, plus conversion between FSRefs, FSSpecs and pathnames where applicable.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17864
diff
changeset
|
856 |
|
f7f076bfcae9
Implemented minimal FSRef support, plus conversion between FSRefs, FSSpecs and pathnames where applicable.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17864
diff
changeset
|
857 static PyObject * |
|
19066
a1b4f3a1ee07
- Don't return mac-style pathnames in unix-Python.
Jack Jansen <jack.jansen@cwi.nl>
parents:
19030
diff
changeset
|
858 mfs_ResolveAliasFile(PyObject *self, PyObject *args) |
|
2180
9b451c84a7bf
Initial version of FSSpec and Alias code. Non-functional as of now.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
859 { |
| 2249 | 860 FSSpec fss; |
| 861 Boolean chain = 1, isfolder, wasaliased; | |
| 862 OSErr err; | |
|
2180
9b451c84a7bf
Initial version of FSSpec and Alias code. Non-functional as of now.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
863 |
| 5071 | 864 if (!PyArg_ParseTuple(args, "O&|i", PyMac_GetFSSpec, &fss, &chain)) |
| 2249 | 865 return NULL; |
| 866 err = ResolveAliasFile(&fss, chain, &isfolder, &wasaliased); | |
| 867 if ( err ) { | |
| 868 PyErr_Mac(ErrorObject, err); | |
|
2180
9b451c84a7bf
Initial version of FSSpec and Alias code. Non-functional as of now.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
869 return NULL; |
| 2249 | 870 } |
| 5071 | 871 return Py_BuildValue("Oii", newmfssobject(&fss), (int)isfolder, (int)wasaliased); |
| 2249 | 872 } |
| 873 | |
|
13608
a901c2c0166b
Test for TARGET_API_MAC_CARBON with #if in stead of #ifdef.
Jack Jansen <jack.jansen@cwi.nl>
parents:
13606
diff
changeset
|
874 #if !TARGET_API_MAC_CARBON |
| 5071 | 875 static PyObject * |
|
19066
a1b4f3a1ee07
- Don't return mac-style pathnames in unix-Python.
Jack Jansen <jack.jansen@cwi.nl>
parents:
19030
diff
changeset
|
876 mfs_StandardGetFile(PyObject *self, PyObject *args) |
| 2249 | 877 { |
|
2264
85aa2e4d0123
fixed StandardGetFile argument handling
Guido van Rossum <guido@python.org>
parents:
2254
diff
changeset
|
878 SFTypeList list; |
| 2249 | 879 short numtypes; |
| 880 StandardFileReply reply; | |
| 881 | |
| 882 list[0] = list[1] = list[2] = list[3] = 0; | |
| 883 numtypes = 0; | |
| 5071 | 884 if (!PyArg_ParseTuple(args, "|O&O&O&O&", PyMac_GetOSType, &list[0], |
| 2249 | 885 PyMac_GetOSType, &list[1], PyMac_GetOSType, &list[2], |
| 886 PyMac_GetOSType, &list[3]) ) | |
| 887 return NULL; | |
|
2264
85aa2e4d0123
fixed StandardGetFile argument handling
Guido van Rossum <guido@python.org>
parents:
2254
diff
changeset
|
888 while ( numtypes < 4 && list[numtypes] ) { |
| 2249 | 889 numtypes++; |
| 890 } | |
|
2717
6c864ad519a3
StandardGetFile without args now shows all files (in stead of none)
Jack Jansen <jack.jansen@cwi.nl>
parents:
2408
diff
changeset
|
891 if ( numtypes == 0 ) |
|
6c864ad519a3
StandardGetFile without args now shows all files (in stead of none)
Jack Jansen <jack.jansen@cwi.nl>
parents:
2408
diff
changeset
|
892 numtypes = -1; |
|
2264
85aa2e4d0123
fixed StandardGetFile argument handling
Guido van Rossum <guido@python.org>
parents:
2254
diff
changeset
|
893 StandardGetFile((FileFilterUPP)0, numtypes, list, &reply); |
| 5071 | 894 return Py_BuildValue("(Oi)", newmfssobject(&reply.sfFile), reply.sfGood); |
|
2180
9b451c84a7bf
Initial version of FSSpec and Alias code. Non-functional as of now.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
895 } |
|
9b451c84a7bf
Initial version of FSSpec and Alias code. Non-functional as of now.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
896 |
| 5071 | 897 static PyObject * |
|
19066
a1b4f3a1ee07
- Don't return mac-style pathnames in unix-Python.
Jack Jansen <jack.jansen@cwi.nl>
parents:
19030
diff
changeset
|
898 mfs_PromptGetFile(PyObject *self, PyObject *args) |
|
2981
56ad247cbfcb
Added new call PromptGetFile (like StandardGetFile, but accepts a
Jack Jansen <jack.jansen@cwi.nl>
parents:
2909
diff
changeset
|
899 { |
|
56ad247cbfcb
Added new call PromptGetFile (like StandardGetFile, but accepts a
Jack Jansen <jack.jansen@cwi.nl>
parents:
2909
diff
changeset
|
900 SFTypeList list; |
|
56ad247cbfcb
Added new call PromptGetFile (like StandardGetFile, but accepts a
Jack Jansen <jack.jansen@cwi.nl>
parents:
2909
diff
changeset
|
901 short numtypes; |
|
56ad247cbfcb
Added new call PromptGetFile (like StandardGetFile, but accepts a
Jack Jansen <jack.jansen@cwi.nl>
parents:
2909
diff
changeset
|
902 StandardFileReply reply; |
|
56ad247cbfcb
Added new call PromptGetFile (like StandardGetFile, but accepts a
Jack Jansen <jack.jansen@cwi.nl>
parents:
2909
diff
changeset
|
903 char *prompt = NULL; |
|
56ad247cbfcb
Added new call PromptGetFile (like StandardGetFile, but accepts a
Jack Jansen <jack.jansen@cwi.nl>
parents:
2909
diff
changeset
|
904 |
|
56ad247cbfcb
Added new call PromptGetFile (like StandardGetFile, but accepts a
Jack Jansen <jack.jansen@cwi.nl>
parents:
2909
diff
changeset
|
905 list[0] = list[1] = list[2] = list[3] = 0; |
|
56ad247cbfcb
Added new call PromptGetFile (like StandardGetFile, but accepts a
Jack Jansen <jack.jansen@cwi.nl>
parents:
2909
diff
changeset
|
906 numtypes = 0; |
| 5071 | 907 if (!PyArg_ParseTuple(args, "s|O&O&O&O&", &prompt, PyMac_GetOSType, &list[0], |
|
2981
56ad247cbfcb
Added new call PromptGetFile (like StandardGetFile, but accepts a
Jack Jansen <jack.jansen@cwi.nl>
parents:
2909
diff
changeset
|
908 PyMac_GetOSType, &list[1], PyMac_GetOSType, &list[2], |
|
56ad247cbfcb
Added new call PromptGetFile (like StandardGetFile, but accepts a
Jack Jansen <jack.jansen@cwi.nl>
parents:
2909
diff
changeset
|
909 PyMac_GetOSType, &list[3]) ) |
|
56ad247cbfcb
Added new call PromptGetFile (like StandardGetFile, but accepts a
Jack Jansen <jack.jansen@cwi.nl>
parents:
2909
diff
changeset
|
910 return NULL; |
|
56ad247cbfcb
Added new call PromptGetFile (like StandardGetFile, but accepts a
Jack Jansen <jack.jansen@cwi.nl>
parents:
2909
diff
changeset
|
911 while ( numtypes < 4 && list[numtypes] ) { |
|
56ad247cbfcb
Added new call PromptGetFile (like StandardGetFile, but accepts a
Jack Jansen <jack.jansen@cwi.nl>
parents:
2909
diff
changeset
|
912 numtypes++; |
|
56ad247cbfcb
Added new call PromptGetFile (like StandardGetFile, but accepts a
Jack Jansen <jack.jansen@cwi.nl>
parents:
2909
diff
changeset
|
913 } |
|
56ad247cbfcb
Added new call PromptGetFile (like StandardGetFile, but accepts a
Jack Jansen <jack.jansen@cwi.nl>
parents:
2909
diff
changeset
|
914 if ( numtypes == 0 ) |
|
56ad247cbfcb
Added new call PromptGetFile (like StandardGetFile, but accepts a
Jack Jansen <jack.jansen@cwi.nl>
parents:
2909
diff
changeset
|
915 numtypes = -1; |
|
56ad247cbfcb
Added new call PromptGetFile (like StandardGetFile, but accepts a
Jack Jansen <jack.jansen@cwi.nl>
parents:
2909
diff
changeset
|
916 PyMac_PromptGetFile(numtypes, list, &reply, prompt); |
| 5071 | 917 return Py_BuildValue("(Oi)", newmfssobject(&reply.sfFile), reply.sfGood); |
|
2981
56ad247cbfcb
Added new call PromptGetFile (like StandardGetFile, but accepts a
Jack Jansen <jack.jansen@cwi.nl>
parents:
2909
diff
changeset
|
918 } |
|
56ad247cbfcb
Added new call PromptGetFile (like StandardGetFile, but accepts a
Jack Jansen <jack.jansen@cwi.nl>
parents:
2909
diff
changeset
|
919 |
| 5071 | 920 static PyObject * |
|
19066
a1b4f3a1ee07
- Don't return mac-style pathnames in unix-Python.
Jack Jansen <jack.jansen@cwi.nl>
parents:
19030
diff
changeset
|
921 mfs_StandardPutFile(PyObject *self, PyObject *args) |
|
2180
9b451c84a7bf
Initial version of FSSpec and Alias code. Non-functional as of now.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
922 { |
|
9b451c84a7bf
Initial version of FSSpec and Alias code. Non-functional as of now.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
923 Str255 prompt, dft; |
|
9b451c84a7bf
Initial version of FSSpec and Alias code. Non-functional as of now.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
924 StandardFileReply reply; |
|
9b451c84a7bf
Initial version of FSSpec and Alias code. Non-functional as of now.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
925 |
|
9b451c84a7bf
Initial version of FSSpec and Alias code. Non-functional as of now.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
926 dft[0] = 0; |
| 5071 | 927 if (!PyArg_ParseTuple(args, "O&|O&", PyMac_GetStr255, &prompt, PyMac_GetStr255, &dft) ) |
|
2180
9b451c84a7bf
Initial version of FSSpec and Alias code. Non-functional as of now.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
928 return NULL; |
|
9b451c84a7bf
Initial version of FSSpec and Alias code. Non-functional as of now.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
929 StandardPutFile(prompt, dft, &reply); |
| 5071 | 930 return Py_BuildValue("(Oi)",newmfssobject(&reply.sfFile), reply.sfGood); |
|
2180
9b451c84a7bf
Initial version of FSSpec and Alias code. Non-functional as of now.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
931 } |
|
9b451c84a7bf
Initial version of FSSpec and Alias code. Non-functional as of now.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
932 |
|
3787
7766360b85b8
Added SetFolder method which sets Standard File initial folder
Jack Jansen <jack.jansen@cwi.nl>
parents:
3140
diff
changeset
|
933 /* |
|
7766360b85b8
Added SetFolder method which sets Standard File initial folder
Jack Jansen <jack.jansen@cwi.nl>
parents:
3140
diff
changeset
|
934 ** Set initial directory for file dialogs */ |
| 5071 | 935 static PyObject * |
|
19066
a1b4f3a1ee07
- Don't return mac-style pathnames in unix-Python.
Jack Jansen <jack.jansen@cwi.nl>
parents:
19030
diff
changeset
|
936 mfs_SetFolder(PyObject *self, PyObject *args) |
|
3787
7766360b85b8
Added SetFolder method which sets Standard File initial folder
Jack Jansen <jack.jansen@cwi.nl>
parents:
3140
diff
changeset
|
937 { |
|
7766360b85b8
Added SetFolder method which sets Standard File initial folder
Jack Jansen <jack.jansen@cwi.nl>
parents:
3140
diff
changeset
|
938 FSSpec spec; |
|
7766360b85b8
Added SetFolder method which sets Standard File initial folder
Jack Jansen <jack.jansen@cwi.nl>
parents:
3140
diff
changeset
|
939 FSSpec ospec; |
|
7766360b85b8
Added SetFolder method which sets Standard File initial folder
Jack Jansen <jack.jansen@cwi.nl>
parents:
3140
diff
changeset
|
940 short orefnum; |
|
7766360b85b8
Added SetFolder method which sets Standard File initial folder
Jack Jansen <jack.jansen@cwi.nl>
parents:
3140
diff
changeset
|
941 long oparid; |
|
7766360b85b8
Added SetFolder method which sets Standard File initial folder
Jack Jansen <jack.jansen@cwi.nl>
parents:
3140
diff
changeset
|
942 |
|
7766360b85b8
Added SetFolder method which sets Standard File initial folder
Jack Jansen <jack.jansen@cwi.nl>
parents:
3140
diff
changeset
|
943 /* Get old values */ |
|
7766360b85b8
Added SetFolder method which sets Standard File initial folder
Jack Jansen <jack.jansen@cwi.nl>
parents:
3140
diff
changeset
|
944 orefnum = -LMGetSFSaveDisk(); |
|
7766360b85b8
Added SetFolder method which sets Standard File initial folder
Jack Jansen <jack.jansen@cwi.nl>
parents:
3140
diff
changeset
|
945 oparid = LMGetCurDirStore(); |
|
7766360b85b8
Added SetFolder method which sets Standard File initial folder
Jack Jansen <jack.jansen@cwi.nl>
parents:
3140
diff
changeset
|
946 (void)FSMakeFSSpec(orefnum, oparid, "\pplaceholder", &ospec); |
|
7766360b85b8
Added SetFolder method which sets Standard File initial folder
Jack Jansen <jack.jansen@cwi.nl>
parents:
3140
diff
changeset
|
947 |
|
7766360b85b8
Added SetFolder method which sets Standard File initial folder
Jack Jansen <jack.jansen@cwi.nl>
parents:
3140
diff
changeset
|
948 /* Go to working directory by default */ |
|
7766360b85b8
Added SetFolder method which sets Standard File initial folder
Jack Jansen <jack.jansen@cwi.nl>
parents:
3140
diff
changeset
|
949 (void)FSMakeFSSpec(0, 0, "\p:placeholder", &spec); |
| 5071 | 950 if (!PyArg_ParseTuple(args, "|O&", PyMac_GetFSSpec, &spec)) |
|
3787
7766360b85b8
Added SetFolder method which sets Standard File initial folder
Jack Jansen <jack.jansen@cwi.nl>
parents:
3140
diff
changeset
|
951 return NULL; |
|
7766360b85b8
Added SetFolder method which sets Standard File initial folder
Jack Jansen <jack.jansen@cwi.nl>
parents:
3140
diff
changeset
|
952 /* Set standard-file working directory */ |
|
7766360b85b8
Added SetFolder method which sets Standard File initial folder
Jack Jansen <jack.jansen@cwi.nl>
parents:
3140
diff
changeset
|
953 LMSetSFSaveDisk(-spec.vRefNum); |
|
7766360b85b8
Added SetFolder method which sets Standard File initial folder
Jack Jansen <jack.jansen@cwi.nl>
parents:
3140
diff
changeset
|
954 LMSetCurDirStore(spec.parID); |
| 5071 | 955 return (PyObject *)newmfssobject(&ospec); |
|
3787
7766360b85b8
Added SetFolder method which sets Standard File initial folder
Jack Jansen <jack.jansen@cwi.nl>
parents:
3140
diff
changeset
|
956 } |
|
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:
11679
diff
changeset
|
957 #endif |
|
3787
7766360b85b8
Added SetFolder method which sets Standard File initial folder
Jack Jansen <jack.jansen@cwi.nl>
parents:
3140
diff
changeset
|
958 |
| 5071 | 959 static PyObject * |
|
19066
a1b4f3a1ee07
- Don't return mac-style pathnames in unix-Python.
Jack Jansen <jack.jansen@cwi.nl>
parents:
19030
diff
changeset
|
960 mfs_FSSpec(PyObject *self, PyObject *args) |
|
2180
9b451c84a7bf
Initial version of FSSpec and Alias code. Non-functional as of now.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
961 { |
|
9b451c84a7bf
Initial version of FSSpec and Alias code. Non-functional as of now.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
962 FSSpec fss; |
|
9b451c84a7bf
Initial version of FSSpec and Alias code. Non-functional as of now.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
963 |
| 5071 | 964 if (!PyArg_ParseTuple(args, "O&", PyMac_GetFSSpec, &fss)) |
|
2180
9b451c84a7bf
Initial version of FSSpec and Alias code. Non-functional as of now.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
965 return NULL; |
| 5071 | 966 return (PyObject *)newmfssobject(&fss); |
|
2180
9b451c84a7bf
Initial version of FSSpec and Alias code. Non-functional as of now.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
967 } |
|
9b451c84a7bf
Initial version of FSSpec and Alias code. Non-functional as of now.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
968 |
| 5071 | 969 static PyObject * |
|
19066
a1b4f3a1ee07
- Don't return mac-style pathnames in unix-Python.
Jack Jansen <jack.jansen@cwi.nl>
parents:
19030
diff
changeset
|
970 mfs_FSRef(PyObject *self, PyObject *args) |
|
18434
f7f076bfcae9
Implemented minimal FSRef support, plus conversion between FSRefs, FSSpecs and pathnames where applicable.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17864
diff
changeset
|
971 { |
|
18962
d7590122f9a2
Merging appropriate 2.1.1 fixes back into the main trunk.
Jack Jansen <jack.jansen@cwi.nl>
parents:
18434
diff
changeset
|
972 #if TARGET_API_MAC_OS8 |
|
d7590122f9a2
Merging appropriate 2.1.1 fixes back into the main trunk.
Jack Jansen <jack.jansen@cwi.nl>
parents:
18434
diff
changeset
|
973 PyErr_SetString(PyExc_NotImplementedError, "FSRef objects not supported on this platform"); |
|
d7590122f9a2
Merging appropriate 2.1.1 fixes back into the main trunk.
Jack Jansen <jack.jansen@cwi.nl>
parents:
18434
diff
changeset
|
974 return 0; |
|
d7590122f9a2
Merging appropriate 2.1.1 fixes back into the main trunk.
Jack Jansen <jack.jansen@cwi.nl>
parents:
18434
diff
changeset
|
975 #else |
|
18434
f7f076bfcae9
Implemented minimal FSRef support, plus conversion between FSRefs, FSSpecs and pathnames where applicable.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17864
diff
changeset
|
976 FSRef fsr; |
|
f7f076bfcae9
Implemented minimal FSRef support, plus conversion between FSRefs, FSSpecs and pathnames where applicable.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17864
diff
changeset
|
977 |
|
f7f076bfcae9
Implemented minimal FSRef support, plus conversion between FSRefs, FSSpecs and pathnames where applicable.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17864
diff
changeset
|
978 if (!PyArg_ParseTuple(args, "O&", PyMac_GetFSRef, &fsr)) |
|
f7f076bfcae9
Implemented minimal FSRef support, plus conversion between FSRefs, FSSpecs and pathnames where applicable.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17864
diff
changeset
|
979 return NULL; |
|
f7f076bfcae9
Implemented minimal FSRef support, plus conversion between FSRefs, FSSpecs and pathnames where applicable.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17864
diff
changeset
|
980 return (PyObject *)newmfsrobject(&fsr); |
|
18962
d7590122f9a2
Merging appropriate 2.1.1 fixes back into the main trunk.
Jack Jansen <jack.jansen@cwi.nl>
parents:
18434
diff
changeset
|
981 #endif |
|
18434
f7f076bfcae9
Implemented minimal FSRef support, plus conversion between FSRefs, FSSpecs and pathnames where applicable.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17864
diff
changeset
|
982 } |
|
f7f076bfcae9
Implemented minimal FSRef support, plus conversion between FSRefs, FSSpecs and pathnames where applicable.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17864
diff
changeset
|
983 |
|
f7f076bfcae9
Implemented minimal FSRef support, plus conversion between FSRefs, FSSpecs and pathnames where applicable.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17864
diff
changeset
|
984 static PyObject * |
|
19066
a1b4f3a1ee07
- Don't return mac-style pathnames in unix-Python.
Jack Jansen <jack.jansen@cwi.nl>
parents:
19030
diff
changeset
|
985 mfs_RawFSSpec(PyObject *self, PyObject *args) |
|
2319
1e7207128167
Added RawFSSpec and RawAlias methods which turn their string arguments
Jack Jansen <jack.jansen@cwi.nl>
parents:
2275
diff
changeset
|
986 { |
|
1e7207128167
Added RawFSSpec and RawAlias methods which turn their string arguments
Jack Jansen <jack.jansen@cwi.nl>
parents:
2275
diff
changeset
|
987 FSSpec *fssp; |
|
1e7207128167
Added RawFSSpec and RawAlias methods which turn their string arguments
Jack Jansen <jack.jansen@cwi.nl>
parents:
2275
diff
changeset
|
988 int size; |
|
1e7207128167
Added RawFSSpec and RawAlias methods which turn their string arguments
Jack Jansen <jack.jansen@cwi.nl>
parents:
2275
diff
changeset
|
989 |
|
5429
ac235c9e6881
- Changed the m# format for PyArg_ParseTuple back to s#
Jack Jansen <jack.jansen@cwi.nl>
parents:
5152
diff
changeset
|
990 if (!PyArg_ParseTuple(args, "s#", &fssp, &size)) |
|
2319
1e7207128167
Added RawFSSpec and RawAlias methods which turn their string arguments
Jack Jansen <jack.jansen@cwi.nl>
parents:
2275
diff
changeset
|
991 return NULL; |
|
1e7207128167
Added RawFSSpec and RawAlias methods which turn their string arguments
Jack Jansen <jack.jansen@cwi.nl>
parents:
2275
diff
changeset
|
992 if ( size != sizeof(FSSpec) ) { |
|
1e7207128167
Added RawFSSpec and RawAlias methods which turn their string arguments
Jack Jansen <jack.jansen@cwi.nl>
parents:
2275
diff
changeset
|
993 PyErr_SetString(PyExc_TypeError, "Incorrect size for FSSpec record"); |
|
1e7207128167
Added RawFSSpec and RawAlias methods which turn their string arguments
Jack Jansen <jack.jansen@cwi.nl>
parents:
2275
diff
changeset
|
994 return NULL; |
|
1e7207128167
Added RawFSSpec and RawAlias methods which turn their string arguments
Jack Jansen <jack.jansen@cwi.nl>
parents:
2275
diff
changeset
|
995 } |
| 5071 | 996 return (PyObject *)newmfssobject(fssp); |
|
2319
1e7207128167
Added RawFSSpec and RawAlias methods which turn their string arguments
Jack Jansen <jack.jansen@cwi.nl>
parents:
2275
diff
changeset
|
997 } |
|
1e7207128167
Added RawFSSpec and RawAlias methods which turn their string arguments
Jack Jansen <jack.jansen@cwi.nl>
parents:
2275
diff
changeset
|
998 |
| 5071 | 999 static PyObject * |
|
19066
a1b4f3a1ee07
- Don't return mac-style pathnames in unix-Python.
Jack Jansen <jack.jansen@cwi.nl>
parents:
19030
diff
changeset
|
1000 mfs_RawAlias(PyObject *self, PyObject *args) |
|
2319
1e7207128167
Added RawFSSpec and RawAlias methods which turn their string arguments
Jack Jansen <jack.jansen@cwi.nl>
parents:
2275
diff
changeset
|
1001 { |
|
1e7207128167
Added RawFSSpec and RawAlias methods which turn their string arguments
Jack Jansen <jack.jansen@cwi.nl>
parents:
2275
diff
changeset
|
1002 char *dataptr; |
|
1e7207128167
Added RawFSSpec and RawAlias methods which turn their string arguments
Jack Jansen <jack.jansen@cwi.nl>
parents:
2275
diff
changeset
|
1003 Handle h; |
|
1e7207128167
Added RawFSSpec and RawAlias methods which turn their string arguments
Jack Jansen <jack.jansen@cwi.nl>
parents:
2275
diff
changeset
|
1004 int size; |
|
1e7207128167
Added RawFSSpec and RawAlias methods which turn their string arguments
Jack Jansen <jack.jansen@cwi.nl>
parents:
2275
diff
changeset
|
1005 |
|
5429
ac235c9e6881
- Changed the m# format for PyArg_ParseTuple back to s#
Jack Jansen <jack.jansen@cwi.nl>
parents:
5152
diff
changeset
|
1006 if (!PyArg_ParseTuple(args, "s#", &dataptr, &size)) |
|
2319
1e7207128167
Added RawFSSpec and RawAlias methods which turn their string arguments
Jack Jansen <jack.jansen@cwi.nl>
parents:
2275
diff
changeset
|
1007 return NULL; |
|
1e7207128167
Added RawFSSpec and RawAlias methods which turn their string arguments
Jack Jansen <jack.jansen@cwi.nl>
parents:
2275
diff
changeset
|
1008 h = NewHandle(size); |
|
1e7207128167
Added RawFSSpec and RawAlias methods which turn their string arguments
Jack Jansen <jack.jansen@cwi.nl>
parents:
2275
diff
changeset
|
1009 if ( h == NULL ) { |
|
1e7207128167
Added RawFSSpec and RawAlias methods which turn their string arguments
Jack Jansen <jack.jansen@cwi.nl>
parents:
2275
diff
changeset
|
1010 PyErr_NoMemory(); |
|
1e7207128167
Added RawFSSpec and RawAlias methods which turn their string arguments
Jack Jansen <jack.jansen@cwi.nl>
parents:
2275
diff
changeset
|
1011 return NULL; |
|
1e7207128167
Added RawFSSpec and RawAlias methods which turn their string arguments
Jack Jansen <jack.jansen@cwi.nl>
parents:
2275
diff
changeset
|
1012 } |
|
1e7207128167
Added RawFSSpec and RawAlias methods which turn their string arguments
Jack Jansen <jack.jansen@cwi.nl>
parents:
2275
diff
changeset
|
1013 HLock(h); |
|
1e7207128167
Added RawFSSpec and RawAlias methods which turn their string arguments
Jack Jansen <jack.jansen@cwi.nl>
parents:
2275
diff
changeset
|
1014 memcpy((char *)*h, dataptr, size); |
|
1e7207128167
Added RawFSSpec and RawAlias methods which turn their string arguments
Jack Jansen <jack.jansen@cwi.nl>
parents:
2275
diff
changeset
|
1015 HUnlock(h); |
| 5071 | 1016 return (PyObject *)newmfsaobject((AliasHandle)h); |
|
2319
1e7207128167
Added RawFSSpec and RawAlias methods which turn their string arguments
Jack Jansen <jack.jansen@cwi.nl>
parents:
2275
diff
changeset
|
1017 } |
|
1e7207128167
Added RawFSSpec and RawAlias methods which turn their string arguments
Jack Jansen <jack.jansen@cwi.nl>
parents:
2275
diff
changeset
|
1018 |
|
13608
a901c2c0166b
Test for TARGET_API_MAC_CARBON with #if in stead of #ifdef.
Jack Jansen <jack.jansen@cwi.nl>
parents:
13606
diff
changeset
|
1019 #if !TARGET_API_MAC_CARBON |
| 5071 | 1020 static PyObject * |
|
19066
a1b4f3a1ee07
- Don't return mac-style pathnames in unix-Python.
Jack Jansen <jack.jansen@cwi.nl>
parents:
19030
diff
changeset
|
1021 mfs_GetDirectory(PyObject *self, PyObject *args) |
|
2400
d31f694c11a8
Added GetDirectory() method
Jack Jansen <jack.jansen@cwi.nl>
parents:
2337
diff
changeset
|
1022 { |
|
d31f694c11a8
Added GetDirectory() method
Jack Jansen <jack.jansen@cwi.nl>
parents:
2337
diff
changeset
|
1023 FSSpec fsdir; |
|
d31f694c11a8
Added GetDirectory() method
Jack Jansen <jack.jansen@cwi.nl>
parents:
2337
diff
changeset
|
1024 int ok; |
|
2981
56ad247cbfcb
Added new call PromptGetFile (like StandardGetFile, but accepts a
Jack Jansen <jack.jansen@cwi.nl>
parents:
2909
diff
changeset
|
1025 char *prompt = NULL; |
|
2400
d31f694c11a8
Added GetDirectory() method
Jack Jansen <jack.jansen@cwi.nl>
parents:
2337
diff
changeset
|
1026 |
| 5071 | 1027 if (!PyArg_ParseTuple(args, "|s", &prompt) ) |
|
2400
d31f694c11a8
Added GetDirectory() method
Jack Jansen <jack.jansen@cwi.nl>
parents:
2337
diff
changeset
|
1028 return NULL; |
|
d31f694c11a8
Added GetDirectory() method
Jack Jansen <jack.jansen@cwi.nl>
parents:
2337
diff
changeset
|
1029 |
|
2981
56ad247cbfcb
Added new call PromptGetFile (like StandardGetFile, but accepts a
Jack Jansen <jack.jansen@cwi.nl>
parents:
2909
diff
changeset
|
1030 ok = PyMac_GetDirectory(&fsdir, prompt); |
| 5071 | 1031 return Py_BuildValue("(Oi)", newmfssobject(&fsdir), ok); |
|
2400
d31f694c11a8
Added GetDirectory() method
Jack Jansen <jack.jansen@cwi.nl>
parents:
2337
diff
changeset
|
1032 } |
|
13606
c9a4a1316170
pymactoolbox.h contains protoypes for all externally visible toolbox module
Jack Jansen <jack.jansen@cwi.nl>
parents:
13547
diff
changeset
|
1033 #endif |
|
2400
d31f694c11a8
Added GetDirectory() method
Jack Jansen <jack.jansen@cwi.nl>
parents:
2337
diff
changeset
|
1034 |
| 5071 | 1035 static PyObject * |
|
19066
a1b4f3a1ee07
- Don't return mac-style pathnames in unix-Python.
Jack Jansen <jack.jansen@cwi.nl>
parents:
19030
diff
changeset
|
1036 mfs_FindFolder(PyObject *self, PyObject *args) |
|
2748
39cd25678b41
Added FindFolder interface
Jack Jansen <jack.jansen@cwi.nl>
parents:
2717
diff
changeset
|
1037 { |
|
39cd25678b41
Added FindFolder interface
Jack Jansen <jack.jansen@cwi.nl>
parents:
2717
diff
changeset
|
1038 OSErr err; |
|
39cd25678b41
Added FindFolder interface
Jack Jansen <jack.jansen@cwi.nl>
parents:
2717
diff
changeset
|
1039 short where; |
|
39cd25678b41
Added FindFolder interface
Jack Jansen <jack.jansen@cwi.nl>
parents:
2717
diff
changeset
|
1040 OSType which; |
|
39cd25678b41
Added FindFolder interface
Jack Jansen <jack.jansen@cwi.nl>
parents:
2717
diff
changeset
|
1041 int create; |
|
39cd25678b41
Added FindFolder interface
Jack Jansen <jack.jansen@cwi.nl>
parents:
2717
diff
changeset
|
1042 short refnum; |
|
39cd25678b41
Added FindFolder interface
Jack Jansen <jack.jansen@cwi.nl>
parents:
2717
diff
changeset
|
1043 long dirid; |
|
39cd25678b41
Added FindFolder interface
Jack Jansen <jack.jansen@cwi.nl>
parents:
2717
diff
changeset
|
1044 |
|
17049
7eb5a6e8c98d
FindFolder argument is a short, not an unsigned short.
Jack Jansen <jack.jansen@cwi.nl>
parents:
13608
diff
changeset
|
1045 if (!PyArg_ParseTuple(args, "hO&i", &where, PyMac_GetOSType, &which, &create) ) |
|
2748
39cd25678b41
Added FindFolder interface
Jack Jansen <jack.jansen@cwi.nl>
parents:
2717
diff
changeset
|
1046 return NULL; |
|
39cd25678b41
Added FindFolder interface
Jack Jansen <jack.jansen@cwi.nl>
parents:
2717
diff
changeset
|
1047 err = FindFolder(where, which, (Boolean)create, &refnum, &dirid); |
|
39cd25678b41
Added FindFolder interface
Jack Jansen <jack.jansen@cwi.nl>
parents:
2717
diff
changeset
|
1048 if ( err ) { |
|
39cd25678b41
Added FindFolder interface
Jack Jansen <jack.jansen@cwi.nl>
parents:
2717
diff
changeset
|
1049 PyErr_Mac(ErrorObject, err); |
|
39cd25678b41
Added FindFolder interface
Jack Jansen <jack.jansen@cwi.nl>
parents:
2717
diff
changeset
|
1050 return NULL; |
|
39cd25678b41
Added FindFolder interface
Jack Jansen <jack.jansen@cwi.nl>
parents:
2717
diff
changeset
|
1051 } |
| 5071 | 1052 return Py_BuildValue("(ii)", refnum, dirid); |
|
2748
39cd25678b41
Added FindFolder interface
Jack Jansen <jack.jansen@cwi.nl>
parents:
2717
diff
changeset
|
1053 } |
|
39cd25678b41
Added FindFolder interface
Jack Jansen <jack.jansen@cwi.nl>
parents:
2717
diff
changeset
|
1054 |
| 5071 | 1055 static PyObject * |
|
19066
a1b4f3a1ee07
- Don't return mac-style pathnames in unix-Python.
Jack Jansen <jack.jansen@cwi.nl>
parents:
19030
diff
changeset
|
1056 mfs_FindApplication(PyObject *self, PyObject *args) |
|
4319
97133996e22f
Added macfs.FindApplication() to find application FSSpec given signature.
Jack Jansen <jack.jansen@cwi.nl>
parents:
4308
diff
changeset
|
1057 { |
|
97133996e22f
Added macfs.FindApplication() to find application FSSpec given signature.
Jack Jansen <jack.jansen@cwi.nl>
parents:
4308
diff
changeset
|
1058 OSErr err; |
|
97133996e22f
Added macfs.FindApplication() to find application FSSpec given signature.
Jack Jansen <jack.jansen@cwi.nl>
parents:
4308
diff
changeset
|
1059 OSType which; |
|
97133996e22f
Added macfs.FindApplication() to find application FSSpec given signature.
Jack Jansen <jack.jansen@cwi.nl>
parents:
4308
diff
changeset
|
1060 FSSpec fss; |
|
97133996e22f
Added macfs.FindApplication() to find application FSSpec given signature.
Jack Jansen <jack.jansen@cwi.nl>
parents:
4308
diff
changeset
|
1061 |
| 5071 | 1062 if (!PyArg_ParseTuple(args, "O&", PyMac_GetOSType, &which) ) |
|
4319
97133996e22f
Added macfs.FindApplication() to find application FSSpec given signature.
Jack Jansen <jack.jansen@cwi.nl>
parents:
4308
diff
changeset
|
1063 return NULL; |
|
97133996e22f
Added macfs.FindApplication() to find application FSSpec given signature.
Jack Jansen <jack.jansen@cwi.nl>
parents:
4308
diff
changeset
|
1064 err = FindApplicationFromCreator(which, &fss); |
|
97133996e22f
Added macfs.FindApplication() to find application FSSpec given signature.
Jack Jansen <jack.jansen@cwi.nl>
parents:
4308
diff
changeset
|
1065 if ( err ) { |
|
97133996e22f
Added macfs.FindApplication() to find application FSSpec given signature.
Jack Jansen <jack.jansen@cwi.nl>
parents:
4308
diff
changeset
|
1066 PyErr_Mac(ErrorObject, err); |
|
97133996e22f
Added macfs.FindApplication() to find application FSSpec given signature.
Jack Jansen <jack.jansen@cwi.nl>
parents:
4308
diff
changeset
|
1067 return NULL; |
|
97133996e22f
Added macfs.FindApplication() to find application FSSpec given signature.
Jack Jansen <jack.jansen@cwi.nl>
parents:
4308
diff
changeset
|
1068 } |
| 5071 | 1069 return (PyObject *)newmfssobject(&fss); |
|
4319
97133996e22f
Added macfs.FindApplication() to find application FSSpec given signature.
Jack Jansen <jack.jansen@cwi.nl>
parents:
4308
diff
changeset
|
1070 } |
|
97133996e22f
Added macfs.FindApplication() to find application FSSpec given signature.
Jack Jansen <jack.jansen@cwi.nl>
parents:
4308
diff
changeset
|
1071 |
| 5071 | 1072 static PyObject * |
|
19066
a1b4f3a1ee07
- Don't return mac-style pathnames in unix-Python.
Jack Jansen <jack.jansen@cwi.nl>
parents:
19030
diff
changeset
|
1073 mfs_FInfo(PyObject *self, PyObject *args) |
|
2909
f9b1069a3e26
Added interfaces to {Get,Set}FInfo and accompanying objects
Jack Jansen <jack.jansen@cwi.nl>
parents:
2748
diff
changeset
|
1074 { |
| 5071 | 1075 return (PyObject *)newmfsiobject(); |
|
2909
f9b1069a3e26
Added interfaces to {Get,Set}FInfo and accompanying objects
Jack Jansen <jack.jansen@cwi.nl>
parents:
2748
diff
changeset
|
1076 } |
|
f9b1069a3e26
Added interfaces to {Get,Set}FInfo and accompanying objects
Jack Jansen <jack.jansen@cwi.nl>
parents:
2748
diff
changeset
|
1077 |
|
5743
c606dd61544a
Added NewAliasMinimalFromFullPath(), and allow alias.Resolve() to return
Jack Jansen <jack.jansen@cwi.nl>
parents:
5429
diff
changeset
|
1078 static PyObject * |
|
19066
a1b4f3a1ee07
- Don't return mac-style pathnames in unix-Python.
Jack Jansen <jack.jansen@cwi.nl>
parents:
19030
diff
changeset
|
1079 mfs_NewAliasMinimalFromFullPath(PyObject *self, PyObject *args) |
|
5743
c606dd61544a
Added NewAliasMinimalFromFullPath(), and allow alias.Resolve() to return
Jack Jansen <jack.jansen@cwi.nl>
parents:
5429
diff
changeset
|
1080 { |
|
c606dd61544a
Added NewAliasMinimalFromFullPath(), and allow alias.Resolve() to return
Jack Jansen <jack.jansen@cwi.nl>
parents:
5429
diff
changeset
|
1081 OSErr err; |
|
c606dd61544a
Added NewAliasMinimalFromFullPath(), and allow alias.Resolve() to return
Jack Jansen <jack.jansen@cwi.nl>
parents:
5429
diff
changeset
|
1082 char *fullpath; |
|
c606dd61544a
Added NewAliasMinimalFromFullPath(), and allow alias.Resolve() to return
Jack Jansen <jack.jansen@cwi.nl>
parents:
5429
diff
changeset
|
1083 int fullpathlen; |
|
c606dd61544a
Added NewAliasMinimalFromFullPath(), and allow alias.Resolve() to return
Jack Jansen <jack.jansen@cwi.nl>
parents:
5429
diff
changeset
|
1084 AliasHandle alias; |
|
c606dd61544a
Added NewAliasMinimalFromFullPath(), and allow alias.Resolve() to return
Jack Jansen <jack.jansen@cwi.nl>
parents:
5429
diff
changeset
|
1085 Str32 zonename; |
|
c606dd61544a
Added NewAliasMinimalFromFullPath(), and allow alias.Resolve() to return
Jack Jansen <jack.jansen@cwi.nl>
parents:
5429
diff
changeset
|
1086 Str31 servername; |
|
c606dd61544a
Added NewAliasMinimalFromFullPath(), and allow alias.Resolve() to return
Jack Jansen <jack.jansen@cwi.nl>
parents:
5429
diff
changeset
|
1087 |
|
c606dd61544a
Added NewAliasMinimalFromFullPath(), and allow alias.Resolve() to return
Jack Jansen <jack.jansen@cwi.nl>
parents:
5429
diff
changeset
|
1088 if (!PyArg_ParseTuple(args, "s#", &fullpath, &fullpathlen) ) |
|
c606dd61544a
Added NewAliasMinimalFromFullPath(), and allow alias.Resolve() to return
Jack Jansen <jack.jansen@cwi.nl>
parents:
5429
diff
changeset
|
1089 return NULL; |
|
c606dd61544a
Added NewAliasMinimalFromFullPath(), and allow alias.Resolve() to return
Jack Jansen <jack.jansen@cwi.nl>
parents:
5429
diff
changeset
|
1090 zonename[0] = 0; |
|
c606dd61544a
Added NewAliasMinimalFromFullPath(), and allow alias.Resolve() to return
Jack Jansen <jack.jansen@cwi.nl>
parents:
5429
diff
changeset
|
1091 servername[0] = 0; |
|
c606dd61544a
Added NewAliasMinimalFromFullPath(), and allow alias.Resolve() to return
Jack Jansen <jack.jansen@cwi.nl>
parents:
5429
diff
changeset
|
1092 err = NewAliasMinimalFromFullPath(fullpathlen, (Ptr)fullpath, zonename, |
|
c606dd61544a
Added NewAliasMinimalFromFullPath(), and allow alias.Resolve() to return
Jack Jansen <jack.jansen@cwi.nl>
parents:
5429
diff
changeset
|
1093 servername, &alias); |
|
c606dd61544a
Added NewAliasMinimalFromFullPath(), and allow alias.Resolve() to return
Jack Jansen <jack.jansen@cwi.nl>
parents:
5429
diff
changeset
|
1094 if ( err ) { |
|
c606dd61544a
Added NewAliasMinimalFromFullPath(), and allow alias.Resolve() to return
Jack Jansen <jack.jansen@cwi.nl>
parents:
5429
diff
changeset
|
1095 PyErr_Mac(ErrorObject, err); |
|
c606dd61544a
Added NewAliasMinimalFromFullPath(), and allow alias.Resolve() to return
Jack Jansen <jack.jansen@cwi.nl>
parents:
5429
diff
changeset
|
1096 return NULL; |
|
c606dd61544a
Added NewAliasMinimalFromFullPath(), and allow alias.Resolve() to return
Jack Jansen <jack.jansen@cwi.nl>
parents:
5429
diff
changeset
|
1097 } |
|
c606dd61544a
Added NewAliasMinimalFromFullPath(), and allow alias.Resolve() to return
Jack Jansen <jack.jansen@cwi.nl>
parents:
5429
diff
changeset
|
1098 return (PyObject *)newmfsaobject(alias); |
|
c606dd61544a
Added NewAliasMinimalFromFullPath(), and allow alias.Resolve() to return
Jack Jansen <jack.jansen@cwi.nl>
parents:
5429
diff
changeset
|
1099 } |
|
c606dd61544a
Added NewAliasMinimalFromFullPath(), and allow alias.Resolve() to return
Jack Jansen <jack.jansen@cwi.nl>
parents:
5429
diff
changeset
|
1100 |
|
c606dd61544a
Added NewAliasMinimalFromFullPath(), and allow alias.Resolve() to return
Jack Jansen <jack.jansen@cwi.nl>
parents:
5429
diff
changeset
|
1101 |
|
2180
9b451c84a7bf
Initial version of FSSpec and Alias code. Non-functional as of now.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
1102 /* List of methods defined in the module */ |
|
9b451c84a7bf
Initial version of FSSpec and Alias code. Non-functional as of now.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
1103 |
| 5071 | 1104 static struct PyMethodDef mfs_methods[] = { |
| 2249 | 1105 {"ResolveAliasFile", mfs_ResolveAliasFile, 1}, |
|
13608
a901c2c0166b
Test for TARGET_API_MAC_CARBON with #if in stead of #ifdef.
Jack Jansen <jack.jansen@cwi.nl>
parents:
13606
diff
changeset
|
1106 #if !TARGET_API_MAC_CARBON |
| 2249 | 1107 {"StandardGetFile", mfs_StandardGetFile, 1}, |
|
2981
56ad247cbfcb
Added new call PromptGetFile (like StandardGetFile, but accepts a
Jack Jansen <jack.jansen@cwi.nl>
parents:
2909
diff
changeset
|
1108 {"PromptGetFile", mfs_PromptGetFile, 1}, |
| 2249 | 1109 {"StandardPutFile", mfs_StandardPutFile, 1}, |
|
2400
d31f694c11a8
Added GetDirectory() method
Jack Jansen <jack.jansen@cwi.nl>
parents:
2337
diff
changeset
|
1110 {"GetDirectory", mfs_GetDirectory, 1}, |
|
3787
7766360b85b8
Added SetFolder method which sets Standard File initial folder
Jack Jansen <jack.jansen@cwi.nl>
parents:
3140
diff
changeset
|
1111 {"SetFolder", mfs_SetFolder, 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:
11679
diff
changeset
|
1112 #endif |
| 2249 | 1113 {"FSSpec", mfs_FSSpec, 1}, |
|
18434
f7f076bfcae9
Implemented minimal FSRef support, plus conversion between FSRefs, FSSpecs and pathnames where applicable.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17864
diff
changeset
|
1114 {"FSRef", mfs_FSRef, 1}, |
|
2319
1e7207128167
Added RawFSSpec and RawAlias methods which turn their string arguments
Jack Jansen <jack.jansen@cwi.nl>
parents:
2275
diff
changeset
|
1115 {"RawFSSpec", mfs_RawFSSpec, 1}, |
|
1e7207128167
Added RawFSSpec and RawAlias methods which turn their string arguments
Jack Jansen <jack.jansen@cwi.nl>
parents:
2275
diff
changeset
|
1116 {"RawAlias", mfs_RawAlias, 1}, |
|
2748
39cd25678b41
Added FindFolder interface
Jack Jansen <jack.jansen@cwi.nl>
parents:
2717
diff
changeset
|
1117 {"FindFolder", mfs_FindFolder, 1}, |
|
4319
97133996e22f
Added macfs.FindApplication() to find application FSSpec given signature.
Jack Jansen <jack.jansen@cwi.nl>
parents:
4308
diff
changeset
|
1118 {"FindApplication", mfs_FindApplication, 1}, |
|
2909
f9b1069a3e26
Added interfaces to {Get,Set}FInfo and accompanying objects
Jack Jansen <jack.jansen@cwi.nl>
parents:
2748
diff
changeset
|
1119 {"FInfo", mfs_FInfo, 1}, |
|
5743
c606dd61544a
Added NewAliasMinimalFromFullPath(), and allow alias.Resolve() to return
Jack Jansen <jack.jansen@cwi.nl>
parents:
5429
diff
changeset
|
1120 {"NewAliasMinimalFromFullPath", mfs_NewAliasMinimalFromFullPath, 1}, |
|
2180
9b451c84a7bf
Initial version of FSSpec and Alias code. Non-functional as of now.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
1121 |
|
9b451c84a7bf
Initial version of FSSpec and Alias code. Non-functional as of now.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
1122 {NULL, NULL} /* sentinel */ |
|
9b451c84a7bf
Initial version of FSSpec and Alias code. Non-functional as of now.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
1123 }; |
|
9b451c84a7bf
Initial version of FSSpec and Alias code. Non-functional as of now.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
1124 |
|
18434
f7f076bfcae9
Implemented minimal FSRef support, plus conversion between FSRefs, FSSpecs and pathnames where applicable.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17864
diff
changeset
|
1125 /* |
|
f7f076bfcae9
Implemented minimal FSRef support, plus conversion between FSRefs, FSSpecs and pathnames where applicable.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17864
diff
changeset
|
1126 ** Convert a Python object to an FSSpec. |
|
f7f076bfcae9
Implemented minimal FSRef support, plus conversion between FSRefs, FSSpecs and pathnames where applicable.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17864
diff
changeset
|
1127 ** The object may either be a full pathname, an FSSpec, an FSRef or a triple |
|
f7f076bfcae9
Implemented minimal FSRef support, plus conversion between FSRefs, FSSpecs and pathnames where applicable.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17864
diff
changeset
|
1128 ** (vrefnum, dirid, path). |
|
f7f076bfcae9
Implemented minimal FSRef support, plus conversion between FSRefs, FSSpecs and pathnames where applicable.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17864
diff
changeset
|
1129 */ |
|
f7f076bfcae9
Implemented minimal FSRef support, plus conversion between FSRefs, FSSpecs and pathnames where applicable.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17864
diff
changeset
|
1130 int |
|
f7f076bfcae9
Implemented minimal FSRef support, plus conversion between FSRefs, FSSpecs and pathnames where applicable.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17864
diff
changeset
|
1131 PyMac_GetFSRef(PyObject *v, FSRef *fsr) |
|
f7f076bfcae9
Implemented minimal FSRef support, plus conversion between FSRefs, FSSpecs and pathnames where applicable.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17864
diff
changeset
|
1132 { |
|
18962
d7590122f9a2
Merging appropriate 2.1.1 fixes back into the main trunk.
Jack Jansen <jack.jansen@cwi.nl>
parents:
18434
diff
changeset
|
1133 #if TARGET_API_MAC_OS8 |
|
20900
0b6332c2aba0
Added an error message when using FSRef objects on platforms that don't
Jack Jansen <jack.jansen@cwi.nl>
parents:
20806
diff
changeset
|
1134 PyErr_SetString(PyExc_TypeError, "FSRef objects not supported on this platform"); |
|
18962
d7590122f9a2
Merging appropriate 2.1.1 fixes back into the main trunk.
Jack Jansen <jack.jansen@cwi.nl>
parents:
18434
diff
changeset
|
1135 return 0; |
|
d7590122f9a2
Merging appropriate 2.1.1 fixes back into the main trunk.
Jack Jansen <jack.jansen@cwi.nl>
parents:
18434
diff
changeset
|
1136 #else |
|
18434
f7f076bfcae9
Implemented minimal FSRef support, plus conversion between FSRefs, FSSpecs and pathnames where applicable.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17864
diff
changeset
|
1137 /* If it's an FSRef we're also okay. */ |
|
f7f076bfcae9
Implemented minimal FSRef support, plus conversion between FSRefs, FSSpecs and pathnames where applicable.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17864
diff
changeset
|
1138 if (_mfs_GetFSRefFromFSRef(v, fsr)) |
|
f7f076bfcae9
Implemented minimal FSRef support, plus conversion between FSRefs, FSSpecs and pathnames where applicable.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17864
diff
changeset
|
1139 return 1; |
|
f7f076bfcae9
Implemented minimal FSRef support, plus conversion between FSRefs, FSSpecs and pathnames where applicable.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17864
diff
changeset
|
1140 /* first check whether it already is an FSSpec */ |
|
f7f076bfcae9
Implemented minimal FSRef support, plus conversion between FSRefs, FSSpecs and pathnames where applicable.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17864
diff
changeset
|
1141 if ( _mfs_GetFSRefFromFSSpec(v, fsr) ) |
|
f7f076bfcae9
Implemented minimal FSRef support, plus conversion between FSRefs, FSSpecs and pathnames where applicable.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17864
diff
changeset
|
1142 return 1; |
|
f7f076bfcae9
Implemented minimal FSRef support, plus conversion between FSRefs, FSSpecs and pathnames where applicable.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17864
diff
changeset
|
1143 if ( PyString_Check(v) ) { |
|
18979
3dd8e64f512e
PyMac_GetFSSpec must be called via the dylib glue code on OSX.
Jack Jansen <jack.jansen@cwi.nl>
parents:
18962
diff
changeset
|
1144 #if TARGET_API_MAC_OSX |
|
3dd8e64f512e
PyMac_GetFSSpec must be called via the dylib glue code on OSX.
Jack Jansen <jack.jansen@cwi.nl>
parents:
18962
diff
changeset
|
1145 OSStatus err; |
|
3dd8e64f512e
PyMac_GetFSSpec must be called via the dylib glue code on OSX.
Jack Jansen <jack.jansen@cwi.nl>
parents:
18962
diff
changeset
|
1146 if ( (err=FSPathMakeRef(PyString_AsString(v), fsr, NULL)) ) { |
|
3dd8e64f512e
PyMac_GetFSSpec must be called via the dylib glue code on OSX.
Jack Jansen <jack.jansen@cwi.nl>
parents:
18962
diff
changeset
|
1147 PyErr_Mac(ErrorObject, err); |
|
3dd8e64f512e
PyMac_GetFSSpec must be called via the dylib glue code on OSX.
Jack Jansen <jack.jansen@cwi.nl>
parents:
18962
diff
changeset
|
1148 return 0; |
|
3dd8e64f512e
PyMac_GetFSSpec must be called via the dylib glue code on OSX.
Jack Jansen <jack.jansen@cwi.nl>
parents:
18962
diff
changeset
|
1149 } |
|
3dd8e64f512e
PyMac_GetFSSpec must be called via the dylib glue code on OSX.
Jack Jansen <jack.jansen@cwi.nl>
parents:
18962
diff
changeset
|
1150 return 1; |
|
3dd8e64f512e
PyMac_GetFSSpec must be called via the dylib glue code on OSX.
Jack Jansen <jack.jansen@cwi.nl>
parents:
18962
diff
changeset
|
1151 #else |
|
18434
f7f076bfcae9
Implemented minimal FSRef support, plus conversion between FSRefs, FSSpecs and pathnames where applicable.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17864
diff
changeset
|
1152 PyErr_SetString(PyExc_NotImplementedError, "Cannot create an FSRef from a pathname on this platform"); |
|
f7f076bfcae9
Implemented minimal FSRef support, plus conversion between FSRefs, FSSpecs and pathnames where applicable.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17864
diff
changeset
|
1153 return 0; |
|
18979
3dd8e64f512e
PyMac_GetFSSpec must be called via the dylib glue code on OSX.
Jack Jansen <jack.jansen@cwi.nl>
parents:
18962
diff
changeset
|
1154 #endif |
|
18434
f7f076bfcae9
Implemented minimal FSRef support, plus conversion between FSRefs, FSSpecs and pathnames where applicable.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17864
diff
changeset
|
1155 } |
|
f7f076bfcae9
Implemented minimal FSRef support, plus conversion between FSRefs, FSSpecs and pathnames where applicable.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17864
diff
changeset
|
1156 PyErr_SetString(PyExc_TypeError, "FSRef argument should be existing FSRef, FSSpec or (OSX only) pathname"); |
|
f7f076bfcae9
Implemented minimal FSRef support, plus conversion between FSRefs, FSSpecs and pathnames where applicable.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17864
diff
changeset
|
1157 return 0; |
|
18962
d7590122f9a2
Merging appropriate 2.1.1 fixes back into the main trunk.
Jack Jansen <jack.jansen@cwi.nl>
parents:
18434
diff
changeset
|
1158 #endif |
|
18434
f7f076bfcae9
Implemented minimal FSRef support, plus conversion between FSRefs, FSSpecs and pathnames where applicable.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17864
diff
changeset
|
1159 } |
|
f7f076bfcae9
Implemented minimal FSRef support, plus conversion between FSRefs, FSSpecs and pathnames where applicable.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17864
diff
changeset
|
1160 |
|
f7f076bfcae9
Implemented minimal FSRef support, plus conversion between FSRefs, FSSpecs and pathnames where applicable.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17864
diff
changeset
|
1161 /* Convert FSSpec to PyObject */ |
|
f7f076bfcae9
Implemented minimal FSRef support, plus conversion between FSRefs, FSSpecs and pathnames where applicable.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17864
diff
changeset
|
1162 PyObject *PyMac_BuildFSRef(FSRef *v) |
|
f7f076bfcae9
Implemented minimal FSRef support, plus conversion between FSRefs, FSSpecs and pathnames where applicable.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17864
diff
changeset
|
1163 { |
|
18962
d7590122f9a2
Merging appropriate 2.1.1 fixes back into the main trunk.
Jack Jansen <jack.jansen@cwi.nl>
parents:
18434
diff
changeset
|
1164 #if TARGET_API_MAC_OS8 |
|
d7590122f9a2
Merging appropriate 2.1.1 fixes back into the main trunk.
Jack Jansen <jack.jansen@cwi.nl>
parents:
18434
diff
changeset
|
1165 return NULL; |
|
d7590122f9a2
Merging appropriate 2.1.1 fixes back into the main trunk.
Jack Jansen <jack.jansen@cwi.nl>
parents:
18434
diff
changeset
|
1166 #else |
|
18434
f7f076bfcae9
Implemented minimal FSRef support, plus conversion between FSRefs, FSSpecs and pathnames where applicable.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17864
diff
changeset
|
1167 return (PyObject *)newmfsrobject(v); |
|
18962
d7590122f9a2
Merging appropriate 2.1.1 fixes back into the main trunk.
Jack Jansen <jack.jansen@cwi.nl>
parents:
18434
diff
changeset
|
1168 #endif |
|
18434
f7f076bfcae9
Implemented minimal FSRef support, plus conversion between FSRefs, FSSpecs and pathnames where applicable.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17864
diff
changeset
|
1169 } |
|
f7f076bfcae9
Implemented minimal FSRef support, plus conversion between FSRefs, FSSpecs and pathnames where applicable.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17864
diff
changeset
|
1170 |
|
f7f076bfcae9
Implemented minimal FSRef support, plus conversion between FSRefs, FSSpecs and pathnames where applicable.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17864
diff
changeset
|
1171 /* |
|
f7f076bfcae9
Implemented minimal FSRef support, plus conversion between FSRefs, FSSpecs and pathnames where applicable.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17864
diff
changeset
|
1172 ** Convert a Python object to an FSRef. |
|
f7f076bfcae9
Implemented minimal FSRef support, plus conversion between FSRefs, FSSpecs and pathnames where applicable.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17864
diff
changeset
|
1173 ** The object may either be a full pathname (OSX only), an FSSpec or an FSRef. |
|
f7f076bfcae9
Implemented minimal FSRef support, plus conversion between FSRefs, FSSpecs and pathnames where applicable.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17864
diff
changeset
|
1174 */ |
|
f7f076bfcae9
Implemented minimal FSRef support, plus conversion between FSRefs, FSSpecs and pathnames where applicable.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17864
diff
changeset
|
1175 int |
|
f7f076bfcae9
Implemented minimal FSRef support, plus conversion between FSRefs, FSSpecs and pathnames where applicable.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17864
diff
changeset
|
1176 PyMac_GetFSSpec(PyObject *v, FSSpec *fs) |
|
f7f076bfcae9
Implemented minimal FSRef support, plus conversion between FSRefs, FSSpecs and pathnames where applicable.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17864
diff
changeset
|
1177 { |
|
f7f076bfcae9
Implemented minimal FSRef support, plus conversion between FSRefs, FSSpecs and pathnames where applicable.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17864
diff
changeset
|
1178 Str255 path; |
|
f7f076bfcae9
Implemented minimal FSRef support, plus conversion between FSRefs, FSSpecs and pathnames where applicable.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17864
diff
changeset
|
1179 short refnum; |
|
f7f076bfcae9
Implemented minimal FSRef support, plus conversion between FSRefs, FSSpecs and pathnames where applicable.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17864
diff
changeset
|
1180 long parid; |
|
f7f076bfcae9
Implemented minimal FSRef support, plus conversion between FSRefs, FSSpecs and pathnames where applicable.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17864
diff
changeset
|
1181 OSErr err; |
|
f7f076bfcae9
Implemented minimal FSRef support, plus conversion between FSRefs, FSSpecs and pathnames where applicable.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17864
diff
changeset
|
1182 |
|
f7f076bfcae9
Implemented minimal FSRef support, plus conversion between FSRefs, FSSpecs and pathnames where applicable.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17864
diff
changeset
|
1183 /* first check whether it already is an FSSpec */ |
|
f7f076bfcae9
Implemented minimal FSRef support, plus conversion between FSRefs, FSSpecs and pathnames where applicable.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17864
diff
changeset
|
1184 if ( _mfs_GetFSSpecFromFSSpec(v, fs) ) |
|
f7f076bfcae9
Implemented minimal FSRef support, plus conversion between FSRefs, FSSpecs and pathnames where applicable.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17864
diff
changeset
|
1185 return 1; |
|
f7f076bfcae9
Implemented minimal FSRef support, plus conversion between FSRefs, FSSpecs and pathnames where applicable.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17864
diff
changeset
|
1186 /* If it's an FSRef we're also okay. */ |
|
f7f076bfcae9
Implemented minimal FSRef support, plus conversion between FSRefs, FSSpecs and pathnames where applicable.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17864
diff
changeset
|
1187 if (_mfs_GetFSSpecFromFSRef(v, fs)) |
|
f7f076bfcae9
Implemented minimal FSRef support, plus conversion between FSRefs, FSSpecs and pathnames where applicable.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17864
diff
changeset
|
1188 return 1; |
|
f7f076bfcae9
Implemented minimal FSRef support, plus conversion between FSRefs, FSSpecs and pathnames where applicable.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17864
diff
changeset
|
1189 if ( PyString_Check(v) ) { |
|
f7f076bfcae9
Implemented minimal FSRef support, plus conversion between FSRefs, FSSpecs and pathnames where applicable.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17864
diff
changeset
|
1190 /* It's a pathname */ |
|
f7f076bfcae9
Implemented minimal FSRef support, plus conversion between FSRefs, FSSpecs and pathnames where applicable.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17864
diff
changeset
|
1191 if( !PyArg_Parse(v, "O&", PyMac_GetStr255, &path) ) |
|
f7f076bfcae9
Implemented minimal FSRef support, plus conversion between FSRefs, FSSpecs and pathnames where applicable.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17864
diff
changeset
|
1192 return 0; |
|
f7f076bfcae9
Implemented minimal FSRef support, plus conversion between FSRefs, FSSpecs and pathnames where applicable.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17864
diff
changeset
|
1193 refnum = 0; /* XXXX Should get CurWD here?? */ |
|
f7f076bfcae9
Implemented minimal FSRef support, plus conversion between FSRefs, FSSpecs and pathnames where applicable.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17864
diff
changeset
|
1194 parid = 0; |
|
f7f076bfcae9
Implemented minimal FSRef support, plus conversion between FSRefs, FSSpecs and pathnames where applicable.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17864
diff
changeset
|
1195 } else { |
|
f7f076bfcae9
Implemented minimal FSRef support, plus conversion between FSRefs, FSSpecs and pathnames where applicable.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17864
diff
changeset
|
1196 if( !PyArg_Parse(v, "(hlO&); FSSpec should be FSSpec, FSRef, fullpath or (vrefnum,dirid,path)", |
|
f7f076bfcae9
Implemented minimal FSRef support, plus conversion between FSRefs, FSSpecs and pathnames where applicable.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17864
diff
changeset
|
1197 &refnum, &parid, PyMac_GetStr255, &path)) { |
|
f7f076bfcae9
Implemented minimal FSRef support, plus conversion between FSRefs, FSSpecs and pathnames where applicable.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17864
diff
changeset
|
1198 return 0; |
|
f7f076bfcae9
Implemented minimal FSRef support, plus conversion between FSRefs, FSSpecs and pathnames where applicable.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17864
diff
changeset
|
1199 } |
|
f7f076bfcae9
Implemented minimal FSRef support, plus conversion between FSRefs, FSSpecs and pathnames where applicable.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17864
diff
changeset
|
1200 } |
|
f7f076bfcae9
Implemented minimal FSRef support, plus conversion between FSRefs, FSSpecs and pathnames where applicable.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17864
diff
changeset
|
1201 err = FSMakeFSSpec(refnum, parid, path, fs); |
|
f7f076bfcae9
Implemented minimal FSRef support, plus conversion between FSRefs, FSSpecs and pathnames where applicable.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17864
diff
changeset
|
1202 if ( err && err != fnfErr ) { |
|
f7f076bfcae9
Implemented minimal FSRef support, plus conversion between FSRefs, FSSpecs and pathnames where applicable.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17864
diff
changeset
|
1203 PyMac_Error(err); |
|
f7f076bfcae9
Implemented minimal FSRef support, plus conversion between FSRefs, FSSpecs and pathnames where applicable.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17864
diff
changeset
|
1204 return 0; |
|
f7f076bfcae9
Implemented minimal FSRef support, plus conversion between FSRefs, FSSpecs and pathnames where applicable.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17864
diff
changeset
|
1205 } |
|
f7f076bfcae9
Implemented minimal FSRef support, plus conversion between FSRefs, FSSpecs and pathnames where applicable.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17864
diff
changeset
|
1206 return 1; |
|
f7f076bfcae9
Implemented minimal FSRef support, plus conversion between FSRefs, FSSpecs and pathnames where applicable.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17864
diff
changeset
|
1207 } |
|
f7f076bfcae9
Implemented minimal FSRef support, plus conversion between FSRefs, FSSpecs and pathnames where applicable.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17864
diff
changeset
|
1208 |
|
f7f076bfcae9
Implemented minimal FSRef support, plus conversion between FSRefs, FSSpecs and pathnames where applicable.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17864
diff
changeset
|
1209 /* Convert FSSpec to PyObject */ |
|
f7f076bfcae9
Implemented minimal FSRef support, plus conversion between FSRefs, FSSpecs and pathnames where applicable.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17864
diff
changeset
|
1210 PyObject *PyMac_BuildFSSpec(FSSpec *v) |
|
f7f076bfcae9
Implemented minimal FSRef support, plus conversion between FSRefs, FSSpecs and pathnames where applicable.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17864
diff
changeset
|
1211 { |
|
f7f076bfcae9
Implemented minimal FSRef support, plus conversion between FSRefs, FSSpecs and pathnames where applicable.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17864
diff
changeset
|
1212 return (PyObject *)newmfssobject(v); |
|
f7f076bfcae9
Implemented minimal FSRef support, plus conversion between FSRefs, FSSpecs and pathnames where applicable.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17864
diff
changeset
|
1213 } |
|
2180
9b451c84a7bf
Initial version of FSSpec and Alias code. Non-functional as of now.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
1214 |
|
20794
83a3e21a7cc3
Moved macfsn hackery from macmain.c to macfsmodule.c so it loads
Just van Rossum <just@letterror.com>
parents:
19841
diff
changeset
|
1215 |
|
83a3e21a7cc3
Moved macfsn hackery from macmain.c to macfsmodule.c so it loads
Just van Rossum <just@letterror.com>
parents:
19841
diff
changeset
|
1216 /* |
|
83a3e21a7cc3
Moved macfsn hackery from macmain.c to macfsmodule.c so it loads
Just van Rossum <just@letterror.com>
parents:
19841
diff
changeset
|
1217 ** Import the macfsn module, which will override the Standard File |
|
83a3e21a7cc3
Moved macfsn hackery from macmain.c to macfsmodule.c so it loads
Just van Rossum <just@letterror.com>
parents:
19841
diff
changeset
|
1218 ** calls in the macfs builtin module by Navigation Services versions, |
|
83a3e21a7cc3
Moved macfsn hackery from macmain.c to macfsmodule.c so it loads
Just van Rossum <just@letterror.com>
parents:
19841
diff
changeset
|
1219 ** if available on this machine. |
|
83a3e21a7cc3
Moved macfsn hackery from macmain.c to macfsmodule.c so it loads
Just van Rossum <just@letterror.com>
parents:
19841
diff
changeset
|
1220 */ |
|
83a3e21a7cc3
Moved macfsn hackery from macmain.c to macfsmodule.c so it loads
Just van Rossum <just@letterror.com>
parents:
19841
diff
changeset
|
1221 static void |
|
83a3e21a7cc3
Moved macfsn hackery from macmain.c to macfsmodule.c so it loads
Just van Rossum <just@letterror.com>
parents:
19841
diff
changeset
|
1222 PyMac_InstallNavServicesForSF(void) |
|
83a3e21a7cc3
Moved macfsn hackery from macmain.c to macfsmodule.c so it loads
Just van Rossum <just@letterror.com>
parents:
19841
diff
changeset
|
1223 { |
|
20806
42f22ea6a0f1
Under MachO-Python unconditionally import macfsn.
Jack Jansen <jack.jansen@cwi.nl>
parents:
20794
diff
changeset
|
1224 #ifndef TARGET_API_MAC_OSX |
|
20794
83a3e21a7cc3
Moved macfsn hackery from macmain.c to macfsmodule.c so it loads
Just van Rossum <just@letterror.com>
parents:
19841
diff
changeset
|
1225 if ( !PyMac_options.nonavservice ) { |
|
20806
42f22ea6a0f1
Under MachO-Python unconditionally import macfsn.
Jack Jansen <jack.jansen@cwi.nl>
parents:
20794
diff
changeset
|
1226 #endif |
|
20794
83a3e21a7cc3
Moved macfsn hackery from macmain.c to macfsmodule.c so it loads
Just van Rossum <just@letterror.com>
parents:
19841
diff
changeset
|
1227 PyObject *m = PyImport_ImportModule("macfsn"); |
|
83a3e21a7cc3
Moved macfsn hackery from macmain.c to macfsmodule.c so it loads
Just van Rossum <just@letterror.com>
parents:
19841
diff
changeset
|
1228 |
|
83a3e21a7cc3
Moved macfsn hackery from macmain.c to macfsmodule.c so it loads
Just van Rossum <just@letterror.com>
parents:
19841
diff
changeset
|
1229 if ( m == NULL ) { |
|
83a3e21a7cc3
Moved macfsn hackery from macmain.c to macfsmodule.c so it loads
Just van Rossum <just@letterror.com>
parents:
19841
diff
changeset
|
1230 PySys_WriteStderr("'import macfsn' failed; "); |
|
83a3e21a7cc3
Moved macfsn hackery from macmain.c to macfsmodule.c so it loads
Just van Rossum <just@letterror.com>
parents:
19841
diff
changeset
|
1231 if (Py_VerboseFlag) { |
|
83a3e21a7cc3
Moved macfsn hackery from macmain.c to macfsmodule.c so it loads
Just van Rossum <just@letterror.com>
parents:
19841
diff
changeset
|
1232 PySys_WriteStderr("traceback:\n"); |
|
83a3e21a7cc3
Moved macfsn hackery from macmain.c to macfsmodule.c so it loads
Just van Rossum <just@letterror.com>
parents:
19841
diff
changeset
|
1233 PyErr_Print(); |
|
83a3e21a7cc3
Moved macfsn hackery from macmain.c to macfsmodule.c so it loads
Just van Rossum <just@letterror.com>
parents:
19841
diff
changeset
|
1234 } |
|
83a3e21a7cc3
Moved macfsn hackery from macmain.c to macfsmodule.c so it loads
Just van Rossum <just@letterror.com>
parents:
19841
diff
changeset
|
1235 else { |
|
83a3e21a7cc3
Moved macfsn hackery from macmain.c to macfsmodule.c so it loads
Just van Rossum <just@letterror.com>
parents:
19841
diff
changeset
|
1236 PySys_WriteStderr("use -v for traceback\n"); |
|
83a3e21a7cc3
Moved macfsn hackery from macmain.c to macfsmodule.c so it loads
Just van Rossum <just@letterror.com>
parents:
19841
diff
changeset
|
1237 } |
|
83a3e21a7cc3
Moved macfsn hackery from macmain.c to macfsmodule.c so it loads
Just van Rossum <just@letterror.com>
parents:
19841
diff
changeset
|
1238 PyErr_Clear(); |
|
83a3e21a7cc3
Moved macfsn hackery from macmain.c to macfsmodule.c so it loads
Just van Rossum <just@letterror.com>
parents:
19841
diff
changeset
|
1239 } |
|
20806
42f22ea6a0f1
Under MachO-Python unconditionally import macfsn.
Jack Jansen <jack.jansen@cwi.nl>
parents:
20794
diff
changeset
|
1240 #ifndef TARGET_API_MAC_OSX |
|
20794
83a3e21a7cc3
Moved macfsn hackery from macmain.c to macfsmodule.c so it loads
Just van Rossum <just@letterror.com>
parents:
19841
diff
changeset
|
1241 } |
|
20806
42f22ea6a0f1
Under MachO-Python unconditionally import macfsn.
Jack Jansen <jack.jansen@cwi.nl>
parents:
20794
diff
changeset
|
1242 #endif |
|
20794
83a3e21a7cc3
Moved macfsn hackery from macmain.c to macfsmodule.c so it loads
Just van Rossum <just@letterror.com>
parents:
19841
diff
changeset
|
1243 } |
|
83a3e21a7cc3
Moved macfsn hackery from macmain.c to macfsmodule.c so it loads
Just van Rossum <just@letterror.com>
parents:
19841
diff
changeset
|
1244 |
|
83a3e21a7cc3
Moved macfsn hackery from macmain.c to macfsmodule.c so it loads
Just van Rossum <just@letterror.com>
parents:
19841
diff
changeset
|
1245 |
|
2180
9b451c84a7bf
Initial version of FSSpec and Alias code. Non-functional as of now.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
1246 /* Initialization function for the module (*must* be called initmacfs) */ |
|
9b451c84a7bf
Initial version of FSSpec and Alias code. Non-functional as of now.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
1247 |
|
9b451c84a7bf
Initial version of FSSpec and Alias code. Non-functional as of now.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
1248 void |
|
19066
a1b4f3a1ee07
- Don't return mac-style pathnames in unix-Python.
Jack Jansen <jack.jansen@cwi.nl>
parents:
19030
diff
changeset
|
1249 initmacfs(void) |
|
2180
9b451c84a7bf
Initial version of FSSpec and Alias code. Non-functional as of now.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
1250 { |
| 5071 | 1251 PyObject *m, *d; |
|
2180
9b451c84a7bf
Initial version of FSSpec and Alias code. Non-functional as of now.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
1252 |
|
19010
fe20d1cfec3d
Oops, arg type for the glue routine was wrong.
Jack Jansen <jack.jansen@cwi.nl>
parents:
18979
diff
changeset
|
1253 PyMac_INIT_TOOLBOX_OBJECT_CONVERT(FSSpec, PyMac_GetFSSpec); |
|
19645
d55b75ac2fb4
Added glue routine for PyMac_BuildFSSpec, PyMac_GetFSRef and PyMac_BuildFSRef.
Jack Jansen <jack.jansen@cwi.nl>
parents:
19066
diff
changeset
|
1254 PyMac_INIT_TOOLBOX_OBJECT_CONVERT(FSRef, PyMac_GetFSRef); |
|
d55b75ac2fb4
Added glue routine for PyMac_BuildFSSpec, PyMac_GetFSRef and PyMac_BuildFSRef.
Jack Jansen <jack.jansen@cwi.nl>
parents:
19066
diff
changeset
|
1255 PyMac_INIT_TOOLBOX_OBJECT_NEW(FSSpec *, PyMac_BuildFSSpec); |
|
d55b75ac2fb4
Added glue routine for PyMac_BuildFSSpec, PyMac_GetFSRef and PyMac_BuildFSRef.
Jack Jansen <jack.jansen@cwi.nl>
parents:
19066
diff
changeset
|
1256 PyMac_INIT_TOOLBOX_OBJECT_NEW(FSRef *, PyMac_BuildFSRef); |
|
18979
3dd8e64f512e
PyMac_GetFSSpec must be called via the dylib glue code on OSX.
Jack Jansen <jack.jansen@cwi.nl>
parents:
18962
diff
changeset
|
1257 |
|
2180
9b451c84a7bf
Initial version of FSSpec and Alias code. Non-functional as of now.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
1258 /* Create the module and add the functions */ |
| 5071 | 1259 m = Py_InitModule("macfs", mfs_methods); |
|
2180
9b451c84a7bf
Initial version of FSSpec and Alias code. Non-functional as of now.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
1260 |
|
9b451c84a7bf
Initial version of FSSpec and Alias code. Non-functional as of now.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
1261 /* Add some symbolic constants to the module */ |
| 5071 | 1262 d = PyModule_GetDict(m); |
|
11679
216efdad9a4b
Big oops: macfs has always been using a private exception but calling it mac.error.
Jack Jansen <jack.jansen@cwi.nl>
parents:
6442
diff
changeset
|
1263 ErrorObject = PyMac_GetOSErrException(); |
| 5071 | 1264 PyDict_SetItemString(d, "error", ErrorObject); |
|
2180
9b451c84a7bf
Initial version of FSSpec and Alias code. Non-functional as of now.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
1265 |
|
6330
172c7febd755
Export type objects to Python
Jack Jansen <jack.jansen@cwi.nl>
parents:
5743
diff
changeset
|
1266 Mfsatype.ob_type = &PyType_Type; |
|
172c7febd755
Export type objects to Python
Jack Jansen <jack.jansen@cwi.nl>
parents:
5743
diff
changeset
|
1267 Py_INCREF(&Mfsatype); |
|
172c7febd755
Export type objects to Python
Jack Jansen <jack.jansen@cwi.nl>
parents:
5743
diff
changeset
|
1268 PyDict_SetItemString(d, "AliasType", (PyObject *)&Mfsatype); |
|
172c7febd755
Export type objects to Python
Jack Jansen <jack.jansen@cwi.nl>
parents:
5743
diff
changeset
|
1269 Mfsstype.ob_type = &PyType_Type; |
|
172c7febd755
Export type objects to Python
Jack Jansen <jack.jansen@cwi.nl>
parents:
5743
diff
changeset
|
1270 Py_INCREF(&Mfsstype); |
|
172c7febd755
Export type objects to Python
Jack Jansen <jack.jansen@cwi.nl>
parents:
5743
diff
changeset
|
1271 PyDict_SetItemString(d, "FSSpecType", (PyObject *)&Mfsstype); |
|
172c7febd755
Export type objects to Python
Jack Jansen <jack.jansen@cwi.nl>
parents:
5743
diff
changeset
|
1272 Mfsitype.ob_type = &PyType_Type; |
|
172c7febd755
Export type objects to Python
Jack Jansen <jack.jansen@cwi.nl>
parents:
5743
diff
changeset
|
1273 Py_INCREF(&Mfsitype); |
|
172c7febd755
Export type objects to Python
Jack Jansen <jack.jansen@cwi.nl>
parents:
5743
diff
changeset
|
1274 PyDict_SetItemString(d, "FInfoType", (PyObject *)&Mfsitype); |
|
20794
83a3e21a7cc3
Moved macfsn hackery from macmain.c to macfsmodule.c so it loads
Just van Rossum <just@letterror.com>
parents:
19841
diff
changeset
|
1275 |
|
83a3e21a7cc3
Moved macfsn hackery from macmain.c to macfsmodule.c so it loads
Just van Rossum <just@letterror.com>
parents:
19841
diff
changeset
|
1276 PyMac_InstallNavServicesForSF(); |
|
2180
9b451c84a7bf
Initial version of FSSpec and Alias code. Non-functional as of now.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
1277 } |
