Cocoa Calling Carbon Question
Cocoa Calling Carbon Question
- Subject: Cocoa Calling Carbon Question
- From: Karl Goiser <email@hidden>
- Date: Mon, 11 Jun 2001 15:18:20 +1000
Hello,
I don't know if this is a dumb question or not, but I can't work it
out. Can anybody help?
Short version:
How do I create an FSSpec from an NSString containg a full path name
(like /Users/karl/file1)?
Long version:
I need to use a function in Carbon that requires an FSSpec. So,
given the full path to a file, I tried the following code:
FSSpec fileSpec;
Str255 fileSpecName;
OSErr err;
//Translate the NSString into a Str255:
if ([fullName getFileSystemRepresentation:&fileSpecName[1]
maxLength: 253]) {
//fileSpecName[0] = [fullName cStringLength];
fileSpecName[0] = strlen(&fileSpecName[1]); // Which one
should I use here?
//Make the FSSpec:
if (err = FSMakeFSSpec(0, 0, fileSpecName, &fileSpec)) {
NSLog(@"doFBCIndexing, FSMakeFSSpec error: %d", err);
} else {
...
}
}
When I run the code in debug mode, all seem to be ok, but I always
get an error -37 (Bad filename) error when trying to make the FSSpec.
The file names are OS X style names, like,
"/Users/karl/Documents/enumerating.rtfd".
I can think that there are two possible problems:
1) FSMakeFSSpec doesn't accept OS X style file names and the above
code will never work,
2) The problem is mine and I have done something wrong above.
Thank you for helping out!
Karl
--
----
Klaatu barada nikto