|
From: <cre...@us...> - 2006-07-08 00:41:58
|
Revision: 1445 Author: creecode Date: 2006-07-07 17:41:55 -0700 (Fri, 07 Jul 2006) ViewCVS: http://svn.sourceforge.net/frontierkernel/?rev=1445&view=rev Log Message: ----------- minor code formatting tweaks removed include SetUpA5.h renamed CFStringToStr255 function to CFStringRefToStr255 fix problems with conversions of CFStringRef to other formats by using MIN macro from sys/params.h Modified Paths: -------------- Frontier/branches/FSRef_Migration/Common/source/file.c Modified: Frontier/branches/FSRef_Migration/Common/source/file.c =================================================================== --- Frontier/branches/FSRef_Migration/Common/source/file.c 2006-07-04 07:45:48 UTC (rev 1444) +++ Frontier/branches/FSRef_Migration/Common/source/file.c 2006-07-08 00:41:55 UTC (rev 1445) @@ -31,6 +31,7 @@ #ifdef MACVERSION #include "MoreFilesX.h" + #include <sys/param.h> #endif @@ -51,16 +52,6 @@ #include "langinternal.h" /*for langbackgroundtask*/ -#ifdef MACVERSION -#ifdef flcomponent - - #include "SetUpA5.h" - -#endif -#endif - - - boolean equalfilespecs (const ptrfilespec fs1, const ptrfilespec fs2) { // @@ -916,42 +907,47 @@ // // the caller must dispose of the CFString // + // 2006-07-06 creedon: created + // HFSUniStr255 hname; OSErr err = FSGetCatalogInfo ( fsRef, kFSCatInfoNone, NULL, &hname, NULL, NULL ); *name = CFStringCreateWithCharacters ( kCFAllocatorDefault, hname.unicode, hname.length ); - // CFRelease ( name ); - return ( err ); } // FSRefGetName - boolean CFStringToStr255 ( CFStringRef input, StringPtr output ) { + boolean CFStringRefToStr255 ( CFStringRef input, StringPtr output ) { - output [ 0 ] = CFStringGetBytes ( input, CFRangeMake ( 0, ( ( CFStringGetLength ( input ) >= 255 ) ? - 255 : CFStringGetLength ( input ) ) ), kTextEncodingMacRoman, '^', false, - &( output [1] ), 255, NULL ); + // + // 2006-07-06 creedon: created, cribbed from < http://developer.apple.com/carbon/tipsandtricks.html#CFStringFromUnicode > + // + + output [ 0 ] = CFStringGetBytes ( input, CFRangeMake ( 0, MIN ( CFStringGetLength ( input ), 255 ) ), + kTextEncodingMacRoman, '^', false, &( output [ 1 ] ), 255, NULL ); - // MIN ( CFStringGetLength ( input ), 255 ) - if ( output [ 0 ] == 0 ) return ( false ); return ( true ); - } // CFStringToStr255 + } // CFStringRefToStr255 boolean HFSUniStr255ToStr255 ( ConstHFSUniStr255Param input, StringPtr output ) { + // + // 2006-07-06 creedon; created + // + CFStringRef csr; csr = CFStringCreateWithCharacters ( kCFAllocatorDefault, input -> unicode, input -> length ); - CFStringToStr255 ( csr, output ); + CFStringRefToStr255 ( csr, output ); CFRelease ( csr ); @@ -962,6 +958,10 @@ boolean FSRefGetNameStr255 ( const FSRef *fsRef, Str255 bsname ) { + // + // 2006-07-06 creedon; created + // + CFStringRef csr; OSErr err = FSRefGetName ( fsRef, &csr ); @@ -983,33 +983,18 @@ boolean bigstringToHFSUniStr255 ( const bigstring bs, HFSUniStr255 *output ) { - CFStringRef temp = CFStringCreateWithPascalString (kCFAllocatorDefault, bs, kCFStringEncodingMacRoman ); + // + // 2006-07-06 creedon; created + // + + CFStringRef csr = CFStringCreateWithPascalString (kCFAllocatorDefault, bs, kCFStringEncodingMacRoman ); - output -> length = CFStringGetLength(temp); + ( *output ).length = CFStringGetLength ( csr ); - CFStringGetCharacters(temp, CFRangeMake(0, output -> length), output -> unicode); + CFStringGetCharacters ( csr, CFRangeMake ( 0, ( *output ).length ), ( *output ).unicode ); - CFRelease ( temp ); - - /* - HFSUniStr255 name; - unsigned long len; - OSStatus status; - // TextEncoding encoding = ; - TextToUnicodeInfo info; - - if ( CreateTextToUnicodeInfoByEncoding ( CreateTextEncoding ( kTextEncodingMacRoman, - kTextEncodingDefaultVariant, kTextEncodingDefaultFormat ), &info ) != noErr ) - return ( false ); - - status = ConvertFromPStringToUnicode ( info, bs, sizeof ( name.unicode ), ( name -> length ), name.unicode ); + CFRelease ( csr ); - DisposeTextToUnicodeInfo ( &info ); - - if ( status != noErr ) - return ( false ); - */ - return ( true ); } // bigstringToHFSUniStr255 @@ -1017,34 +1002,19 @@ boolean CFStringRefToHFSUniStr255 ( CFStringRef input, HFSUniStr255 *output ) { - output -> length = CFStringGetBytes ( input, CFRangeMake ( 0, ( ( CFStringGetLength ( input ) >= 255 ) ? - CFStringGetLength ( input ) : 255 ) ), - kCFStringEncodingUnicode, 0, false, ( UInt8 * ) ( output -> unicode ), 255, - NULL ); + // + // 2006-07-06 creedon: created, cribbed from < http://developer.apple.com/carbon/tipsandtricks.html#CFStringFromUnicode > + // + + ( *output ).length = CFStringGetBytes ( input, CFRangeMake (0, MIN ( CFStringGetLength ( input ), 255 ) ), + kCFStringEncodingUnicode, 0, false, ( UInt8 * ) ( *output).unicode, 255, NULL ); - if ( output -> length == 0 ) + if ( ( *output ).length == 0 ) return ( false ); return ( true ); } // CFStringRefToHFSUniStr255 - - /* bigstring fsname ( const ptrfilespec fs ) { - - bigstring bsname; - - CFStringRef cname; - - FSRefGetName ( ( *fs ).ref, &cname ); - - CFStringToStr255 ( cname, &bsname ); - - CFRelease ( cname ); - - return ( bsname ); - - } */ - #endif This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |