Mercurial > cpython-lru_cache-weakref
annotate Mac/Modules/macfsmodule.c @ 25838:8540887bcec6 2.2
Backport of 2.183:
Fix memory leak in add_subclass() found by NealN with valgrind.
| author | Guido van Rossum <guido@python.org> |
|---|---|
| date | Fri, 18 Oct 2002 13:42:21 +0000 |
| parents | a3ee7132036a |
| children |
| 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*/ |
|
21313
91dd223829c6
Patch supplied by Burton Radons for his own SF bug #487390: Modifying
Guido van Rossum <guido@python.org>
parents:
21245
diff
changeset
|
236 "macfs.Alias", /*tp_name*/ |
| 2249 | 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); |
|
21343
7a58cd337cf4
Added __members__ to FInfo object.
Just van Rossum <just@letterror.com>
parents:
21313
diff
changeset
|
295 else if ( strcmp(name, "__members__") == 0 ) |
|
7a58cd337cf4
Added __members__ to FInfo object.
Just van Rossum <just@letterror.com>
parents:
21313
diff
changeset
|
296 return Py_BuildValue("[sssss]", "Type", "Creator", "Flags", "Location", "Fldr"); |
|
2909
f9b1069a3e26
Added interfaces to {Get,Set}FInfo and accompanying objects
Jack Jansen <jack.jansen@cwi.nl>
parents:
2748
diff
changeset
|
297 else |
| 5071 | 298 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
|
299 } |
|
f9b1069a3e26
Added interfaces to {Get,Set}FInfo and accompanying objects
Jack Jansen <jack.jansen@cwi.nl>
parents:
2748
diff
changeset
|
300 |
|
f9b1069a3e26
Added interfaces to {Get,Set}FInfo and accompanying objects
Jack Jansen <jack.jansen@cwi.nl>
parents:
2748
diff
changeset
|
301 |
|
f9b1069a3e26
Added interfaces to {Get,Set}FInfo and accompanying objects
Jack Jansen <jack.jansen@cwi.nl>
parents:
2748
diff
changeset
|
302 static int |
|
19066
a1b4f3a1ee07
- Don't return mac-style pathnames in unix-Python.
Jack Jansen <jack.jansen@cwi.nl>
parents:
19030
diff
changeset
|
303 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
|
304 { |
|
f9b1069a3e26
Added interfaces to {Get,Set}FInfo and accompanying objects
Jack Jansen <jack.jansen@cwi.nl>
parents:
2748
diff
changeset
|
305 int rv; |
|
f9b1069a3e26
Added interfaces to {Get,Set}FInfo and accompanying objects
Jack Jansen <jack.jansen@cwi.nl>
parents:
2748
diff
changeset
|
306 int i; |
|
f9b1069a3e26
Added interfaces to {Get,Set}FInfo and accompanying objects
Jack Jansen <jack.jansen@cwi.nl>
parents:
2748
diff
changeset
|
307 |
|
f9b1069a3e26
Added interfaces to {Get,Set}FInfo and accompanying objects
Jack Jansen <jack.jansen@cwi.nl>
parents:
2748
diff
changeset
|
308 if ( v == NULL ) { |
| 5071 | 309 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
|
310 return -1; |
|
f9b1069a3e26
Added interfaces to {Get,Set}FInfo and accompanying objects
Jack Jansen <jack.jansen@cwi.nl>
parents:
2748
diff
changeset
|
311 } |
|
f9b1069a3e26
Added interfaces to {Get,Set}FInfo and accompanying objects
Jack Jansen <jack.jansen@cwi.nl>
parents:
2748
diff
changeset
|
312 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
|
313 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
|
314 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
|
315 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
|
316 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
|
317 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
|
318 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
|
319 } 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
|
320 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
|
321 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
|
322 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
|
323 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
|
324 } else { |
| 5071 | 325 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
|
326 return -1; |
|
f9b1069a3e26
Added interfaces to {Get,Set}FInfo and accompanying objects
Jack Jansen <jack.jansen@cwi.nl>
parents:
2748
diff
changeset
|
327 } |
|
f9b1069a3e26
Added interfaces to {Get,Set}FInfo and accompanying objects
Jack Jansen <jack.jansen@cwi.nl>
parents:
2748
diff
changeset
|
328 if (rv) |
|
f9b1069a3e26
Added interfaces to {Get,Set}FInfo and accompanying objects
Jack Jansen <jack.jansen@cwi.nl>
parents:
2748
diff
changeset
|
329 return 0; |
|
f9b1069a3e26
Added interfaces to {Get,Set}FInfo and accompanying objects
Jack Jansen <jack.jansen@cwi.nl>
parents:
2748
diff
changeset
|
330 return -1; |
|
f9b1069a3e26
Added interfaces to {Get,Set}FInfo and accompanying objects
Jack Jansen <jack.jansen@cwi.nl>
parents:
2748
diff
changeset
|
331 } |
|
f9b1069a3e26
Added interfaces to {Get,Set}FInfo and accompanying objects
Jack Jansen <jack.jansen@cwi.nl>
parents:
2748
diff
changeset
|
332 |
|
f9b1069a3e26
Added interfaces to {Get,Set}FInfo and accompanying objects
Jack Jansen <jack.jansen@cwi.nl>
parents:
2748
diff
changeset
|
333 |
| 5071 | 334 static PyTypeObject Mfsitype = { |
| 335 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
|
336 0, /*ob_size*/ |
|
21313
91dd223829c6
Patch supplied by Burton Radons for his own SF bug #487390: Modifying
Guido van Rossum <guido@python.org>
parents:
21245
diff
changeset
|
337 "macfs.FInfo", /*tp_name*/ |
|
2909
f9b1069a3e26
Added interfaces to {Get,Set}FInfo and accompanying objects
Jack Jansen <jack.jansen@cwi.nl>
parents:
2748
diff
changeset
|
338 sizeof(mfsiobject), /*tp_basicsize*/ |
|
f9b1069a3e26
Added interfaces to {Get,Set}FInfo and accompanying objects
Jack Jansen <jack.jansen@cwi.nl>
parents:
2748
diff
changeset
|
339 0, /*tp_itemsize*/ |
|
f9b1069a3e26
Added interfaces to {Get,Set}FInfo and accompanying objects
Jack Jansen <jack.jansen@cwi.nl>
parents:
2748
diff
changeset
|
340 /* methods */ |
|
f9b1069a3e26
Added interfaces to {Get,Set}FInfo and accompanying objects
Jack Jansen <jack.jansen@cwi.nl>
parents:
2748
diff
changeset
|
341 (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
|
342 (printfunc)0, /*tp_print*/ |
|
f9b1069a3e26
Added interfaces to {Get,Set}FInfo and accompanying objects
Jack Jansen <jack.jansen@cwi.nl>
parents:
2748
diff
changeset
|
343 (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
|
344 (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
|
345 (cmpfunc)0, /*tp_compare*/ |
|
f9b1069a3e26
Added interfaces to {Get,Set}FInfo and accompanying objects
Jack Jansen <jack.jansen@cwi.nl>
parents:
2748
diff
changeset
|
346 (reprfunc)0, /*tp_repr*/ |
|
f9b1069a3e26
Added interfaces to {Get,Set}FInfo and accompanying objects
Jack Jansen <jack.jansen@cwi.nl>
parents:
2748
diff
changeset
|
347 0, /*tp_as_number*/ |
|
f9b1069a3e26
Added interfaces to {Get,Set}FInfo and accompanying objects
Jack Jansen <jack.jansen@cwi.nl>
parents:
2748
diff
changeset
|
348 0, /*tp_as_sequence*/ |
|
f9b1069a3e26
Added interfaces to {Get,Set}FInfo and accompanying objects
Jack Jansen <jack.jansen@cwi.nl>
parents:
2748
diff
changeset
|
349 0, /*tp_as_mapping*/ |
|
f9b1069a3e26
Added interfaces to {Get,Set}FInfo and accompanying objects
Jack Jansen <jack.jansen@cwi.nl>
parents:
2748
diff
changeset
|
350 (hashfunc)0, /*tp_hash*/ |
|
f9b1069a3e26
Added interfaces to {Get,Set}FInfo and accompanying objects
Jack Jansen <jack.jansen@cwi.nl>
parents:
2748
diff
changeset
|
351 }; |
|
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 /* 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
|
354 /* -------------------------------------------------------- */ |
|
f9b1069a3e26
Added interfaces to {Get,Set}FInfo and accompanying objects
Jack Jansen <jack.jansen@cwi.nl>
parents:
2748
diff
changeset
|
355 |
|
f9b1069a3e26
Added interfaces to {Get,Set}FInfo and accompanying objects
Jack Jansen <jack.jansen@cwi.nl>
parents:
2748
diff
changeset
|
356 |
| 2249 | 357 /* |
|
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
|
358 ** 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
|
359 ** 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
|
360 ** 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
|
361 ** 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
|
362 ** helper routines. |
| 2249 | 363 */ |
|
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
|
364 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
|
365 _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
|
366 { |
|
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 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
|
368 *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
|
369 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
|
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 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
|
372 } |
|
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 |
|
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 /* 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
|
375 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
|
376 _mfs_GetFSSpecFromFSRef(PyObject *self, FSSpec *fssp) |
| 2249 | 377 { |
|
18962
d7590122f9a2
Merging appropriate 2.1.1 fixes back into the main trunk.
Jack Jansen <jack.jansen@cwi.nl>
parents:
18434
diff
changeset
|
378 #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
|
379 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
|
380 |
|
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 ( 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
|
382 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
|
383 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
|
384 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
|
385 } |
|
18962
d7590122f9a2
Merging appropriate 2.1.1 fixes back into the main trunk.
Jack Jansen <jack.jansen@cwi.nl>
parents:
18434
diff
changeset
|
386 #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
|
387 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
|
388 } |
|
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 |
|
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 /* 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
|
391 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
|
392 _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
|
393 { |
|
18962
d7590122f9a2
Merging appropriate 2.1.1 fixes back into the main trunk.
Jack Jansen <jack.jansen@cwi.nl>
parents:
18434
diff
changeset
|
394 #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
|
395 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
|
396 *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
|
397 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
|
398 } |
|
18962
d7590122f9a2
Merging appropriate 2.1.1 fixes back into the main trunk.
Jack Jansen <jack.jansen@cwi.nl>
parents:
18434
diff
changeset
|
399 #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
|
400 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
|
401 } |
|
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 |
|
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 /* 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
|
404 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
|
405 _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
|
406 { |
|
18962
d7590122f9a2
Merging appropriate 2.1.1 fixes back into the main trunk.
Jack Jansen <jack.jansen@cwi.nl>
parents:
18434
diff
changeset
|
407 #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
|
408 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
|
409 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
|
410 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
|
411 } |
|
18962
d7590122f9a2
Merging appropriate 2.1.1 fixes back into the main trunk.
Jack Jansen <jack.jansen@cwi.nl>
parents:
18434
diff
changeset
|
412 #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
|
413 return 0; |
| 2249 | 414 } |
| 415 | |
|
4308
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 ** 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
|
418 */ |
|
1a0f34c18163
Added [GS]etDates methods to get and set creation, modification and
Jack Jansen <jack.jansen@cwi.nl>
parents:
3787
diff
changeset
|
419 static OSErr |
|
19066
a1b4f3a1ee07
- Don't return mac-style pathnames in unix-Python.
Jack Jansen <jack.jansen@cwi.nl>
parents:
19030
diff
changeset
|
420 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
|
421 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
|
422 { |
|
1a0f34c18163
Added [GS]etDates methods to get and set creation, modification and
Jack Jansen <jack.jansen@cwi.nl>
parents:
3787
diff
changeset
|
423 CInfoPBRec pb; |
|
1a0f34c18163
Added [GS]etDates methods to get and set creation, modification and
Jack Jansen <jack.jansen@cwi.nl>
parents:
3787
diff
changeset
|
424 OSErr error; |
|
1a0f34c18163
Added [GS]etDates methods to get and set creation, modification and
Jack Jansen <jack.jansen@cwi.nl>
parents:
3787
diff
changeset
|
425 |
|
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.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
|
427 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
|
428 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
|
429 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
|
430 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
|
431 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
|
432 *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
|
433 *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
|
434 *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
|
435 return 0; |
|
1a0f34c18163
Added [GS]etDates methods to get and set creation, modification and
Jack Jansen <jack.jansen@cwi.nl>
parents:
3787
diff
changeset
|
436 } |
|
1a0f34c18163
Added [GS]etDates methods to get and set creation, modification and
Jack Jansen <jack.jansen@cwi.nl>
parents:
3787
diff
changeset
|
437 |
|
1a0f34c18163
Added [GS]etDates methods to get and set creation, modification and
Jack Jansen <jack.jansen@cwi.nl>
parents:
3787
diff
changeset
|
438 static OSErr |
|
19066
a1b4f3a1ee07
- Don't return mac-style pathnames in unix-Python.
Jack Jansen <jack.jansen@cwi.nl>
parents:
19030
diff
changeset
|
439 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
|
440 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
|
441 { |
|
1a0f34c18163
Added [GS]etDates methods to get and set creation, modification and
Jack Jansen <jack.jansen@cwi.nl>
parents:
3787
diff
changeset
|
442 CInfoPBRec pb; |
|
1a0f34c18163
Added [GS]etDates methods to get and set creation, modification and
Jack Jansen <jack.jansen@cwi.nl>
parents:
3787
diff
changeset
|
443 OSErr error; |
|
1a0f34c18163
Added [GS]etDates methods to get and set creation, modification and
Jack Jansen <jack.jansen@cwi.nl>
parents:
3787
diff
changeset
|
444 |
|
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.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
|
446 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
|
447 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
|
448 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
|
449 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
|
450 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
|
451 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
|
452 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
|
453 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
|
454 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
|
455 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
|
456 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
|
457 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
|
458 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
|
459 return error; |
|
1a0f34c18163
Added [GS]etDates methods to get and set creation, modification and
Jack Jansen <jack.jansen@cwi.nl>
parents:
3787
diff
changeset
|
460 } |
|
1a0f34c18163
Added [GS]etDates methods to get and set creation, modification and
Jack Jansen <jack.jansen@cwi.nl>
parents:
3787
diff
changeset
|
461 |
| 5071 | 462 static PyObject * |
|
19066
a1b4f3a1ee07
- Don't return mac-style pathnames in unix-Python.
Jack Jansen <jack.jansen@cwi.nl>
parents:
19030
diff
changeset
|
463 mfss_as_pathname(mfssobject *self, PyObject *args) |
| 2249 | 464 { |
|
19841
d8dd75e3b304
Replaced PyMac_FullPath by PyMac_FullPathname, which has an extra 'length'
Jack Jansen <jack.jansen@cwi.nl>
parents:
19649
diff
changeset
|
465 char strbuf[PATHNAMELEN]; |
| 2249 | 466 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
|
467 |
| 5071 | 468 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
|
469 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
|
470 err = PyMac_GetFullPathname(&self->fsspec, strbuf, PATHNAMELEN); |
| 2249 | 471 if ( err ) { |
| 472 PyErr_Mac(ErrorObject, err); | |
| 473 return NULL; | |
| 474 } | |
| 5071 | 475 return PyString_FromString(strbuf); |
| 2249 | 476 } |
| 477 | |
| 5071 | 478 static PyObject * |
|
19066
a1b4f3a1ee07
- Don't return mac-style pathnames in unix-Python.
Jack Jansen <jack.jansen@cwi.nl>
parents:
19030
diff
changeset
|
479 mfss_as_tuple(mfssobject *self, PyObject *args) |
| 2249 | 480 { |
| 5071 | 481 if (!PyArg_ParseTuple(args, "")) |
| 2249 | 482 return NULL; |
| 483 return Py_BuildValue("(iis#)", self->fsspec.vRefNum, self->fsspec.parID, | |
| 484 &self->fsspec.name[1], self->fsspec.name[0]); | |
| 485 } | |
| 486 | |
| 5071 | 487 static PyObject * |
|
19066
a1b4f3a1ee07
- Don't return mac-style pathnames in unix-Python.
Jack Jansen <jack.jansen@cwi.nl>
parents:
19030
diff
changeset
|
488 mfss_NewAlias(mfssobject *self, PyObject *args) |
| 2249 | 489 { |
| 490 FSSpec src, *srcp; | |
| 491 OSErr err; | |
| 492 AliasHandle alias; | |
| 493 | |
| 494 src.name[0] = 0; | |
| 5071 | 495 if (!PyArg_ParseTuple(args, "|O&", PyMac_GetFSSpec, &src)) |
| 2249 | 496 return NULL; |
| 497 if ( src.name[0] ) | |
| 498 srcp = &src; | |
| 499 else | |
| 500 srcp = NULL; | |
| 501 err = NewAlias(srcp, &self->fsspec, &alias); | |
| 502 if ( err ) { | |
| 503 PyErr_Mac(ErrorObject, err); | |
| 504 return NULL; | |
| 505 } | |
| 506 | |
| 5071 | 507 return (PyObject *)newmfsaobject(alias); |
| 2249 | 508 } |
| 509 | |
| 5071 | 510 static PyObject * |
|
19066
a1b4f3a1ee07
- Don't return mac-style pathnames in unix-Python.
Jack Jansen <jack.jansen@cwi.nl>
parents:
19030
diff
changeset
|
511 mfss_NewAliasMinimal(mfssobject *self, PyObject *args) |
| 2249 | 512 { |
| 513 OSErr err; | |
| 514 AliasHandle alias; | |
| 515 | |
| 5071 | 516 if (!PyArg_ParseTuple(args, "")) |
| 2249 | 517 return NULL; |
| 518 err = NewAliasMinimal(&self->fsspec, &alias); | |
| 519 if ( err ) { | |
| 520 PyErr_Mac(ErrorObject, err); | |
| 521 return NULL; | |
| 522 } | |
| 5071 | 523 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
|
524 } |
|
9b451c84a7bf
Initial version of FSSpec and Alias code. Non-functional as of now.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
525 |
|
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 static PyObject * |
|
19066
a1b4f3a1ee07
- Don't return mac-style pathnames in unix-Python.
Jack Jansen <jack.jansen@cwi.nl>
parents:
19030
diff
changeset
|
527 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
|
528 { |
|
18962
d7590122f9a2
Merging appropriate 2.1.1 fixes back into the main trunk.
Jack Jansen <jack.jansen@cwi.nl>
parents:
18434
diff
changeset
|
529 #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
|
530 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
|
531 return 0; |
|
d7590122f9a2
Merging appropriate 2.1.1 fixes back into the main trunk.
Jack Jansen <jack.jansen@cwi.nl>
parents:
18434
diff
changeset
|
532 #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
|
533 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
|
534 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
|
535 |
|
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 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
|
537 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
|
538 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
|
539 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
|
540 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
|
541 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
|
542 } |
|
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 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
|
544 #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
|
545 } |
|
f7f076bfcae9
Implemented minimal FSRef support, plus conversion between FSRefs, FSSpecs and pathnames where applicable.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17864
diff
changeset
|
546 |
|
2909
f9b1069a3e26
Added interfaces to {Get,Set}FInfo and accompanying objects
Jack Jansen <jack.jansen@cwi.nl>
parents:
2748
diff
changeset
|
547 /* XXXX These routines should be replaced by a wrapper to the *FInfo routines */ |
| 5071 | 548 static PyObject * |
|
19066
a1b4f3a1ee07
- Don't return mac-style pathnames in unix-Python.
Jack Jansen <jack.jansen@cwi.nl>
parents:
19030
diff
changeset
|
549 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
|
550 { |
|
e5b9f644053e
Added [GS]etCreatorType methods to FSSpec objects
Jack Jansen <jack.jansen@cwi.nl>
parents:
2264
diff
changeset
|
551 OSErr err; |
|
e5b9f644053e
Added [GS]etCreatorType methods to FSSpec objects
Jack Jansen <jack.jansen@cwi.nl>
parents:
2264
diff
changeset
|
552 FInfo info; |
|
e5b9f644053e
Added [GS]etCreatorType methods to FSSpec objects
Jack Jansen <jack.jansen@cwi.nl>
parents:
2264
diff
changeset
|
553 |
| 5071 | 554 if (!PyArg_ParseTuple(args, "")) |
|
2275
e5b9f644053e
Added [GS]etCreatorType methods to FSSpec objects
Jack Jansen <jack.jansen@cwi.nl>
parents:
2264
diff
changeset
|
555 return NULL; |
|
e5b9f644053e
Added [GS]etCreatorType methods to FSSpec objects
Jack Jansen <jack.jansen@cwi.nl>
parents:
2264
diff
changeset
|
556 err = FSpGetFInfo(&self->fsspec, &info); |
|
e5b9f644053e
Added [GS]etCreatorType methods to FSSpec objects
Jack Jansen <jack.jansen@cwi.nl>
parents:
2264
diff
changeset
|
557 if ( err ) { |
|
e5b9f644053e
Added [GS]etCreatorType methods to FSSpec objects
Jack Jansen <jack.jansen@cwi.nl>
parents:
2264
diff
changeset
|
558 PyErr_Mac(ErrorObject, err); |
|
e5b9f644053e
Added [GS]etCreatorType methods to FSSpec objects
Jack Jansen <jack.jansen@cwi.nl>
parents:
2264
diff
changeset
|
559 return NULL; |
|
e5b9f644053e
Added [GS]etCreatorType methods to FSSpec objects
Jack Jansen <jack.jansen@cwi.nl>
parents:
2264
diff
changeset
|
560 } |
|
e5b9f644053e
Added [GS]etCreatorType methods to FSSpec objects
Jack Jansen <jack.jansen@cwi.nl>
parents:
2264
diff
changeset
|
561 return Py_BuildValue("(O&O&)", |
|
e5b9f644053e
Added [GS]etCreatorType methods to FSSpec objects
Jack Jansen <jack.jansen@cwi.nl>
parents:
2264
diff
changeset
|
562 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
|
563 } |
|
e5b9f644053e
Added [GS]etCreatorType methods to FSSpec objects
Jack Jansen <jack.jansen@cwi.nl>
parents:
2264
diff
changeset
|
564 |
| 5071 | 565 static PyObject * |
|
19066
a1b4f3a1ee07
- Don't return mac-style pathnames in unix-Python.
Jack Jansen <jack.jansen@cwi.nl>
parents:
19030
diff
changeset
|
566 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
|
567 { |
|
e5b9f644053e
Added [GS]etCreatorType methods to FSSpec objects
Jack Jansen <jack.jansen@cwi.nl>
parents:
2264
diff
changeset
|
568 OSErr err; |
|
e5b9f644053e
Added [GS]etCreatorType methods to FSSpec objects
Jack Jansen <jack.jansen@cwi.nl>
parents:
2264
diff
changeset
|
569 OSType creator, type; |
|
e5b9f644053e
Added [GS]etCreatorType methods to FSSpec objects
Jack Jansen <jack.jansen@cwi.nl>
parents:
2264
diff
changeset
|
570 FInfo info; |
|
e5b9f644053e
Added [GS]etCreatorType methods to FSSpec objects
Jack Jansen <jack.jansen@cwi.nl>
parents:
2264
diff
changeset
|
571 |
| 5071 | 572 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
|
573 return NULL; |
|
e5b9f644053e
Added [GS]etCreatorType methods to FSSpec objects
Jack Jansen <jack.jansen@cwi.nl>
parents:
2264
diff
changeset
|
574 err = FSpGetFInfo(&self->fsspec, &info); |
|
e5b9f644053e
Added [GS]etCreatorType methods to FSSpec objects
Jack Jansen <jack.jansen@cwi.nl>
parents:
2264
diff
changeset
|
575 if ( err ) { |
|
e5b9f644053e
Added [GS]etCreatorType methods to FSSpec objects
Jack Jansen <jack.jansen@cwi.nl>
parents:
2264
diff
changeset
|
576 PyErr_Mac(ErrorObject, err); |
|
e5b9f644053e
Added [GS]etCreatorType methods to FSSpec objects
Jack Jansen <jack.jansen@cwi.nl>
parents:
2264
diff
changeset
|
577 return NULL; |
|
e5b9f644053e
Added [GS]etCreatorType methods to FSSpec objects
Jack Jansen <jack.jansen@cwi.nl>
parents:
2264
diff
changeset
|
578 } |
|
e5b9f644053e
Added [GS]etCreatorType methods to FSSpec objects
Jack Jansen <jack.jansen@cwi.nl>
parents:
2264
diff
changeset
|
579 info.fdType = type; |
|
e5b9f644053e
Added [GS]etCreatorType methods to FSSpec objects
Jack Jansen <jack.jansen@cwi.nl>
parents:
2264
diff
changeset
|
580 info.fdCreator = creator; |
|
e5b9f644053e
Added [GS]etCreatorType methods to FSSpec objects
Jack Jansen <jack.jansen@cwi.nl>
parents:
2264
diff
changeset
|
581 err = FSpSetFInfo(&self->fsspec, &info); |
|
e5b9f644053e
Added [GS]etCreatorType methods to FSSpec objects
Jack Jansen <jack.jansen@cwi.nl>
parents:
2264
diff
changeset
|
582 if ( err ) { |
|
e5b9f644053e
Added [GS]etCreatorType methods to FSSpec objects
Jack Jansen <jack.jansen@cwi.nl>
parents:
2264
diff
changeset
|
583 PyErr_Mac(ErrorObject, err); |
|
e5b9f644053e
Added [GS]etCreatorType methods to FSSpec objects
Jack Jansen <jack.jansen@cwi.nl>
parents:
2264
diff
changeset
|
584 return NULL; |
|
e5b9f644053e
Added [GS]etCreatorType methods to FSSpec objects
Jack Jansen <jack.jansen@cwi.nl>
parents:
2264
diff
changeset
|
585 } |
| 5071 | 586 Py_INCREF(Py_None); |
| 587 return Py_None; | |
|
2275
e5b9f644053e
Added [GS]etCreatorType methods to FSSpec objects
Jack Jansen <jack.jansen@cwi.nl>
parents:
2264
diff
changeset
|
588 } |
|
e5b9f644053e
Added [GS]etCreatorType methods to FSSpec objects
Jack Jansen <jack.jansen@cwi.nl>
parents:
2264
diff
changeset
|
589 |
| 5071 | 590 static PyObject * |
|
19066
a1b4f3a1ee07
- Don't return mac-style pathnames in unix-Python.
Jack Jansen <jack.jansen@cwi.nl>
parents:
19030
diff
changeset
|
591 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
|
592 { |
|
f9b1069a3e26
Added interfaces to {Get,Set}FInfo and accompanying objects
Jack Jansen <jack.jansen@cwi.nl>
parents:
2748
diff
changeset
|
593 OSErr err; |
|
f9b1069a3e26
Added interfaces to {Get,Set}FInfo and accompanying objects
Jack Jansen <jack.jansen@cwi.nl>
parents:
2748
diff
changeset
|
594 mfsiobject *fip; |
|
f9b1069a3e26
Added interfaces to {Get,Set}FInfo and accompanying objects
Jack Jansen <jack.jansen@cwi.nl>
parents:
2748
diff
changeset
|
595 |
|
f9b1069a3e26
Added interfaces to {Get,Set}FInfo and accompanying objects
Jack Jansen <jack.jansen@cwi.nl>
parents:
2748
diff
changeset
|
596 |
| 5071 | 597 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
|
598 return NULL; |
|
f9b1069a3e26
Added interfaces to {Get,Set}FInfo and accompanying objects
Jack Jansen <jack.jansen@cwi.nl>
parents:
2748
diff
changeset
|
599 if ( (fip=newmfsiobject()) == NULL ) |
|
f9b1069a3e26
Added interfaces to {Get,Set}FInfo and accompanying objects
Jack Jansen <jack.jansen@cwi.nl>
parents:
2748
diff
changeset
|
600 return NULL; |
|
f9b1069a3e26
Added interfaces to {Get,Set}FInfo and accompanying objects
Jack Jansen <jack.jansen@cwi.nl>
parents:
2748
diff
changeset
|
601 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
|
602 if ( err ) { |
|
f9b1069a3e26
Added interfaces to {Get,Set}FInfo and accompanying objects
Jack Jansen <jack.jansen@cwi.nl>
parents:
2748
diff
changeset
|
603 PyErr_Mac(ErrorObject, err); |
| 5071 | 604 Py_DECREF(fip); |
|
2909
f9b1069a3e26
Added interfaces to {Get,Set}FInfo and accompanying objects
Jack Jansen <jack.jansen@cwi.nl>
parents:
2748
diff
changeset
|
605 return NULL; |
|
f9b1069a3e26
Added interfaces to {Get,Set}FInfo and accompanying objects
Jack Jansen <jack.jansen@cwi.nl>
parents:
2748
diff
changeset
|
606 } |
| 5071 | 607 return (PyObject *)fip; |
|
2909
f9b1069a3e26
Added interfaces to {Get,Set}FInfo and accompanying objects
Jack Jansen <jack.jansen@cwi.nl>
parents:
2748
diff
changeset
|
608 } |
|
f9b1069a3e26
Added interfaces to {Get,Set}FInfo and accompanying objects
Jack Jansen <jack.jansen@cwi.nl>
parents:
2748
diff
changeset
|
609 |
| 5071 | 610 static PyObject * |
|
19066
a1b4f3a1ee07
- Don't return mac-style pathnames in unix-Python.
Jack Jansen <jack.jansen@cwi.nl>
parents:
19030
diff
changeset
|
611 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
|
612 { |
|
f9b1069a3e26
Added interfaces to {Get,Set}FInfo and accompanying objects
Jack Jansen <jack.jansen@cwi.nl>
parents:
2748
diff
changeset
|
613 OSErr err; |
|
f9b1069a3e26
Added interfaces to {Get,Set}FInfo and accompanying objects
Jack Jansen <jack.jansen@cwi.nl>
parents:
2748
diff
changeset
|
614 mfsiobject *fip; |
|
f9b1069a3e26
Added interfaces to {Get,Set}FInfo and accompanying objects
Jack Jansen <jack.jansen@cwi.nl>
parents:
2748
diff
changeset
|
615 |
| 5071 | 616 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
|
617 return NULL; |
|
f9b1069a3e26
Added interfaces to {Get,Set}FInfo and accompanying objects
Jack Jansen <jack.jansen@cwi.nl>
parents:
2748
diff
changeset
|
618 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
|
619 if ( err ) { |
|
f9b1069a3e26
Added interfaces to {Get,Set}FInfo and accompanying objects
Jack Jansen <jack.jansen@cwi.nl>
parents:
2748
diff
changeset
|
620 PyErr_Mac(ErrorObject, err); |
|
f9b1069a3e26
Added interfaces to {Get,Set}FInfo and accompanying objects
Jack Jansen <jack.jansen@cwi.nl>
parents:
2748
diff
changeset
|
621 return NULL; |
|
f9b1069a3e26
Added interfaces to {Get,Set}FInfo and accompanying objects
Jack Jansen <jack.jansen@cwi.nl>
parents:
2748
diff
changeset
|
622 } |
| 5071 | 623 Py_INCREF(Py_None); |
| 624 return Py_None; | |
|
2909
f9b1069a3e26
Added interfaces to {Get,Set}FInfo and accompanying objects
Jack Jansen <jack.jansen@cwi.nl>
parents:
2748
diff
changeset
|
625 } |
|
f9b1069a3e26
Added interfaces to {Get,Set}FInfo and accompanying objects
Jack Jansen <jack.jansen@cwi.nl>
parents:
2748
diff
changeset
|
626 |
| 5071 | 627 static PyObject * |
|
19066
a1b4f3a1ee07
- Don't return mac-style pathnames in unix-Python.
Jack Jansen <jack.jansen@cwi.nl>
parents:
19030
diff
changeset
|
628 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
|
629 { |
|
1a0f34c18163
Added [GS]etDates methods to get and set creation, modification and
Jack Jansen <jack.jansen@cwi.nl>
parents:
3787
diff
changeset
|
630 OSErr err; |
|
1a0f34c18163
Added [GS]etDates methods to get and set creation, modification and
Jack Jansen <jack.jansen@cwi.nl>
parents:
3787
diff
changeset
|
631 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
|
632 |
| 5071 | 633 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
|
634 return NULL; |
|
1a0f34c18163
Added [GS]etDates methods to get and set creation, modification and
Jack Jansen <jack.jansen@cwi.nl>
parents:
3787
diff
changeset
|
635 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
|
636 if ( err ) { |
|
1a0f34c18163
Added [GS]etDates methods to get and set creation, modification and
Jack Jansen <jack.jansen@cwi.nl>
parents:
3787
diff
changeset
|
637 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
|
638 return NULL; |
|
1a0f34c18163
Added [GS]etDates methods to get and set creation, modification and
Jack Jansen <jack.jansen@cwi.nl>
parents:
3787
diff
changeset
|
639 } |
| 5071 | 640 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
|
641 } |
|
1a0f34c18163
Added [GS]etDates methods to get and set creation, modification and
Jack Jansen <jack.jansen@cwi.nl>
parents:
3787
diff
changeset
|
642 |
| 5071 | 643 static PyObject * |
|
19066
a1b4f3a1ee07
- Don't return mac-style pathnames in unix-Python.
Jack Jansen <jack.jansen@cwi.nl>
parents:
19030
diff
changeset
|
644 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
|
645 { |
|
1a0f34c18163
Added [GS]etDates methods to get and set creation, modification and
Jack Jansen <jack.jansen@cwi.nl>
parents:
3787
diff
changeset
|
646 OSErr err; |
|
1a0f34c18163
Added [GS]etDates methods to get and set creation, modification and
Jack Jansen <jack.jansen@cwi.nl>
parents:
3787
diff
changeset
|
647 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
|
648 |
| 5071 | 649 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
|
650 return NULL; |
|
1a0f34c18163
Added [GS]etDates methods to get and set creation, modification and
Jack Jansen <jack.jansen@cwi.nl>
parents:
3787
diff
changeset
|
651 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
|
652 (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
|
653 if ( err ) { |
|
1a0f34c18163
Added [GS]etDates methods to get and set creation, modification and
Jack Jansen <jack.jansen@cwi.nl>
parents:
3787
diff
changeset
|
654 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
|
655 return NULL; |
|
1a0f34c18163
Added [GS]etDates methods to get and set creation, modification and
Jack Jansen <jack.jansen@cwi.nl>
parents:
3787
diff
changeset
|
656 } |
| 5071 | 657 Py_INCREF(Py_None); |
| 658 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
|
659 } |
|
1a0f34c18163
Added [GS]etDates methods to get and set creation, modification and
Jack Jansen <jack.jansen@cwi.nl>
parents:
3787
diff
changeset
|
660 |
| 5071 | 661 static struct PyMethodDef mfss_methods[] = { |
| 662 {"as_pathname", (PyCFunction)mfss_as_pathname, 1}, | |
| 663 {"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
|
664 {"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
|
665 {"FSpMakeFSRef", (PyCFunction)mfss_FSpMakeFSRef, 1}, |
| 5071 | 666 {"NewAlias", (PyCFunction)mfss_NewAlias, 1}, |
| 667 {"NewAliasMinimal", (PyCFunction)mfss_NewAliasMinimal, 1}, | |
| 668 {"GetCreatorType", (PyCFunction)mfss_GetCreatorType, 1}, | |
| 669 {"SetCreatorType", (PyCFunction)mfss_SetCreatorType, 1}, | |
| 670 {"GetFInfo", (PyCFunction)mfss_GetFInfo, 1}, | |
| 671 {"SetFInfo", (PyCFunction)mfss_SetFInfo, 1}, | |
| 672 {"GetDates", (PyCFunction)mfss_GetDates, 1}, | |
| 673 {"SetDates", (PyCFunction)mfss_SetDates, 1}, | |
| 2249 | 674 |
| 675 {NULL, NULL} /* sentinel */ | |
| 676 }; | |
| 677 | |
| 678 /* ---------- */ | |
| 679 | |
| 5071 | 680 static PyObject * |
|
19066
a1b4f3a1ee07
- Don't return mac-style pathnames in unix-Python.
Jack Jansen <jack.jansen@cwi.nl>
parents:
19030
diff
changeset
|
681 mfss_getattr(mfssobject *self, char *name) |
| 2249 | 682 { |
|
2319
1e7207128167
Added RawFSSpec and RawAlias methods which turn their string arguments
Jack Jansen <jack.jansen@cwi.nl>
parents:
2275
diff
changeset
|
683 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
|
684 return PyString_FromStringAndSize((char *)&self->fsspec, sizeof(FSSpec)); |
| 5071 | 685 return Py_FindMethod(mfss_methods, (PyObject *)self, name); |
| 2249 | 686 } |
| 687 | |
| 688 mfssobject * | |
|
19066
a1b4f3a1ee07
- Don't return mac-style pathnames in unix-Python.
Jack Jansen <jack.jansen@cwi.nl>
parents:
19030
diff
changeset
|
689 newmfssobject(FSSpec *fss) |
| 2249 | 690 { |
| 691 mfssobject *self; | |
| 692 | |
| 5071 | 693 self = PyObject_NEW(mfssobject, &Mfsstype); |
| 2249 | 694 if (self == NULL) |
| 695 return NULL; | |
| 696 self->fsspec = *fss; | |
| 697 return self; | |
| 698 } | |
| 699 | |
| 700 static void | |
|
19066
a1b4f3a1ee07
- Don't return mac-style pathnames in unix-Python.
Jack Jansen <jack.jansen@cwi.nl>
parents:
19030
diff
changeset
|
701 mfss_dealloc(mfssobject *self) |
| 2249 | 702 { |
| 5071 | 703 PyMem_DEL(self); |
| 2249 | 704 } |
| 705 | |
| 5071 | 706 static PyObject * |
|
19066
a1b4f3a1ee07
- Don't return mac-style pathnames in unix-Python.
Jack Jansen <jack.jansen@cwi.nl>
parents:
19030
diff
changeset
|
707 mfss_repr(mfssobject *self) |
| 2249 | 708 { |
| 709 char buf[512]; | |
| 710 | |
|
21245
ba6a7a5c32e8
Replace sprintf() with PyOS_snprintf().
Jack Jansen <jack.jansen@cwi.nl>
parents:
20900
diff
changeset
|
711 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
|
712 self->fsspec.vRefNum, |
|
77eb63716b4f
replace %#s with portable solution
Guido van Rossum <guido@python.org>
parents:
2400
diff
changeset
|
713 self->fsspec.parID, |
|
77eb63716b4f
replace %#s with portable solution
Guido van Rossum <guido@python.org>
parents:
2400
diff
changeset
|
714 self->fsspec.name[0], self->fsspec.name+1); |
| 5071 | 715 return PyString_FromString(buf); |
| 2249 | 716 } |
| 717 | |
| 718 static int | |
|
19066
a1b4f3a1ee07
- Don't return mac-style pathnames in unix-Python.
Jack Jansen <jack.jansen@cwi.nl>
parents:
19030
diff
changeset
|
719 mfss_compare(mfssobject *v, mfssobject *w) |
| 2249 | 720 { |
| 721 int minlen; | |
| 722 int res; | |
| 723 | |
| 724 if ( v->fsspec.vRefNum < w->fsspec.vRefNum ) return -1; | |
| 725 if ( v->fsspec.vRefNum > w->fsspec.vRefNum ) return 1; | |
| 726 if ( v->fsspec.parID < w->fsspec.parID ) return -1; | |
| 727 if ( v->fsspec.parID > w->fsspec.parID ) return 1; | |
| 728 minlen = v->fsspec.name[0]; | |
| 729 if ( w->fsspec.name[0] < minlen ) minlen = w->fsspec.name[0]; | |
| 730 res = strncmp((char *)v->fsspec.name+1, (char *)w->fsspec.name+1, minlen); | |
| 731 if ( res ) return res; | |
| 732 if ( v->fsspec.name[0] < w->fsspec.name[0] ) return -1; | |
| 733 if ( v->fsspec.name[0] > w->fsspec.name[0] ) return 1; | |
| 734 return res; | |
| 735 } | |
| 736 | |
| 5071 | 737 statichere PyTypeObject Mfsstype = { |
| 738 PyObject_HEAD_INIT(&PyType_Type) | |
| 2249 | 739 0, /*ob_size*/ |
|
21313
91dd223829c6
Patch supplied by Burton Radons for his own SF bug #487390: Modifying
Guido van Rossum <guido@python.org>
parents:
21245
diff
changeset
|
740 "macfs.FSSpec", /*tp_name*/ |
| 2249 | 741 sizeof(mfssobject), /*tp_basicsize*/ |
| 742 0, /*tp_itemsize*/ | |
| 743 /* methods */ | |
| 744 (destructor)mfss_dealloc, /*tp_dealloc*/ | |
| 745 (printfunc)0, /*tp_print*/ | |
| 746 (getattrfunc)mfss_getattr, /*tp_getattr*/ | |
| 747 (setattrfunc)0, /*tp_setattr*/ | |
| 748 (cmpfunc)mfss_compare, /*tp_compare*/ | |
| 749 (reprfunc)mfss_repr, /*tp_repr*/ | |
| 750 0, /*tp_as_number*/ | |
| 751 0, /*tp_as_sequence*/ | |
| 752 0, /*tp_as_mapping*/ | |
| 753 (hashfunc)0, /*tp_hash*/ | |
| 754 }; | |
| 755 | |
| 756 /* End of code for FSSpec objects */ | |
| 757 /* -------------------------------------------------------- */ | |
|
18962
d7590122f9a2
Merging appropriate 2.1.1 fixes back into the main trunk.
Jack Jansen <jack.jansen@cwi.nl>
parents:
18434
diff
changeset
|
758 #if !TARGET_API_MAC_OS8 |
| 5071 | 759 static PyObject * |
|
19066
a1b4f3a1ee07
- Don't return mac-style pathnames in unix-Python.
Jack Jansen <jack.jansen@cwi.nl>
parents:
19030
diff
changeset
|
760 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
|
761 { |
|
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 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
|
763 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
|
764 |
|
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 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
|
766 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
|
767 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
|
768 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
|
769 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
|
770 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
|
771 } |
|
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 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
|
773 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
|
774 } |
|
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 |
|
22023
e068440e116f
backport of 1.52 and 1.53:
Jack Jansen <jack.jansen@cwi.nl>
parents:
21343
diff
changeset
|
776 static PyObject * |
|
e068440e116f
backport of 1.52 and 1.53:
Jack Jansen <jack.jansen@cwi.nl>
parents:
21343
diff
changeset
|
777 mfsr_as_pathname(mfsrobject *self, PyObject *args) |
|
e068440e116f
backport of 1.52 and 1.53:
Jack Jansen <jack.jansen@cwi.nl>
parents:
21343
diff
changeset
|
778 { |
|
22408
a3ee7132036a
char/unsigned char mixup.
Jack Jansen <jack.jansen@cwi.nl>
parents:
22023
diff
changeset
|
779 unsigned char strbuf[PATHNAMELEN]; |
|
22023
e068440e116f
backport of 1.52 and 1.53:
Jack Jansen <jack.jansen@cwi.nl>
parents:
21343
diff
changeset
|
780 OSStatus err; |
|
e068440e116f
backport of 1.52 and 1.53:
Jack Jansen <jack.jansen@cwi.nl>
parents:
21343
diff
changeset
|
781 |
|
e068440e116f
backport of 1.52 and 1.53:
Jack Jansen <jack.jansen@cwi.nl>
parents:
21343
diff
changeset
|
782 if (!PyArg_ParseTuple(args, "")) |
|
e068440e116f
backport of 1.52 and 1.53:
Jack Jansen <jack.jansen@cwi.nl>
parents:
21343
diff
changeset
|
783 return NULL; |
|
e068440e116f
backport of 1.52 and 1.53:
Jack Jansen <jack.jansen@cwi.nl>
parents:
21343
diff
changeset
|
784 err = FSRefMakePath(&self->fsref, strbuf, PATHNAMELEN); |
|
e068440e116f
backport of 1.52 and 1.53:
Jack Jansen <jack.jansen@cwi.nl>
parents:
21343
diff
changeset
|
785 if ( err ) { |
|
e068440e116f
backport of 1.52 and 1.53:
Jack Jansen <jack.jansen@cwi.nl>
parents:
21343
diff
changeset
|
786 PyErr_Mac(ErrorObject, err); |
|
e068440e116f
backport of 1.52 and 1.53:
Jack Jansen <jack.jansen@cwi.nl>
parents:
21343
diff
changeset
|
787 return NULL; |
|
e068440e116f
backport of 1.52 and 1.53:
Jack Jansen <jack.jansen@cwi.nl>
parents:
21343
diff
changeset
|
788 } |
|
22408
a3ee7132036a
char/unsigned char mixup.
Jack Jansen <jack.jansen@cwi.nl>
parents:
22023
diff
changeset
|
789 return PyString_FromString((char *)strbuf); |
|
22023
e068440e116f
backport of 1.52 and 1.53:
Jack Jansen <jack.jansen@cwi.nl>
parents:
21343
diff
changeset
|
790 } |
|
e068440e116f
backport of 1.52 and 1.53:
Jack Jansen <jack.jansen@cwi.nl>
parents:
21343
diff
changeset
|
791 |
|
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
|
792 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
|
793 {"as_fsspec", (PyCFunction)mfsr_as_fsspec, 1}, |
|
22023
e068440e116f
backport of 1.52 and 1.53:
Jack Jansen <jack.jansen@cwi.nl>
parents:
21343
diff
changeset
|
794 {"as_pathname", (PyCFunction)mfsr_as_pathname, 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
|
795 #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
|
796 {"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
|
797 {"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
|
798 {"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
|
799 {"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
|
800 {"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
|
801 {"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
|
802 {"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
|
803 {"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
|
804 {"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
|
805 #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
|
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 {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
|
808 }; |
|
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 |
|
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 /* ---------- */ |
|
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 |
|
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 static PyObject * |
|
19066
a1b4f3a1ee07
- Don't return mac-style pathnames in unix-Python.
Jack Jansen <jack.jansen@cwi.nl>
parents:
19030
diff
changeset
|
813 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
|
814 { |
|
f7f076bfcae9
Implemented minimal FSRef support, plus conversion between FSRefs, FSSpecs and pathnames where applicable.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17864
diff
changeset
|
815 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
|
816 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
|
817 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
|
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 |
|
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 mfsrobject * |
|
19066
a1b4f3a1ee07
- Don't return mac-style pathnames in unix-Python.
Jack Jansen <jack.jansen@cwi.nl>
parents:
19030
diff
changeset
|
821 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
|
822 { |
|
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 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
|
824 |
|
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 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
|
826 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
|
827 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
|
828 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
|
829 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
|
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 |
|
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 static int |
|
19066
a1b4f3a1ee07
- Don't return mac-style pathnames in unix-Python.
Jack Jansen <jack.jansen@cwi.nl>
parents:
19030
diff
changeset
|
833 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
|
834 { |
|
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 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
|
836 |
|
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 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
|
838 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
|
839 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
|
840 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
|
841 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
|
842 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
|
843 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
|
844 } |
|
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 |
|
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 static void |
|
19066
a1b4f3a1ee07
- Don't return mac-style pathnames in unix-Python.
Jack Jansen <jack.jansen@cwi.nl>
parents:
19030
diff
changeset
|
847 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
|
848 { |
|
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 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
|
850 } |
|
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 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
|
853 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
|
854 0, /*ob_size*/ |
|
21313
91dd223829c6
Patch supplied by Burton Radons for his own SF bug #487390: Modifying
Guido van Rossum <guido@python.org>
parents:
21245
diff
changeset
|
855 "macfs.FSRef", /*tp_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
|
856 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
|
857 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
|
858 /* 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
|
859 (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
|
860 (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
|
861 (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
|
862 (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
|
863 (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
|
864 (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
|
865 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
|
866 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
|
867 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
|
868 (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
|
869 }; |
|
f7f076bfcae9
Implemented minimal FSRef support, plus conversion between FSRefs, FSSpecs and pathnames where applicable.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17864
diff
changeset
|
870 |
|
f7f076bfcae9
Implemented minimal FSRef support, plus conversion between FSRefs, FSSpecs and pathnames where applicable.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17864
diff
changeset
|
871 /* 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
|
872 #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
|
873 /* -------------------------------------------------------- */ |
|
f7f076bfcae9
Implemented minimal FSRef support, plus conversion between FSRefs, FSSpecs and pathnames where applicable.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17864
diff
changeset
|
874 |
|
f7f076bfcae9
Implemented minimal FSRef support, plus conversion between FSRefs, FSSpecs and pathnames where applicable.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17864
diff
changeset
|
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_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
|
877 { |
| 2249 | 878 FSSpec fss; |
| 879 Boolean chain = 1, isfolder, wasaliased; | |
| 880 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
|
881 |
| 5071 | 882 if (!PyArg_ParseTuple(args, "O&|i", PyMac_GetFSSpec, &fss, &chain)) |
| 2249 | 883 return NULL; |
| 884 err = ResolveAliasFile(&fss, chain, &isfolder, &wasaliased); | |
| 885 if ( err ) { | |
| 886 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
|
887 return NULL; |
| 2249 | 888 } |
| 5071 | 889 return Py_BuildValue("Oii", newmfssobject(&fss), (int)isfolder, (int)wasaliased); |
| 2249 | 890 } |
| 891 | |
|
13608
a901c2c0166b
Test for TARGET_API_MAC_CARBON with #if in stead of #ifdef.
Jack Jansen <jack.jansen@cwi.nl>
parents:
13606
diff
changeset
|
892 #if !TARGET_API_MAC_CARBON |
| 5071 | 893 static PyObject * |
|
19066
a1b4f3a1ee07
- Don't return mac-style pathnames in unix-Python.
Jack Jansen <jack.jansen@cwi.nl>
parents:
19030
diff
changeset
|
894 mfs_StandardGetFile(PyObject *self, PyObject *args) |
| 2249 | 895 { |
|
2264
85aa2e4d0123
fixed StandardGetFile argument handling
Guido van Rossum <guido@python.org>
parents:
2254
diff
changeset
|
896 SFTypeList list; |
| 2249 | 897 short numtypes; |
| 898 StandardFileReply reply; | |
| 899 | |
| 900 list[0] = list[1] = list[2] = list[3] = 0; | |
| 901 numtypes = 0; | |
| 5071 | 902 if (!PyArg_ParseTuple(args, "|O&O&O&O&", PyMac_GetOSType, &list[0], |
| 2249 | 903 PyMac_GetOSType, &list[1], PyMac_GetOSType, &list[2], |
| 904 PyMac_GetOSType, &list[3]) ) | |
| 905 return NULL; | |
|
2264
85aa2e4d0123
fixed StandardGetFile argument handling
Guido van Rossum <guido@python.org>
parents:
2254
diff
changeset
|
906 while ( numtypes < 4 && list[numtypes] ) { |
| 2249 | 907 numtypes++; |
| 908 } | |
|
2717
6c864ad519a3
StandardGetFile without args now shows all files (in stead of none)
Jack Jansen <jack.jansen@cwi.nl>
parents:
2408
diff
changeset
|
909 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
|
910 numtypes = -1; |
|
2264
85aa2e4d0123
fixed StandardGetFile argument handling
Guido van Rossum <guido@python.org>
parents:
2254
diff
changeset
|
911 StandardGetFile((FileFilterUPP)0, numtypes, list, &reply); |
| 5071 | 912 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
|
913 } |
|
9b451c84a7bf
Initial version of FSSpec and Alias code. Non-functional as of now.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
914 |
| 5071 | 915 static PyObject * |
|
19066
a1b4f3a1ee07
- Don't return mac-style pathnames in unix-Python.
Jack Jansen <jack.jansen@cwi.nl>
parents:
19030
diff
changeset
|
916 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
|
917 { |
|
56ad247cbfcb
Added new call PromptGetFile (like StandardGetFile, but accepts a
Jack Jansen <jack.jansen@cwi.nl>
parents:
2909
diff
changeset
|
918 SFTypeList list; |
|
56ad247cbfcb
Added new call PromptGetFile (like StandardGetFile, but accepts a
Jack Jansen <jack.jansen@cwi.nl>
parents:
2909
diff
changeset
|
919 short numtypes; |
|
56ad247cbfcb
Added new call PromptGetFile (like StandardGetFile, but accepts a
Jack Jansen <jack.jansen@cwi.nl>
parents:
2909
diff
changeset
|
920 StandardFileReply reply; |
|
56ad247cbfcb
Added new call PromptGetFile (like StandardGetFile, but accepts a
Jack Jansen <jack.jansen@cwi.nl>
parents:
2909
diff
changeset
|
921 char *prompt = NULL; |
|
56ad247cbfcb
Added new call PromptGetFile (like StandardGetFile, but accepts a
Jack Jansen <jack.jansen@cwi.nl>
parents:
2909
diff
changeset
|
922 |
|
56ad247cbfcb
Added new call PromptGetFile (like StandardGetFile, but accepts a
Jack Jansen <jack.jansen@cwi.nl>
parents:
2909
diff
changeset
|
923 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
|
924 numtypes = 0; |
| 5071 | 925 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
|
926 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
|
927 PyMac_GetOSType, &list[3]) ) |
|
56ad247cbfcb
Added new call PromptGetFile (like StandardGetFile, but accepts a
Jack Jansen <jack.jansen@cwi.nl>
parents:
2909
diff
changeset
|
928 return NULL; |
|
56ad247cbfcb
Added new call PromptGetFile (like StandardGetFile, but accepts a
Jack Jansen <jack.jansen@cwi.nl>
parents:
2909
diff
changeset
|
929 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
|
930 numtypes++; |
|
56ad247cbfcb
Added new call PromptGetFile (like StandardGetFile, but accepts a
Jack Jansen <jack.jansen@cwi.nl>
parents:
2909
diff
changeset
|
931 } |
|
56ad247cbfcb
Added new call PromptGetFile (like StandardGetFile, but accepts a
Jack Jansen <jack.jansen@cwi.nl>
parents:
2909
diff
changeset
|
932 if ( numtypes == 0 ) |
|
56ad247cbfcb
Added new call PromptGetFile (like StandardGetFile, but accepts a
Jack Jansen <jack.jansen@cwi.nl>
parents:
2909
diff
changeset
|
933 numtypes = -1; |
|
56ad247cbfcb
Added new call PromptGetFile (like StandardGetFile, but accepts a
Jack Jansen <jack.jansen@cwi.nl>
parents:
2909
diff
changeset
|
934 PyMac_PromptGetFile(numtypes, list, &reply, prompt); |
| 5071 | 935 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
|
936 } |
|
56ad247cbfcb
Added new call PromptGetFile (like StandardGetFile, but accepts a
Jack Jansen <jack.jansen@cwi.nl>
parents:
2909
diff
changeset
|
937 |
| 5071 | 938 static PyObject * |
|
19066
a1b4f3a1ee07
- Don't return mac-style pathnames in unix-Python.
Jack Jansen <jack.jansen@cwi.nl>
parents:
19030
diff
changeset
|
939 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
|
940 { |
|
9b451c84a7bf
Initial version of FSSpec and Alias code. Non-functional as of now.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
941 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
|
942 StandardFileReply reply; |
|
9b451c84a7bf
Initial version of FSSpec and Alias code. Non-functional as of now.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
943 |
|
9b451c84a7bf
Initial version of FSSpec and Alias code. Non-functional as of now.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
944 dft[0] = 0; |
| 5071 | 945 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
|
946 return NULL; |
|
9b451c84a7bf
Initial version of FSSpec and Alias code. Non-functional as of now.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
947 StandardPutFile(prompt, dft, &reply); |
| 5071 | 948 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
|
949 } |
|
9b451c84a7bf
Initial version of FSSpec and Alias code. Non-functional as of now.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
950 |
|
3787
7766360b85b8
Added SetFolder method which sets Standard File initial folder
Jack Jansen <jack.jansen@cwi.nl>
parents:
3140
diff
changeset
|
951 /* |
|
7766360b85b8
Added SetFolder method which sets Standard File initial folder
Jack Jansen <jack.jansen@cwi.nl>
parents:
3140
diff
changeset
|
952 ** Set initial directory for file dialogs */ |
| 5071 | 953 static PyObject * |
|
19066
a1b4f3a1ee07
- Don't return mac-style pathnames in unix-Python.
Jack Jansen <jack.jansen@cwi.nl>
parents:
19030
diff
changeset
|
954 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
|
955 { |
|
7766360b85b8
Added SetFolder method which sets Standard File initial folder
Jack Jansen <jack.jansen@cwi.nl>
parents:
3140
diff
changeset
|
956 FSSpec spec; |
|
7766360b85b8
Added SetFolder method which sets Standard File initial folder
Jack Jansen <jack.jansen@cwi.nl>
parents:
3140
diff
changeset
|
957 FSSpec ospec; |
|
7766360b85b8
Added SetFolder method which sets Standard File initial folder
Jack Jansen <jack.jansen@cwi.nl>
parents:
3140
diff
changeset
|
958 short orefnum; |
|
7766360b85b8
Added SetFolder method which sets Standard File initial folder
Jack Jansen <jack.jansen@cwi.nl>
parents:
3140
diff
changeset
|
959 long oparid; |
|
7766360b85b8
Added SetFolder method which sets Standard File initial folder
Jack Jansen <jack.jansen@cwi.nl>
parents:
3140
diff
changeset
|
960 |
|
7766360b85b8
Added SetFolder method which sets Standard File initial folder
Jack Jansen <jack.jansen@cwi.nl>
parents:
3140
diff
changeset
|
961 /* Get old values */ |
|
7766360b85b8
Added SetFolder method which sets Standard File initial folder
Jack Jansen <jack.jansen@cwi.nl>
parents:
3140
diff
changeset
|
962 orefnum = -LMGetSFSaveDisk(); |
|
7766360b85b8
Added SetFolder method which sets Standard File initial folder
Jack Jansen <jack.jansen@cwi.nl>
parents:
3140
diff
changeset
|
963 oparid = LMGetCurDirStore(); |
|
7766360b85b8
Added SetFolder method which sets Standard File initial folder
Jack Jansen <jack.jansen@cwi.nl>
parents:
3140
diff
changeset
|
964 (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
|
965 |
|
7766360b85b8
Added SetFolder method which sets Standard File initial folder
Jack Jansen <jack.jansen@cwi.nl>
parents:
3140
diff
changeset
|
966 /* 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
|
967 (void)FSMakeFSSpec(0, 0, "\p:placeholder", &spec); |
| 5071 | 968 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
|
969 return NULL; |
|
7766360b85b8
Added SetFolder method which sets Standard File initial folder
Jack Jansen <jack.jansen@cwi.nl>
parents:
3140
diff
changeset
|
970 /* 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
|
971 LMSetSFSaveDisk(-spec.vRefNum); |
|
7766360b85b8
Added SetFolder method which sets Standard File initial folder
Jack Jansen <jack.jansen@cwi.nl>
parents:
3140
diff
changeset
|
972 LMSetCurDirStore(spec.parID); |
| 5071 | 973 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
|
974 } |
|
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
|
975 #endif |
|
3787
7766360b85b8
Added SetFolder method which sets Standard File initial folder
Jack Jansen <jack.jansen@cwi.nl>
parents:
3140
diff
changeset
|
976 |
| 5071 | 977 static PyObject * |
|
19066
a1b4f3a1ee07
- Don't return mac-style pathnames in unix-Python.
Jack Jansen <jack.jansen@cwi.nl>
parents:
19030
diff
changeset
|
978 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
|
979 { |
|
9b451c84a7bf
Initial version of FSSpec and Alias code. Non-functional as of now.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
980 FSSpec fss; |
|
9b451c84a7bf
Initial version of FSSpec and Alias code. Non-functional as of now.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
981 |
| 5071 | 982 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
|
983 return NULL; |
| 5071 | 984 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
|
985 } |
|
9b451c84a7bf
Initial version of FSSpec and Alias code. Non-functional as of now.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
986 |
| 5071 | 987 static PyObject * |
|
19066
a1b4f3a1ee07
- Don't return mac-style pathnames in unix-Python.
Jack Jansen <jack.jansen@cwi.nl>
parents:
19030
diff
changeset
|
988 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
|
989 { |
|
18962
d7590122f9a2
Merging appropriate 2.1.1 fixes back into the main trunk.
Jack Jansen <jack.jansen@cwi.nl>
parents:
18434
diff
changeset
|
990 #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
|
991 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
|
992 return 0; |
|
d7590122f9a2
Merging appropriate 2.1.1 fixes back into the main trunk.
Jack Jansen <jack.jansen@cwi.nl>
parents:
18434
diff
changeset
|
993 #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
|
994 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
|
995 |
|
f7f076bfcae9
Implemented minimal FSRef support, plus conversion between FSRefs, FSSpecs and pathnames where applicable.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17864
diff
changeset
|
996 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
|
997 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
|
998 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
|
999 #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
|
1000 } |
|
f7f076bfcae9
Implemented minimal FSRef support, plus conversion between FSRefs, FSSpecs and pathnames where applicable.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17864
diff
changeset
|
1001 |
|
f7f076bfcae9
Implemented minimal FSRef support, plus conversion between FSRefs, FSSpecs and pathnames where applicable.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17864
diff
changeset
|
1002 static PyObject * |
|
19066
a1b4f3a1ee07
- Don't return mac-style pathnames in unix-Python.
Jack Jansen <jack.jansen@cwi.nl>
parents:
19030
diff
changeset
|
1003 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
|
1004 { |
|
1e7207128167
Added RawFSSpec and RawAlias methods which turn their string arguments
Jack Jansen <jack.jansen@cwi.nl>
parents:
2275
diff
changeset
|
1005 FSSpec *fssp; |
|
1e7207128167
Added RawFSSpec and RawAlias methods which turn their string arguments
Jack Jansen <jack.jansen@cwi.nl>
parents:
2275
diff
changeset
|
1006 int size; |
|
1e7207128167
Added RawFSSpec and RawAlias methods which turn their string arguments
Jack Jansen <jack.jansen@cwi.nl>
parents:
2275
diff
changeset
|
1007 |
|
5429
ac235c9e6881
- Changed the m# format for PyArg_ParseTuple back to s#
Jack Jansen <jack.jansen@cwi.nl>
parents:
5152
diff
changeset
|
1008 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
|
1009 return NULL; |
|
1e7207128167
Added RawFSSpec and RawAlias methods which turn their string arguments
Jack Jansen <jack.jansen@cwi.nl>
parents:
2275
diff
changeset
|
1010 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
|
1011 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
|
1012 return NULL; |
|
1e7207128167
Added RawFSSpec and RawAlias methods which turn their string arguments
Jack Jansen <jack.jansen@cwi.nl>
parents:
2275
diff
changeset
|
1013 } |
| 5071 | 1014 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
|
1015 } |
|
1e7207128167
Added RawFSSpec and RawAlias methods which turn their string arguments
Jack Jansen <jack.jansen@cwi.nl>
parents:
2275
diff
changeset
|
1016 |
| 5071 | 1017 static PyObject * |
|
19066
a1b4f3a1ee07
- Don't return mac-style pathnames in unix-Python.
Jack Jansen <jack.jansen@cwi.nl>
parents:
19030
diff
changeset
|
1018 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
|
1019 { |
|
1e7207128167
Added RawFSSpec and RawAlias methods which turn their string arguments
Jack Jansen <jack.jansen@cwi.nl>
parents:
2275
diff
changeset
|
1020 char *dataptr; |
|
1e7207128167
Added RawFSSpec and RawAlias methods which turn their string arguments
Jack Jansen <jack.jansen@cwi.nl>
parents:
2275
diff
changeset
|
1021 Handle h; |
|
1e7207128167
Added RawFSSpec and RawAlias methods which turn their string arguments
Jack Jansen <jack.jansen@cwi.nl>
parents:
2275
diff
changeset
|
1022 int size; |
|
1e7207128167
Added RawFSSpec and RawAlias methods which turn their string arguments
Jack Jansen <jack.jansen@cwi.nl>
parents:
2275
diff
changeset
|
1023 |
|
5429
ac235c9e6881
- Changed the m# format for PyArg_ParseTuple back to s#
Jack Jansen <jack.jansen@cwi.nl>
parents:
5152
diff
changeset
|
1024 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
|
1025 return NULL; |
|
1e7207128167
Added RawFSSpec and RawAlias methods which turn their string arguments
Jack Jansen <jack.jansen@cwi.nl>
parents:
2275
diff
changeset
|
1026 h = NewHandle(size); |
|
1e7207128167
Added RawFSSpec and RawAlias methods which turn their string arguments
Jack Jansen <jack.jansen@cwi.nl>
parents:
2275
diff
changeset
|
1027 if ( h == NULL ) { |
|
1e7207128167
Added RawFSSpec and RawAlias methods which turn their string arguments
Jack Jansen <jack.jansen@cwi.nl>
parents:
2275
diff
changeset
|
1028 PyErr_NoMemory(); |
|
1e7207128167
Added RawFSSpec and RawAlias methods which turn their string arguments
Jack Jansen <jack.jansen@cwi.nl>
parents:
2275
diff
changeset
|
1029 return NULL; |
|
1e7207128167
Added RawFSSpec and RawAlias methods which turn their string arguments
Jack Jansen <jack.jansen@cwi.nl>
parents:
2275
diff
changeset
|
1030 } |
|
1e7207128167
Added RawFSSpec and RawAlias methods which turn their string arguments
Jack Jansen <jack.jansen@cwi.nl>
parents:
2275
diff
changeset
|
1031 HLock(h); |
|
1e7207128167
Added RawFSSpec and RawAlias methods which turn their string arguments
Jack Jansen <jack.jansen@cwi.nl>
parents:
2275
diff
changeset
|
1032 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
|
1033 HUnlock(h); |
| 5071 | 1034 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
|
1035 } |
|
1e7207128167
Added RawFSSpec and RawAlias methods which turn their string arguments
Jack Jansen <jack.jansen@cwi.nl>
parents:
2275
diff
changeset
|
1036 |
|
13608
a901c2c0166b
Test for TARGET_API_MAC_CARBON with #if in stead of #ifdef.
Jack Jansen <jack.jansen@cwi.nl>
parents:
13606
diff
changeset
|
1037 #if !TARGET_API_MAC_CARBON |
| 5071 | 1038 static PyObject * |
|
19066
a1b4f3a1ee07
- Don't return mac-style pathnames in unix-Python.
Jack Jansen <jack.jansen@cwi.nl>
parents:
19030
diff
changeset
|
1039 mfs_GetDirectory(PyObject *self, PyObject *args) |
|
2400
d31f694c11a8
Added GetDirectory() method
Jack Jansen <jack.jansen@cwi.nl>
parents:
2337
diff
changeset
|
1040 { |
|
d31f694c11a8
Added GetDirectory() method
Jack Jansen <jack.jansen@cwi.nl>
parents:
2337
diff
changeset
|
1041 FSSpec fsdir; |
|
d31f694c11a8
Added GetDirectory() method
Jack Jansen <jack.jansen@cwi.nl>
parents:
2337
diff
changeset
|
1042 int ok; |
|
2981
56ad247cbfcb
Added new call PromptGetFile (like StandardGetFile, but accepts a
Jack Jansen <jack.jansen@cwi.nl>
parents:
2909
diff
changeset
|
1043 char *prompt = NULL; |
|
2400
d31f694c11a8
Added GetDirectory() method
Jack Jansen <jack.jansen@cwi.nl>
parents:
2337
diff
changeset
|
1044 |
| 5071 | 1045 if (!PyArg_ParseTuple(args, "|s", &prompt) ) |
|
2400
d31f694c11a8
Added GetDirectory() method
Jack Jansen <jack.jansen@cwi.nl>
parents:
2337
diff
changeset
|
1046 return NULL; |
|
d31f694c11a8
Added GetDirectory() method
Jack Jansen <jack.jansen@cwi.nl>
parents:
2337
diff
changeset
|
1047 |
|
2981
56ad247cbfcb
Added new call PromptGetFile (like StandardGetFile, but accepts a
Jack Jansen <jack.jansen@cwi.nl>
parents:
2909
diff
changeset
|
1048 ok = PyMac_GetDirectory(&fsdir, prompt); |
| 5071 | 1049 return Py_BuildValue("(Oi)", newmfssobject(&fsdir), ok); |
|
2400
d31f694c11a8
Added GetDirectory() method
Jack Jansen <jack.jansen@cwi.nl>
parents:
2337
diff
changeset
|
1050 } |
|
13606
c9a4a1316170
pymactoolbox.h contains protoypes for all externally visible toolbox module
Jack Jansen <jack.jansen@cwi.nl>
parents:
13547
diff
changeset
|
1051 #endif |
|
2400
d31f694c11a8
Added GetDirectory() method
Jack Jansen <jack.jansen@cwi.nl>
parents:
2337
diff
changeset
|
1052 |
| 5071 | 1053 static PyObject * |
|
19066
a1b4f3a1ee07
- Don't return mac-style pathnames in unix-Python.
Jack Jansen <jack.jansen@cwi.nl>
parents:
19030
diff
changeset
|
1054 mfs_FindFolder(PyObject *self, PyObject *args) |
|
2748
39cd25678b41
Added FindFolder interface
Jack Jansen <jack.jansen@cwi.nl>
parents:
2717
diff
changeset
|
1055 { |
|
39cd25678b41
Added FindFolder interface
Jack Jansen <jack.jansen@cwi.nl>
parents:
2717
diff
changeset
|
1056 OSErr err; |
|
39cd25678b41
Added FindFolder interface
Jack Jansen <jack.jansen@cwi.nl>
parents:
2717
diff
changeset
|
1057 short where; |
|
39cd25678b41
Added FindFolder interface
Jack Jansen <jack.jansen@cwi.nl>
parents:
2717
diff
changeset
|
1058 OSType which; |
|
39cd25678b41
Added FindFolder interface
Jack Jansen <jack.jansen@cwi.nl>
parents:
2717
diff
changeset
|
1059 int create; |
|
39cd25678b41
Added FindFolder interface
Jack Jansen <jack.jansen@cwi.nl>
parents:
2717
diff
changeset
|
1060 short refnum; |
|
39cd25678b41
Added FindFolder interface
Jack Jansen <jack.jansen@cwi.nl>
parents:
2717
diff
changeset
|
1061 long dirid; |
|
39cd25678b41
Added FindFolder interface
Jack Jansen <jack.jansen@cwi.nl>
parents:
2717
diff
changeset
|
1062 |
|
17049
7eb5a6e8c98d
FindFolder argument is a short, not an unsigned short.
Jack Jansen <jack.jansen@cwi.nl>
parents:
13608
diff
changeset
|
1063 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
|
1064 return NULL; |
|
39cd25678b41
Added FindFolder interface
Jack Jansen <jack.jansen@cwi.nl>
parents:
2717
diff
changeset
|
1065 err = FindFolder(where, which, (Boolean)create, &refnum, &dirid); |
|
39cd25678b41
Added FindFolder interface
Jack Jansen <jack.jansen@cwi.nl>
parents:
2717
diff
changeset
|
1066 if ( err ) { |
|
39cd25678b41
Added FindFolder interface
Jack Jansen <jack.jansen@cwi.nl>
parents:
2717
diff
changeset
|
1067 PyErr_Mac(ErrorObject, err); |
|
39cd25678b41
Added FindFolder interface
Jack Jansen <jack.jansen@cwi.nl>
parents:
2717
diff
changeset
|
1068 return NULL; |
|
39cd25678b41
Added FindFolder interface
Jack Jansen <jack.jansen@cwi.nl>
parents:
2717
diff
changeset
|
1069 } |
| 5071 | 1070 return Py_BuildValue("(ii)", refnum, dirid); |
|
2748
39cd25678b41
Added FindFolder interface
Jack Jansen <jack.jansen@cwi.nl>
parents:
2717
diff
changeset
|
1071 } |
|
39cd25678b41
Added FindFolder interface
Jack Jansen <jack.jansen@cwi.nl>
parents:
2717
diff
changeset
|
1072 |
| 5071 | 1073 static PyObject * |
|
19066
a1b4f3a1ee07
- Don't return mac-style pathnames in unix-Python.
Jack Jansen <jack.jansen@cwi.nl>
parents:
19030
diff
changeset
|
1074 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
|
1075 { |
|
97133996e22f
Added macfs.FindApplication() to find application FSSpec given signature.
Jack Jansen <jack.jansen@cwi.nl>
parents:
4308
diff
changeset
|
1076 OSErr err; |
|
97133996e22f
Added macfs.FindApplication() to find application FSSpec given signature.
Jack Jansen <jack.jansen@cwi.nl>
parents:
4308
diff
changeset
|
1077 OSType which; |
|
97133996e22f
Added macfs.FindApplication() to find application FSSpec given signature.
Jack Jansen <jack.jansen@cwi.nl>
parents:
4308
diff
changeset
|
1078 FSSpec fss; |
|
97133996e22f
Added macfs.FindApplication() to find application FSSpec given signature.
Jack Jansen <jack.jansen@cwi.nl>
parents:
4308
diff
changeset
|
1079 |
| 5071 | 1080 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
|
1081 return NULL; |
|
97133996e22f
Added macfs.FindApplication() to find application FSSpec given signature.
Jack Jansen <jack.jansen@cwi.nl>
parents:
4308
diff
changeset
|
1082 err = FindApplicationFromCreator(which, &fss); |
|
97133996e22f
Added macfs.FindApplication() to find application FSSpec given signature.
Jack Jansen <jack.jansen@cwi.nl>
parents:
4308
diff
changeset
|
1083 if ( err ) { |
|
97133996e22f
Added macfs.FindApplication() to find application FSSpec given signature.
Jack Jansen <jack.jansen@cwi.nl>
parents:
4308
diff
changeset
|
1084 PyErr_Mac(ErrorObject, err); |
|
97133996e22f
Added macfs.FindApplication() to find application FSSpec given signature.
Jack Jansen <jack.jansen@cwi.nl>
parents:
4308
diff
changeset
|
1085 return NULL; |
|
97133996e22f
Added macfs.FindApplication() to find application FSSpec given signature.
Jack Jansen <jack.jansen@cwi.nl>
parents:
4308
diff
changeset
|
1086 } |
| 5071 | 1087 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
|
1088 } |
|
97133996e22f
Added macfs.FindApplication() to find application FSSpec given signature.
Jack Jansen <jack.jansen@cwi.nl>
parents:
4308
diff
changeset
|
1089 |
| 5071 | 1090 static PyObject * |
|
19066
a1b4f3a1ee07
- Don't return mac-style pathnames in unix-Python.
Jack Jansen <jack.jansen@cwi.nl>
parents:
19030
diff
changeset
|
1091 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
|
1092 { |
| 5071 | 1093 return (PyObject *)newmfsiobject(); |
|
2909
f9b1069a3e26
Added interfaces to {Get,Set}FInfo and accompanying objects
Jack Jansen <jack.jansen@cwi.nl>
parents:
2748
diff
changeset
|
1094 } |
|
f9b1069a3e26
Added interfaces to {Get,Set}FInfo and accompanying objects
Jack Jansen <jack.jansen@cwi.nl>
parents:
2748
diff
changeset
|
1095 |
|
5743
c606dd61544a
Added NewAliasMinimalFromFullPath(), and allow alias.Resolve() to return
Jack Jansen <jack.jansen@cwi.nl>
parents:
5429
diff
changeset
|
1096 static PyObject * |
|
19066
a1b4f3a1ee07
- Don't return mac-style pathnames in unix-Python.
Jack Jansen <jack.jansen@cwi.nl>
parents:
19030
diff
changeset
|
1097 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
|
1098 { |
|
c606dd61544a
Added NewAliasMinimalFromFullPath(), and allow alias.Resolve() to return
Jack Jansen <jack.jansen@cwi.nl>
parents:
5429
diff
changeset
|
1099 OSErr err; |
|
c606dd61544a
Added NewAliasMinimalFromFullPath(), and allow alias.Resolve() to return
Jack Jansen <jack.jansen@cwi.nl>
parents:
5429
diff
changeset
|
1100 char *fullpath; |
|
c606dd61544a
Added NewAliasMinimalFromFullPath(), and allow alias.Resolve() to return
Jack Jansen <jack.jansen@cwi.nl>
parents:
5429
diff
changeset
|
1101 int fullpathlen; |
|
c606dd61544a
Added NewAliasMinimalFromFullPath(), and allow alias.Resolve() to return
Jack Jansen <jack.jansen@cwi.nl>
parents:
5429
diff
changeset
|
1102 AliasHandle alias; |
|
c606dd61544a
Added NewAliasMinimalFromFullPath(), and allow alias.Resolve() to return
Jack Jansen <jack.jansen@cwi.nl>
parents:
5429
diff
changeset
|
1103 Str32 zonename; |
|
c606dd61544a
Added NewAliasMinimalFromFullPath(), and allow alias.Resolve() to return
Jack Jansen <jack.jansen@cwi.nl>
parents:
5429
diff
changeset
|
1104 Str31 servername; |
|
c606dd61544a
Added NewAliasMinimalFromFullPath(), and allow alias.Resolve() to return
Jack Jansen <jack.jansen@cwi.nl>
parents:
5429
diff
changeset
|
1105 |
|
c606dd61544a
Added NewAliasMinimalFromFullPath(), and allow alias.Resolve() to return
Jack Jansen <jack.jansen@cwi.nl>
parents:
5429
diff
changeset
|
1106 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
|
1107 return NULL; |
|
c606dd61544a
Added NewAliasMinimalFromFullPath(), and allow alias.Resolve() to return
Jack Jansen <jack.jansen@cwi.nl>
parents:
5429
diff
changeset
|
1108 zonename[0] = 0; |
|
c606dd61544a
Added NewAliasMinimalFromFullPath(), and allow alias.Resolve() to return
Jack Jansen <jack.jansen@cwi.nl>
parents:
5429
diff
changeset
|
1109 servername[0] = 0; |
|
c606dd61544a
Added NewAliasMinimalFromFullPath(), and allow alias.Resolve() to return
Jack Jansen <jack.jansen@cwi.nl>
parents:
5429
diff
changeset
|
1110 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
|
1111 servername, &alias); |
|
c606dd61544a
Added NewAliasMinimalFromFullPath(), and allow alias.Resolve() to return
Jack Jansen <jack.jansen@cwi.nl>
parents:
5429
diff
changeset
|
1112 if ( err ) { |
|
c606dd61544a
Added NewAliasMinimalFromFullPath(), and allow alias.Resolve() to return
Jack Jansen <jack.jansen@cwi.nl>
parents:
5429
diff
changeset
|
1113 PyErr_Mac(ErrorObject, err); |
|
c606dd61544a
Added NewAliasMinimalFromFullPath(), and allow alias.Resolve() to return
Jack Jansen <jack.jansen@cwi.nl>
parents:
5429
diff
changeset
|
1114 return NULL; |
|
c606dd61544a
Added NewAliasMinimalFromFullPath(), and allow alias.Resolve() to return
Jack Jansen <jack.jansen@cwi.nl>
parents:
5429
diff
changeset
|
1115 } |
|
c606dd61544a
Added NewAliasMinimalFromFullPath(), and allow alias.Resolve() to return
Jack Jansen <jack.jansen@cwi.nl>
parents:
5429
diff
changeset
|
1116 return (PyObject *)newmfsaobject(alias); |
|
c606dd61544a
Added NewAliasMinimalFromFullPath(), and allow alias.Resolve() to return
Jack Jansen <jack.jansen@cwi.nl>
parents:
5429
diff
changeset
|
1117 } |
|
c606dd61544a
Added NewAliasMinimalFromFullPath(), and allow alias.Resolve() to return
Jack Jansen <jack.jansen@cwi.nl>
parents:
5429
diff
changeset
|
1118 |
|
c606dd61544a
Added NewAliasMinimalFromFullPath(), and allow alias.Resolve() to return
Jack Jansen <jack.jansen@cwi.nl>
parents:
5429
diff
changeset
|
1119 |
|
2180
9b451c84a7bf
Initial version of FSSpec and Alias code. Non-functional as of now.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
1120 /* 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
|
1121 |
| 5071 | 1122 static struct PyMethodDef mfs_methods[] = { |
| 2249 | 1123 {"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
|
1124 #if !TARGET_API_MAC_CARBON |
| 2249 | 1125 {"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
|
1126 {"PromptGetFile", mfs_PromptGetFile, 1}, |
| 2249 | 1127 {"StandardPutFile", mfs_StandardPutFile, 1}, |
|
2400
d31f694c11a8
Added GetDirectory() method
Jack Jansen <jack.jansen@cwi.nl>
parents:
2337
diff
changeset
|
1128 {"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
|
1129 {"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
|
1130 #endif |
| 2249 | 1131 {"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
|
1132 {"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
|
1133 {"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
|
1134 {"RawAlias", mfs_RawAlias, 1}, |
|
2748
39cd25678b41
Added FindFolder interface
Jack Jansen <jack.jansen@cwi.nl>
parents:
2717
diff
changeset
|
1135 {"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
|
1136 {"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
|
1137 {"FInfo", mfs_FInfo, 1}, |
|
5743
c606dd61544a
Added NewAliasMinimalFromFullPath(), and allow alias.Resolve() to return
Jack Jansen <jack.jansen@cwi.nl>
parents:
5429
diff
changeset
|
1138 {"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
|
1139 |
|
9b451c84a7bf
Initial version of FSSpec and Alias code. Non-functional as of now.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
1140 {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
|
1141 }; |
|
9b451c84a7bf
Initial version of FSSpec and Alias code. Non-functional as of now.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
1142 |
|
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
|
1143 /* |
|
f7f076bfcae9
Implemented minimal FSRef support, plus conversion between FSRefs, FSSpecs and pathnames where applicable.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17864
diff
changeset
|
1144 ** 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
|
1145 ** 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
|
1146 ** (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
|
1147 */ |
|
f7f076bfcae9
Implemented minimal FSRef support, plus conversion between FSRefs, FSSpecs and pathnames where applicable.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17864
diff
changeset
|
1148 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
|
1149 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
|
1150 { |
|
18962
d7590122f9a2
Merging appropriate 2.1.1 fixes back into the main trunk.
Jack Jansen <jack.jansen@cwi.nl>
parents:
18434
diff
changeset
|
1151 #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
|
1152 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
|
1153 return 0; |
|
d7590122f9a2
Merging appropriate 2.1.1 fixes back into the main trunk.
Jack Jansen <jack.jansen@cwi.nl>
parents:
18434
diff
changeset
|
1154 #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
|
1155 /* 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
|
1156 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
|
1157 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
|
1158 /* 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
|
1159 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
|
1160 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
|
1161 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
|
1162 #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
|
1163 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
|
1164 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
|
1165 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
|
1166 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
|
1167 } |
|
3dd8e64f512e
PyMac_GetFSSpec must be called via the dylib glue code on OSX.
Jack Jansen <jack.jansen@cwi.nl>
parents:
18962
diff
changeset
|
1168 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
|
1169 #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
|
1170 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
|
1171 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
|
1172 #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
|
1173 } |
|
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 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
|
1175 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
|
1176 #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
|
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 |
|
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 /* 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
|
1180 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
|
1181 { |
|
18962
d7590122f9a2
Merging appropriate 2.1.1 fixes back into the main trunk.
Jack Jansen <jack.jansen@cwi.nl>
parents:
18434
diff
changeset
|
1182 #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
|
1183 return NULL; |
|
d7590122f9a2
Merging appropriate 2.1.1 fixes back into the main trunk.
Jack Jansen <jack.jansen@cwi.nl>
parents:
18434
diff
changeset
|
1184 #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
|
1185 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
|
1186 #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
|
1187 } |
|
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 |
|
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 /* |
|
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 ** 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
|
1191 ** 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
|
1192 */ |
|
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 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
|
1194 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
|
1195 { |
|
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 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
|
1197 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
|
1198 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
|
1199 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
|
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 /* 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
|
1202 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
|
1203 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
|
1204 /* 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
|
1205 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
|
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 if ( PyString_Check(v) ) { |
|
22023
e068440e116f
backport of 1.52 and 1.53:
Jack Jansen <jack.jansen@cwi.nl>
parents:
21343
diff
changeset
|
1208 #if TARGET_API_MAC_OSX |
|
e068440e116f
backport of 1.52 and 1.53:
Jack Jansen <jack.jansen@cwi.nl>
parents:
21343
diff
changeset
|
1209 FSRef fsr; |
|
e068440e116f
backport of 1.52 and 1.53:
Jack Jansen <jack.jansen@cwi.nl>
parents:
21343
diff
changeset
|
1210 |
|
e068440e116f
backport of 1.52 and 1.53:
Jack Jansen <jack.jansen@cwi.nl>
parents:
21343
diff
changeset
|
1211 if ( !PyMac_GetFSRef(v, &fsr) ) |
|
e068440e116f
backport of 1.52 and 1.53:
Jack Jansen <jack.jansen@cwi.nl>
parents:
21343
diff
changeset
|
1212 return 0; |
|
e068440e116f
backport of 1.52 and 1.53:
Jack Jansen <jack.jansen@cwi.nl>
parents:
21343
diff
changeset
|
1213 if ( FSGetCatalogInfo(&fsr, kFSCatInfoNone, NULL, NULL, fs, NULL) == noErr ) |
|
e068440e116f
backport of 1.52 and 1.53:
Jack Jansen <jack.jansen@cwi.nl>
parents:
21343
diff
changeset
|
1214 return 1; |
|
e068440e116f
backport of 1.52 and 1.53:
Jack Jansen <jack.jansen@cwi.nl>
parents:
21343
diff
changeset
|
1215 return 0; |
|
e068440e116f
backport of 1.52 and 1.53:
Jack Jansen <jack.jansen@cwi.nl>
parents:
21343
diff
changeset
|
1216 #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
|
1217 /* 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
|
1218 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
|
1219 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
|
1220 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
|
1221 parid = 0; |
|
22023
e068440e116f
backport of 1.52 and 1.53:
Jack Jansen <jack.jansen@cwi.nl>
parents:
21343
diff
changeset
|
1222 #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
|
1223 } 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
|
1224 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
|
1225 &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
|
1226 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
|
1227 } |
|
f7f076bfcae9
Implemented minimal FSRef support, plus conversion between FSRefs, FSSpecs and pathnames where applicable.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17864
diff
changeset
|
1228 } |
|
f7f076bfcae9
Implemented minimal FSRef support, plus conversion between FSRefs, FSSpecs and pathnames where applicable.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17864
diff
changeset
|
1229 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
|
1230 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
|
1231 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
|
1232 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
|
1233 } |
|
f7f076bfcae9
Implemented minimal FSRef support, plus conversion between FSRefs, FSSpecs and pathnames where applicable.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17864
diff
changeset
|
1234 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
|
1235 } |
|
f7f076bfcae9
Implemented minimal FSRef support, plus conversion between FSRefs, FSSpecs and pathnames where applicable.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17864
diff
changeset
|
1236 |
|
f7f076bfcae9
Implemented minimal FSRef support, plus conversion between FSRefs, FSSpecs and pathnames where applicable.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17864
diff
changeset
|
1237 /* 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
|
1238 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
|
1239 { |
|
f7f076bfcae9
Implemented minimal FSRef support, plus conversion between FSRefs, FSSpecs and pathnames where applicable.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17864
diff
changeset
|
1240 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
|
1241 } |
|
2180
9b451c84a7bf
Initial version of FSSpec and Alias code. Non-functional as of now.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
1242 |
|
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 ** 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
|
1246 ** 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
|
1247 ** 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
|
1248 */ |
|
83a3e21a7cc3
Moved macfsn hackery from macmain.c to macfsmodule.c so it loads
Just van Rossum <just@letterror.com>
parents:
19841
diff
changeset
|
1249 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
|
1250 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
|
1251 { |
|
20806
42f22ea6a0f1
Under MachO-Python unconditionally import macfsn.
Jack Jansen <jack.jansen@cwi.nl>
parents:
20794
diff
changeset
|
1252 #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
|
1253 if ( !PyMac_options.nonavservice ) { |
|
20806
42f22ea6a0f1
Under MachO-Python unconditionally import macfsn.
Jack Jansen <jack.jansen@cwi.nl>
parents:
20794
diff
changeset
|
1254 #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
|
1255 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
|
1256 |
|
83a3e21a7cc3
Moved macfsn hackery from macmain.c to macfsmodule.c so it loads
Just van Rossum <just@letterror.com>
parents:
19841
diff
changeset
|
1257 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
|
1258 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
|
1259 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
|
1260 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
|
1261 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
|
1262 } |
|
83a3e21a7cc3
Moved macfsn hackery from macmain.c to macfsmodule.c so it loads
Just van Rossum <just@letterror.com>
parents:
19841
diff
changeset
|
1263 else { |
|
83a3e21a7cc3
Moved macfsn hackery from macmain.c to macfsmodule.c so it loads
Just van Rossum <just@letterror.com>
parents:
19841
diff
changeset
|
1264 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
|
1265 } |
|
83a3e21a7cc3
Moved macfsn hackery from macmain.c to macfsmodule.c so it loads
Just van Rossum <just@letterror.com>
parents:
19841
diff
changeset
|
1266 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
|
1267 } |
|
20806
42f22ea6a0f1
Under MachO-Python unconditionally import macfsn.
Jack Jansen <jack.jansen@cwi.nl>
parents:
20794
diff
changeset
|
1268 #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
|
1269 } |
|
20806
42f22ea6a0f1
Under MachO-Python unconditionally import macfsn.
Jack Jansen <jack.jansen@cwi.nl>
parents:
20794
diff
changeset
|
1270 #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
|
1271 } |
|
83a3e21a7cc3
Moved macfsn hackery from macmain.c to macfsmodule.c so it loads
Just van Rossum <just@letterror.com>
parents:
19841
diff
changeset
|
1272 |
|
83a3e21a7cc3
Moved macfsn hackery from macmain.c to macfsmodule.c so it loads
Just van Rossum <just@letterror.com>
parents:
19841
diff
changeset
|
1273 |
|
2180
9b451c84a7bf
Initial version of FSSpec and Alias code. Non-functional as of now.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
1274 /* 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
|
1275 |
|
9b451c84a7bf
Initial version of FSSpec and Alias code. Non-functional as of now.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
1276 void |
|
19066
a1b4f3a1ee07
- Don't return mac-style pathnames in unix-Python.
Jack Jansen <jack.jansen@cwi.nl>
parents:
19030
diff
changeset
|
1277 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
|
1278 { |
| 5071 | 1279 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
|
1280 |
|
19010
fe20d1cfec3d
Oops, arg type for the glue routine was wrong.
Jack Jansen <jack.jansen@cwi.nl>
parents:
18979
diff
changeset
|
1281 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
|
1282 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
|
1283 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
|
1284 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
|
1285 |
|
2180
9b451c84a7bf
Initial version of FSSpec and Alias code. Non-functional as of now.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
1286 /* Create the module and add the functions */ |
| 5071 | 1287 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
|
1288 |
|
9b451c84a7bf
Initial version of FSSpec and Alias code. Non-functional as of now.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
1289 /* Add some symbolic constants to the module */ |
| 5071 | 1290 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
|
1291 ErrorObject = PyMac_GetOSErrException(); |
| 5071 | 1292 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
|
1293 |
|
6330
172c7febd755
Export type objects to Python
Jack Jansen <jack.jansen@cwi.nl>
parents:
5743
diff
changeset
|
1294 Mfsatype.ob_type = &PyType_Type; |
|
172c7febd755
Export type objects to Python
Jack Jansen <jack.jansen@cwi.nl>
parents:
5743
diff
changeset
|
1295 Py_INCREF(&Mfsatype); |
|
172c7febd755
Export type objects to Python
Jack Jansen <jack.jansen@cwi.nl>
parents:
5743
diff
changeset
|
1296 PyDict_SetItemString(d, "AliasType", (PyObject *)&Mfsatype); |
|
172c7febd755
Export type objects to Python
Jack Jansen <jack.jansen@cwi.nl>
parents:
5743
diff
changeset
|
1297 Mfsstype.ob_type = &PyType_Type; |
|
172c7febd755
Export type objects to Python
Jack Jansen <jack.jansen@cwi.nl>
parents:
5743
diff
changeset
|
1298 Py_INCREF(&Mfsstype); |
|
172c7febd755
Export type objects to Python
Jack Jansen <jack.jansen@cwi.nl>
parents:
5743
diff
changeset
|
1299 PyDict_SetItemString(d, "FSSpecType", (PyObject *)&Mfsstype); |
|
172c7febd755
Export type objects to Python
Jack Jansen <jack.jansen@cwi.nl>
parents:
5743
diff
changeset
|
1300 Mfsitype.ob_type = &PyType_Type; |
|
172c7febd755
Export type objects to Python
Jack Jansen <jack.jansen@cwi.nl>
parents:
5743
diff
changeset
|
1301 Py_INCREF(&Mfsitype); |
|
172c7febd755
Export type objects to Python
Jack Jansen <jack.jansen@cwi.nl>
parents:
5743
diff
changeset
|
1302 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
|
1303 |
|
83a3e21a7cc3
Moved macfsn hackery from macmain.c to macfsmodule.c so it loads
Just van Rossum <just@letterror.com>
parents:
19841
diff
changeset
|
1304 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
|
1305 } |
