• 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
Re: Converting OSX Path to a OS9 Path
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Converting OSX Path to a OS9 Path


  • Subject: Re: Converting OSX Path to a OS9 Path
  • From: Stéphane Sudre <email@hidden>
  • Date: Tue, 7 Jan 2003 15:01:37 +0100

On mardi, janvier 7, 2003, at 11:38 AM, Flemming Bengtsson wrote:

Hi All,

How can you convert an OSX path string contained in a NSString to a OS9
Str255 path string ?

In theory, you can't since nothing can prevent a OSX path to be larger than 255 bytes. Other issues involves the encoding of the file path (UTF8 AFAIK).

If you're sure the file path is going to be smaller than 255 bytes, you can do this:

/* Coded in Mail.app so it may contain bugs */

CFURLRef tURLRef;
NSString * tMacOSString;
const char * tCString;
Str255 myPascalString;
int tLength;

tURLRef=CFURLCreateWithFileSystemPath(kCFAllocatorDefault,(CFStringRef) myPath,kCFURLPOSIXPathStyle,TRUE or FALSE);

tMacOSString =(NSString *) CFURLCopyFileSystemPath(tURLRef,kCFURLHFSPathStyle);

tCString=[tMacOSString lossyCString]; // Say bye bye to encoding and compatibility or use a compatible encoding converter

if (tCString!=NULL)
{
tLength=strlen(tCString);

if (tLength<256)
{
myPascalString[0]= tLength;

BlockMoveData(tCString, &myPascalString[1], tLength);
}
}
_______________________________________________
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.

  • Follow-Ups:
    • Re: Converting OSX Path to a OS9 Path
      • From: Sandy Martel <email@hidden>
  • Prev by Date: Convert hexadecimal NSString (0xff00) to decimal integer?
  • Next by Date: Re: creating an NSImage from an NSView
  • Previous by thread: Re: Converting OSX Path to a OS9 Path
  • Next by thread: Re: Converting OSX Path to a OS9 Path
  • Index(es):
    • Date
    • Thread