Mailing Lists: Apple Mailing Lists
Image of Mac OS face in stamp
Re: coremidi & codewarrior
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: coremidi & codewarrior



Thank you Laurent. Here is a solution for anyone else who runs into this
conversion problem. Note the solution below limits path names to 255
characters so it is NOT a complete solution. Also it uses c2Pstr which it
seems Apple is not encouraging.

void ConvertPathToUnixStyleMachOPath(StringPtr s)
{
CFStringRef path =
CFStringCreateWithPascalString(kCFAllocatorDefault, s,
CFStringGetSystemEncoding());
CFURLRef theURL =
CFURLCreateWithFileSystemPath(kCFAllocatorDefault,path,
kCFURLHFSPathStyle, false);
CFIndex bufLen = sizeof(Str255) - 1;
if (CFURLGetFileSystemRepresentation(theURL, true, s, bufLen))
c2pstr((char *)s);
CFAllocatorDeallocate(kCFAllocatorDefault, (void *)theURL);
CFAllocatorDeallocate(kCFAllocatorDefault, (void *)path);
}

Jeremy

> From: Laurent Cerveau <email@hidden>
> Date: Thu, 21 Feb 2002 11:49:16 +0100
> To: "Jeremy@Verizon" <email@hidden>
> Cc: email@hidden
> Subject: Re: coremidi & codewarrior
>
> In order to manipulate references to file in OS X, CFURL is your
> friend. Basically it can be used as a central point to do the conversion
> with functions like :
>
> CFURLCreateFromFSRef(CFAllocatorRef allocator, const FSRef *fsRef);
> CFURLGetFSRef(CFURLRef url, FSRef *fsRef);
> CFURLGetFileSystemRepresentation(CFURLRef url, Boolean
> resolveAgainstBase, UInt8 *buffer, CFIndex maxBufLen);
> CFURLCreateWithFileSystemPath(CFAllocatorRef allocator, CFStringRef
> filePath, CFURLPathStyle pathStyle, Boolean isDirectory);
>
> There may be a function that does that directly somewhere around hfs
> files but on top of my head I do not remember :-(.
>
> Hope this helps
>
> Laurent
_______________________________________________
coreaudio-api mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/coreaudio-api
Do not post admin requests to the list. They will be ignored.

References: 
 >Re: coremidi & codewarrior (From: Laurent Cerveau <email@hidden>)



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2011 Apple Inc. All rights reserved.