🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.sys.mac.programmer.help
Article #21

Re: Can an OSType be interchanged with a Str255? How?

#21
From: Steve Caine
Date: Thu, 07 Sep 1995 03:39
27 lines
1360 bytes
In article <oylerb-2108950006040001@msp1-5.nas.mr.net>,
oylerb@tdkt.skypoint.net (Bill A. Oyler) wrote:

> Hello,
> 
> This should be a simple question.  I need to change the creator of a file
> by using the SetFInfo toolbox call.  The creator is stored in a Str255,
> however, not in an OSType like the call requires.
> 
> How can I convert a Str255 to an OSType?  I tried some different methods
> of typecasting, but can't get anything to work.  Help!  :)

Bill,

Try this.

// CAUTION: This is dangerous on 68000 processors (Plus, Classic, etc.)
// because it can't handle addressing multi-byte values at odd addresses.
// Sometimes &theString[1] will be even, sometimes it will be odd.

Str255   theString = "\pTEXT";
OSType   theType;

if (theString[0] == 4) theType = *(long *)&theString[1];

--
Steve Caine
Technical Details
Message-ID: <scaine-0609952340030001@192.0.2.1>
Path: arc1-ca.pugleaf.net!news.kei.com!world!NewsWatcher!user
References: <oylerb-2108950006040001@msp1-5.nas.mr.net> <sproul-3008951238290001@marks.rd.ap.org>

Show Full Headers
Complete Article Headers
Newsgroups: comp.sys.mac.programmer.help,comp.lang.c
Path: arc1-ca.pugleaf.net!news.kei.com!world!NewsWatcher!user
From: scaine@world.std.com (Steve Caine)
Subject: Re: Can an OSType be interchanged with a Str255?  How?
Message-ID: <scaine-0609952340030001@192.0.2.1>
Sender: news@world.std.com (Mr Usenet Himself)
Nntp-Posting-Host: world.std.com
Organization: The World @ Software Tool & Die
References: <oylerb-2108950006040001@msp1-5.nas.mr.net> <sproul-3008951238290001@marks.rd.ap.org>
Date: Thu, 7 Sep 1995 03:39:51 GMT