• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Cocoa Calling Carbon Question
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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


  • Follow-Ups:
    • Re: Cocoa Calling Carbon Question
      • From: Karl Goiser <email@hidden>
    • Re: Cocoa Calling Carbon Question
      • From: Stéphane Sudre <email@hidden>
    • Re: Cocoa Calling Carbon Question
      • From: Clyde McQueen <email@hidden>
  • Prev by Date: Re: NSTextField & sizeToFit
  • Next by Date: Re: Remember window position in multiple monitors
  • Previous by thread: Offscreen Drawing Followup
  • Next by thread: Re: Cocoa Calling Carbon Question
  • Index(es):
    • Date
    • Thread