Welcome to the MacNN Forums.

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

You are here: MacNN Forums > Software - Troubleshooting and Discussion > Developer Center > Help with NSHFSTypeCodeFromFileType

Help with NSHFSTypeCodeFromFileType
Thread Tools
Forum Regular
Join Date: Jan 2001
Location: Boston, MA
Status: Offline
Reply With Quote
Mar 7, 2002, 12:30 PM
 
Has anyone successfully used the NSFoundation function call NSHFSTypeCodeFromFileType()? I'm passing it a four character NSString, but it's always returning zero. I am, naively perhaps, assuming that NSHFSTypeCodeFromFileType will take any four character NSString and turn it into an OSType, not just file types that the system knows about.
     
Professional Poster
Join Date: Oct 2001
Location: London
Status: Offline
Reply With Quote
Mar 10, 2002, 06:03 AM
 
Read the docs again:

(from http://developer.apple.com/techpubs/macosx/Cocoa/Referen ce/Foundation/ObjC_classic/Functions/FoundationFunctions.html)


Given a string of the sort encoded by NSFileTypeForHFSTypeCode(), this function returns the corresponding HFS file type code. It returns zero otherwise.
and more importantly from (http://developer.apple.com/techpubs/macosx/Cocoa/TasksAndConcepts/ProgrammingTopics/LowLevelFileMgmt/Concepts/HFSFileTypes.html):


Classic HFS file types are specified by a 32-bit integer (OSType), usually represented as four characters, such as GIFf or MooV. Cocoa cannot directly use HFS file types in this form, so they must be encoded into an NSString (or Java String). The encoded HFS file type is surrounded by apostrophes, like so:

'<HFS Four Character File Type Code>'


Thus, the type of a typical Mac OS 9 text file can be specified by the Objective-C string @"'TEXT'".
spaced so you can read it better: " ' TEXT ' "

Hope this helps - it confused me first time as well

[ 03-10-2002: Message edited by: Diggory Laycock ]
     
   
Thread Tools
Forum Links
Forum Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Top
Privacy Policy
All times are GMT -5. The time now is 12:15 PM.
All contents of these forums © 1995-2011 MacNN. All rights reserved.
Branding + Design: www.gesamtbild.com
vBulletin v.3.8.7 © 2000-2011, Jelsoft Enterprises Ltd., Content Relevant URLs by vBSEO 3.3.2