Re: Cocoa Calling Carbon Question
Re: Cocoa Calling Carbon Question
- Subject: Re: Cocoa Calling Carbon Question
- From: Clyde McQueen <email@hidden>
- Date: Mon, 11 Jun 2001 06:45:32 -0700
FSMakeFSSpec expects path names to be MacOS-style, so you'll have to use
colons ':' instead of slashes '/'.
See
http://developer.apple.com/techpubs/mac/Files/Files-95.html#HEADING95-0
There are other ways to do this; see
http://www.bestweb.net/~tstephen/software/objects/IconFamily/ for one.
/Clyde
On Sunday, June 10, 2001, at 10:18 PM, Karl Goiser wrote:
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
_______________________________________________
cocoa-dev mailing list
email@hidden
http://www.lists.apple.com/mailman/listinfo/cocoa-dev