Commits

Anonymous committed 1e72071

Added RawFSSpec and RawAlias methods which turn their string arguments
into fsspec and alias objects.

Comments (0)

Files changed (1)

Mac/Modules/macfsmodule.c

 	mfsaobject *self;
 	char *name;
 {
+	if ( strcmp(name, "data") == 0 ) {
+		int size;
+		PyObject *rv;
+		
+		size = GetHandleSize((Handle)self->alias);
+		HLock((Handle)self->alias);
+		rv = PyString_FromStringAndSize(*(Handle)self->alias, size);
+		HUnlock((Handle)self->alias);
+		return rv;
+	}
 	return findmethod(mfsa_methods, (object *)self, name);
 }
 
 	mfssobject *self;
 	char *name;
 {
+	if ( strcmp(name, "data") == 0)
+		return PyString_FromStringAndSize((char *)&self->fsspec, sizeof(FSSpec));	
 	return findmethod(mfss_methods, (object *)self, name);
 }
 
 	return (object *)newmfssobject(&fss);
 }
 
+static object *
+mfs_RawFSSpec(self, args)
+	object *self;	/* Not used */
+	object *args;
+{
+	FSSpec *fssp;
+	int size;
+
+	if (!newgetargs(args, "s#", &fssp, &size))
+		return NULL;
+	if ( size != sizeof(FSSpec) ) {
+		PyErr_SetString(PyExc_TypeError, "Incorrect size for FSSpec record");
+		return NULL;
+	}
+	return (object *)newmfssobject(fssp);
+}
+
+static object *
+mfs_RawAlias(self, args)
+	object *self;	/* Not used */
+	object *args;
+{
+	char *dataptr;
+	Handle h;
+	int size;
+
+	if (!newgetargs(args, "s#", &dataptr, &size))
+		return NULL;
+	h = NewHandle(size);
+	if ( h == NULL ) {
+		PyErr_NoMemory();
+		return NULL;
+	}
+	HLock(h);
+	memcpy((char *)*h, dataptr, size);
+	HUnlock(h);
+	return (object *)newmfsaobject((AliasHandle)h);
+}
+
 /* List of methods defined in the module */
 
 static struct methodlist mfs_methods[] = {
 	{"StandardGetFile",		mfs_StandardGetFile,	1},
 	{"StandardPutFile",		mfs_StandardPutFile,	1},
 	{"FSSpec",				mfs_FSSpec,				1},
+	{"RawFSSpec",			mfs_RawFSSpec,			1},
+	{"RawAlias",			mfs_RawAlias,			1},
  
 	{NULL,		NULL}		/* sentinel */
 };
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.