summaryrefslogtreecommitdiff
path: root/tomacbinary.c
diff options
context:
space:
mode:
authorGeorge Williams <gww@silcom.com>2005-08-25 21:13:42 +0000
committerGeorge Williams <gww@silcom.com>2005-08-25 21:13:42 +0000
commit71966b18cc2b3c24b97cf932dbef4a569dd83051 (patch)
tree8cfb27b42445d8dc1ecf9c6e33c2c68a22a86bd7 /tomacbinary.c
parenta8139580a8d40bb09215ed48a46c0d40878fb28a (diff)
Don't use FSSpec type any more (except when in compatibility mode).
Diffstat (limited to 'tomacbinary.c')
-rw-r--r--tomacbinary.c39
1 files changed, 37 insertions, 2 deletions
diff --git a/tomacbinary.c b/tomacbinary.c
index 0500140..d76e06e 100644
--- a/tomacbinary.c
+++ b/tomacbinary.c
@@ -79,7 +79,17 @@ static void Usage(char *prog) {
}
static FILE *ResForkOfDataFile(char *dataname) {
-#if __Mac
+#ifndef OldMacintosh
+ /* OS/X and linux with appropriate drivers */
+ char *respath = malloc(strlen(dataname)+strlen("/rsrc")+1);
+ FILE *temp;
+
+ strcpy(respath,dataname);
+ strcat(respath,"/rsrc");
+ temp = fopen(respath,"r");
+ free(respath);
+return( temp );
+#elif __Mac /* At 10.4 Mac starts warning that FSSpec is depreciated */
/* copy the resource fork of dataname (if any) into the data fork of a temp file */
FSRef ref;
FSSpec spec;
@@ -118,7 +128,32 @@ return( NULL );
}
static void FindTypeCreater(char *dataname,char **create,char **type) {
-#if __Mac
+#if __Mac && !defined(OldMacintosh)
+ static char cbuf[5], tbuf[5];
+ FSRef ref;
+ FSCatalogInfo info;
+
+ if ( FSPathMakeRef( (unsigned char *) dataname,&ref,NULL)!=noErr )
+return;
+ if ( FSGetCatalogInfo(&ref,kFSCatInfoFinderInfo,&info,NULL,NULL,NULL)!=noErr )
+return;
+ if ( *type==NULL ) {
+ tbuf[0] = ((FInfo *) (info.finderInfo))->fdType>>24;
+ tbuf[1] = ((FInfo *) (info.finderInfo))->fdType>>16;
+ tbuf[2] = ((FInfo *) (info.finderInfo))->fdType>>8;
+ tbuf[3] = ((FInfo *) (info.finderInfo))->fdType;
+ tbuf[4] = '\0';
+ *type = tbuf;
+ }
+ if ( *create==NULL ) {
+ cbuf[0] = ((FInfo *) (info.finderInfo))->fdCreator>>24;
+ cbuf[1] = ((FInfo *) (info.finderInfo))->fdCreator>>16;
+ cbuf[2] = ((FInfo *) (info.finderInfo))->fdCreator>>8;
+ cbuf[3] = ((FInfo *) (info.finderInfo))->fdCreator;
+ cbuf[4] = '\0';
+ *create = cbuf;
+ }
+#elif defined(OldMacintosh)
static char cbuf[5], tbuf[5];
FSRef ref;
FSSpec spec;