[Python-checkins] CVS: python/dist/src/Mac/Modules macfsmodule.c,1.51,1.51.6.1

Jack Jansen jackjansen@users.sourceforge.net
2002年2月24日 14:55:36 -0800


Update of /cvsroot/python/python/dist/src/Mac/Modules
In directory usw-pr-cvs1:/tmp/cvs-serv19764
Modified Files:
 Tag: release22-maint
	macfsmodule.c 
Log Message:
backport of 1.52 and 1.53:
- Added as_pathname() method to FSRef objects.
- In MachoPython expect Unix-style pathnames for both FSSpec and FSRef
initializers.
Index: macfsmodule.c
===================================================================
RCS file: /cvsroot/python/python/dist/src/Mac/Modules/macfsmodule.c,v
retrieving revision 1.51
retrieving revision 1.51.6.1
diff -C2 -d -r1.51 -r1.51.6.1
*** macfsmodule.c	11 Dec 2001 14:04:12 -0000	1.51
--- macfsmodule.c	24 Feb 2002 22:55:34 -0000	1.51.6.1
***************
*** 774,781 ****
 }
 
 static struct PyMethodDef mfsr_methods[] = {
 	{"as_fsspec",		(PyCFunction)mfsr_as_fsspec,	1},
 #if 0
- 	{"as_pathname",		(PyCFunction)mfss_as_pathname,			1},
 	{"as_tuple",		(PyCFunction)mfss_as_tuple,				1},
 	{"NewAlias",		(PyCFunction)mfss_NewAlias,				1},
--- 774,797 ----
 }
 
+ static PyObject *
+ mfsr_as_pathname(mfsrobject *self, PyObject *args)
+ {
+ 	char strbuf[PATHNAMELEN];
+ 	OSStatus err;
+ 	
+ 	if (!PyArg_ParseTuple(args, ""))
+ 		return NULL;
+ 	err = FSRefMakePath(&self->fsref, strbuf, PATHNAMELEN);
+ 	if ( err ) {
+ 		PyErr_Mac(ErrorObject, err);
+ 		return NULL;
+ 	}
+ 	return PyString_FromString(strbuf);
+ }
+ 
 static struct PyMethodDef mfsr_methods[] = {
 	{"as_fsspec",		(PyCFunction)mfsr_as_fsspec,	1},
+ 	{"as_pathname",		(PyCFunction)mfsr_as_pathname,			1},
 #if 0
 	{"as_tuple",		(PyCFunction)mfss_as_tuple,				1},
 	{"NewAlias",		(PyCFunction)mfss_NewAlias,				1},
***************
*** 1190,1193 ****
--- 1206,1218 ----
 		return 1;
 	if ( PyString_Check(v) ) {
+ #if TARGET_API_MAC_OSX
+ 		FSRef fsr;
+ 		
+ 		if ( !PyMac_GetFSRef(v, &fsr) )
+ 			return 0;
+ 		if ( FSGetCatalogInfo(&fsr, kFSCatInfoNone, NULL, NULL, fs, NULL) == noErr )
+ 			return 1;
+ 		return 0;
+ #else
 		/* It's a pathname */
 		if( !PyArg_Parse(v, "O&", PyMac_GetStr255, &path) )
***************
*** 1195,1198 ****
--- 1220,1224 ----
 		refnum = 0; /* XXXX Should get CurWD here?? */
 		parid = 0;
+ #endif
 	} else {
 		if( !PyArg_Parse(v, "(hlO&); FSSpec should be FSSpec, FSRef, fullpath or (vrefnum,dirid,path)",

AltStyle によって変換されたページ (->オリジナル) /