Re: NSHFSTypeCodeFromFileType troubles
Re: NSHFSTypeCodeFromFileType troubles
- Subject: Re: NSHFSTypeCodeFromFileType troubles
- From: "David W. Halliday" <email@hidden>
- Date: Thu, 07 Mar 2002 16:01:42 -0600
- Organization: TNRCC
David W. Halliday wrote:
>
Chris Gervais wrote:
>
>
> Ah...I didn't even think to include the single quote as I thought that
>
> NSHFSTypeCodeFromFileType just took the string as it was...the doc needs to
>
> be more clear on this!
>
>
>
> > Well OSTypes are just a 4 characters string const, like 'JPEG'.
>
> >
>
> > An file type right now for an HFSfile type(OSType) is encode like
>
> > @"'JPEG'",
>
> > note the single quotes this is important.
>
> >
>
> > Thanks,
>
> > Andrew Pinski
>
> >
>
> > ...
>
>
One caveat: The present form of the encoding of HFS file types into NSStrings
>
is an /implementation detail/ and, hence, cannot be relied upon for all time.
>
Unfortunately, other than directly creating OSTypes, via 'ostp' (Apple added an
>
extension to gcc to allow for these special cases of the character quote---one of
>
the extensions that, presumably, will /never/ make it into the mainstream) there is
>
no function to create such OSTypes from strings (though one would be easy enough to
>
code, and would not have the dependency on the implementation of
>
NSHFSTypeCodeFromFileType, nor the Apple extension to gcc).
>
>
email@hidden
>
...
One issue remains, however, on implementing an NSString (or C string) to OSType
function: Byte order! Be careful, and take advantage of the Byte ordering functions
provided by the OS. Admittedly, this is not an issue so long as you are Mac OS X only
(as opposed to Darwin, since Darwin runs on x86 compatible hardware as well), and as
long as Apple has Mac OS X only running on PPC. However, if you want your code to be
as ready for the future as Darwin (and the non-classic [and, possibly, the non-Carbon]
portions of Mac OS X) you will want to pay special attention to this issue.
(Unfortunately, I'm not sure of the byte order requirements of OSTypes. One would
probably have to delve into the HFS/HFS+ code to see how these are handled with this
regard.)
email@hidden
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.