|
From: <cre...@us...> - 2007-02-23 19:27:44
|
Revision: 1620
http://svn.sourceforge.net/frontierkernel/?rev=1620&view=rev
Author: creecode
Date: 2007-02-23 11:27:43 -0800 (Fri, 23 Feb 2007)
Log Message:
-----------
support for long odb item names and file paths
formatting tweaks
Modified Paths:
--------------
Frontier/branches/Frontier_Long_File_Paths/Common/headers/file.h
Frontier/branches/Frontier_Long_File_Paths/Common/source/file.c
Frontier/branches/Frontier_Long_File_Paths/Common/source/fileops.c
Frontier/branches/Frontier_Long_File_Paths/Common/source/filepath.c
Frontier/branches/Frontier_Long_File_Paths/Common/source/fileverbs.c
Frontier/branches/Frontier_Long_File_Paths/Common/source/findinfile.c
Frontier/branches/Frontier_Long_File_Paths/Common/source/font.c
Frontier/branches/Frontier_Long_File_Paths/Common/source/frontierwindows.c
Modified: Frontier/branches/Frontier_Long_File_Paths/Common/headers/file.h
===================================================================
--- Frontier/branches/Frontier_Long_File_Paths/Common/headers/file.h 2007-02-23 18:20:57 UTC (rev 1619)
+++ Frontier/branches/Frontier_Long_File_Paths/Common/headers/file.h 2007-02-23 19:27:43 UTC (rev 1620)
@@ -280,7 +280,7 @@
extern boolean flushvolumechanges (const ptrfilespec fsspec, hdlfilenum fnum);
-extern boolean getfullfilepath (bigstring);
+extern boolean getfullfilepath ( Handle );
extern boolean foldertest ( FSRefParamPtr );
@@ -424,24 +424,30 @@
#ifdef MACVERSION
+ extern OSErr FSRefGetName ( const FSRef *, CFStringRef * );
+
extern boolean CFStringRefToHFSUniStr255 ( CFStringRef, HFSUniStr255 * ); // 2006-06-07 creedon
+ extern boolean CFStringRefToCString ( CFStringRef, StringPtr ); // 2006-11-22 creedon
+
extern boolean CFStringRefToStr255 ( CFStringRef, StringPtr ); // 2006-06-07 creedon
extern boolean FSRefGetNameStr255 ( const FSRef *, Str255 ); // 2006-06-07 creedon
+ extern boolean HFSUniStr255ToCString ( ConstHFSUniStr255Param, StringPtr ); // 2006-11-22 creedon
+
extern boolean HFSUniStr255ToStr255 ( ConstHFSUniStr255Param, StringPtr ); // 2006-06-07 creedon
extern boolean bigstringToHFSUniStr255 ( const bigstring, HFSUniStr255 * ); // 2006-06-07 creedon
extern void filegetinfofrompb ( FSRefParam *, tyfileinfo * );
-
+
extern void filegetinfofrompbcipbr ( CInfoPBRec *, tyfileinfo * );
-
+
extern boolean getmacfileinfo ( const ptrfilespec, FSRefParamPtr, FSCatalogInfoPtr );
-
+
extern boolean getmacfileinfocipbr ( const FSSpecPtr, CInfoPBRec * );
-
+
/* 2006-08-11 creedon: cribbed from MoreFilesX.c and modded to work with Str255 */
OSErr
@@ -504,12 +510,16 @@
extern boolean extendfilespec ( const ptrfilespec, ptrfilespec ); // 2006-06-23 creedon
+extern boolean fileFromPathTextHandle ( Handle, Handle ); // 2006-11-25 creedon
+
extern boolean getfilespecparent ( ptrfilespec ); // 2006-06-17 creedon
-extern boolean setfilelabelindex (const ptrfilespec , short, boolean); // 2006-04-23 creedon */
+extern boolean popFromPathTextHandle ( Handle, Handle *, char ); // 2006-11-26 creedon
-extern short getfilelabelindex (const ptrfilespec , short *); // 2006-04-23 creedon */
+extern boolean setfilelabelindex (const ptrfilespec , short, boolean); // 2006-04-23 creedon
+extern short getfilelabelindex (const ptrfilespec , short *); // 2006-04-23 creedon
+
#ifdef MACVERSION
extern OSStatus GetApplicationIconRef ( const ProcessSerialNumber * , const FSSpec* , IconRef * ); // 2006-06-04 creedon
@@ -521,28 +531,28 @@
#pragma mark === filepath.c ===
- extern boolean directorytopath ( const ptrfilespec, bigstring);
+extern boolean directorytopath ( const ptrfilespec, Handle );
-extern boolean volumerefnumtopath (short, bigstring);
+extern boolean filegetdefaultpath ( ptrfilespec );
+extern boolean filegetpath ( const ptrfilespec, bigstring );
+
extern boolean filesetdefaultpath ( const ptrfilespec );
-extern boolean filegetdefaultpath (ptrfilespec );
+extern boolean filespectopath ( const ptrfilespec, Handle * );
-extern boolean filespectopath (const ptrfilespec , bigstring);
+extern boolean getfsfile ( const ptrfilespec, bigstring );
-extern boolean pathtofilespec ( bigstring, ptrfilespec );
+extern boolean getfsvolume ( const ptrfilespec, long * );
-extern boolean filegetpath (const ptrfilespec , bigstring);
+extern boolean pathtofilespec ( Handle, ptrfilespec );
-extern boolean setfsfile (ptrfilespec , bigstring);
+extern boolean setfsfile ( ptrfilespec, bigstring );
-extern boolean getfsfile (const ptrfilespec , bigstring);
+extern boolean volumerefnumtopath ( short, bigstring );
-extern boolean getfsvolume (const ptrfilespec, long *);
+extern void initfsdefault ( void ); // 2005-07-18 creedon
-extern void initfsdefault (void); /* 2005-07-18 creedon */
-
#pragma mark === fileverbs.c ===
Modified: Frontier/branches/Frontier_Long_File_Paths/Common/source/file.c
===================================================================
--- Frontier/branches/Frontier_Long_File_Paths/Common/source/file.c 2007-02-23 18:20:57 UTC (rev 1619)
+++ Frontier/branches/Frontier_Long_File_Paths/Common/source/file.c 2007-02-23 19:27:43 UTC (rev 1620)
@@ -526,6 +526,8 @@
static boolean filecreateandopen ( ptrfilespec fs, OSType creator, OSType filetype, hdlfilenum *fnum) {
//
+ // 2007-02-23 creedon: added bad name error condition
+ //
// 2006-09-15 creedon: for Mac, FSRef-ized
//
@@ -536,10 +538,12 @@
setfserrorparam ( fs );
- CFStringRefToHFSUniStr255 ( ( *fs ).path, &name );
-
- err = FSCreateFileUnicode ( &( *fs ).fsref, name.length, name.unicode, kFSCatInfoNone, NULL, &( *fs ).fsref, NULL );
-
+ if ( CFStringRefToHFSUniStr255 ( ( *fs ).path, &name ) )
+ err = FSCreateFileUnicode ( &( *fs ).fsref, name.length, name.unicode, kFSCatInfoNone, NULL, &( *fs ).fsref,
+ NULL );
+ else
+ err = bdNamErr;
+
if ( oserror ( err ) )
return (false);
@@ -904,11 +908,13 @@
#ifdef MACVERSION
- static OSErr FSRefGetName ( const FSRef *fsRef, CFStringRef *name ) {
+ OSErr FSRefGetName ( const FSRef *fsRef, CFStringRef *name ) {
//
// the caller must dispose of the CFString
//
+ // 2007-02-23 creedon: made function externally available
+ //
// 2006-07-06 creedon: created
//
@@ -922,6 +928,22 @@
} // FSRefGetName
+ boolean CFStringRefToCString ( CFStringRef input, StringPtr output ) {
+
+ //
+ // 2006-11-22 creedon: created, cribbed from < http://developer.apple.com/carbon/tipsandtricks.html#CFStringFromUnicode >
+ //
+
+ // check output for NULL
+
+ if ( CFStringGetCString ( input, output, CFStringGetLength ( input ) + 1, kCFStringEncodingMacRoman ) )
+ return ( true );
+
+ return ( false );
+
+ } // CFStringRefToCString
+
+
boolean CFStringRefToStr255 ( CFStringRef input, StringPtr output ) {
//
@@ -943,6 +965,25 @@
} // CFStringRefToStr255
+ boolean HFSUniStr255ToCString ( ConstHFSUniStr255Param input, StringPtr output ) {
+
+ //
+ // 2006-11-22 creedon; created
+ //
+
+ CFStringRef csr;
+
+ csr = CFStringCreateWithCharacters ( kCFAllocatorDefault, input -> unicode, input -> length );
+
+ CFStringRefToCString ( csr, output );
+
+ CFRelease ( csr );
+
+ return ( true );
+
+ } // HFSUniStr255ToCString
+
+
boolean HFSUniStr255ToStr255 ( ConstHFSUniStr255Param input, StringPtr output ) {
//
@@ -1009,11 +1050,19 @@
boolean CFStringRefToHFSUniStr255 ( CFStringRef input, HFSUniStr255 *output ) {
//
+ // 2006-11-30 creedon: fix bug where if input was 255 characters, we were only getting back 127 in output,
+ // increased buffer to 511
+ //
// 2006-08-11 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 );
+ CFIndex length = CFStringGetLength ( input );
+
+ if ( length > 255 )
+ return ( false );
+
+ ( *output ).length = CFStringGetBytes ( input, CFRangeMake ( 0, MIN ( length, 255 ) ),
+ kCFStringEncodingUnicode, 0, false, ( UInt8 * ) ( *output ).unicode, 511, NULL );
if ( ( *output ).length == 0 )
return ( false );
Modified: Frontier/branches/Frontier_Long_File_Paths/Common/source/fileops.c
===================================================================
--- Frontier/branches/Frontier_Long_File_Paths/Common/source/fileops.c 2007-02-23 18:20:57 UTC (rev 1619)
+++ Frontier/branches/Frontier_Long_File_Paths/Common/source/fileops.c 2007-02-23 19:27:43 UTC (rev 1620)
@@ -84,12 +84,6 @@
#endif
-#ifdef flsystem6
-
-static short applicationvolnum = 0;
-
-#endif
-
static short applicationresnum = -1;
#ifdef MACVERSION
@@ -179,16 +173,22 @@
#endif
return (false);
+
} /*endswithpathsep*/
boolean cleanendoffilename (bigstring bs) {
+
if (endswithpathsep(bs)) {
+
setstringlength (bs, stringlength(bs) - 1);
+
return (true);
+
}
return (false);
+
} /*cleanendoffilename*/
@@ -1898,25 +1898,6 @@
} /*filegetapplicationrnum*/
-#ifdef flsystem6
-
-short filegetapplicationvnum (void) {
-
- return (applicationvolnum);
- } /*filegetapplicationvnum*/
-
-
-short filegetsystemvnum (void) {
-
- SysEnvRec env;
-
- SysEnvirons (1, &env);
-
- return (env.sysVRefNum);
- } /*filegetsystemvnum*/
-
-#endif
-
#ifdef MACVERSION
static boolean pathtovolume (bigstring bspath, short *vnum) {
@@ -3418,6 +3399,8 @@
boolean newfile ( const ptrfilespec fs, OSType creator, OSType filetype ) {
//
+ // 2007-02-23 creedon: support for long odb item names and file paths
+ //
// 2006-06-18 creedon: for Mac, FSRef-ized
//
@@ -3428,10 +3411,12 @@
setfserrorparam ( fs );
- CFStringRefToHFSUniStr255 ( ( *fs ).path, &name );
-
- err = FSCreateFileUnicode ( &( *fs ).fsref, name.length, name.unicode, kFSCatInfoNone, NULL, &( *fs ).fsref, NULL );
-
+ if ( CFStringRefToHFSUniStr255 ( ( *fs ).path, &name ) )
+ err = FSCreateFileUnicode ( &( *fs ).fsref, name.length, name.unicode, kFSCatInfoNone, NULL, &( *fs ).fsref,
+ NULL );
+ else
+ err = bdNamErr;
+
return ( ! oserror ( err ) );
#endif
@@ -3465,27 +3450,45 @@
#ifdef MACVERSION
- boolean getfullfilepath (bigstring bspath) {
+ boolean getfullfilepath ( Handle handlePath ) {
//
+ // 2007-02-23 creedon: support for long odb item names and file paths
+ //
// 2006-06-25 creedon: FSRef-ized
//
+ Handle colon = NULL, forwardSlash = NULL;
+ boolean fl = false;
+ bigstring bs;
tyfilespec fs;
- setoserrorparam (bspath); /*in case error message takes a filename parameter*/
+ if ( ! newtexthandle ( BIGSTRING ( "\x01" ":" ), &colon ) )
+ return ( false );
- insertstring ( BIGSTRING ( "\x09" "/Volumes/" ), bspath );
+ if ( ! newtexthandle ( BIGSTRING ( "\x01" "/" ), &forwardSlash ) )
+ goto exit;
- stringreplaceall ( ':', '/', bspath );
+ texthandletostring ( handlePath, bs );
+
+ setoserrorparam ( bs ); // in case error message takes a filename parameter
+
+ inserttextinhandle ( handlePath, 0L, BIGSTRING ( "\x09" "/Volumes/" ) );
+
+ textfindreplace ( handlePath, colon, forwardSlash, true, false );
+
+ if ( oserror ( FSPathMakeRef ( *handlePath, &fs.fsref, NULL ) ) )
+ goto exit;
+
+ fl = filespectopath ( &fs, &handlePath );
+
+ exit:
+
+ disposehandle ( colon );
+ disposehandle ( forwardSlash );
- convertpstring ( bspath );
+ return ( fl );
- if ( oserror ( FSPathMakeRef ( bspath, &fs.fsref, NULL ) ) )
- return ( false );
-
- return ( filespectopath ( &fs, bspath ) );
-
} // getfullfilepath
@@ -3525,12 +3528,6 @@
#endif
- #ifdef flsystem6
-
- GetVol (nil, &applicationvolnum);
-
- #endif
-
#ifdef MACVERSION
#ifdef flcomponent
@@ -3630,6 +3627,8 @@
boolean extendfilespec ( const ptrfilespec fsin, ptrfilespec fsout ) {
//
+ // 2007-02-23 creedon: support for long odb item names and file paths
+ //
// 2006-06-23 creedon: created
//
@@ -3648,9 +3647,10 @@
HFSUniStr255 name;
OSErr err;
- CFStringRefToHFSUniStr255 ( ( *fsin ).path, &name );
+ if ( ! CFStringRefToHFSUniStr255 ( ( *fsin ).path, &name ) )
+ return ( false );
- err = FSMakeFSRefUnicode ( &( *fsin ).fsref, name.length, name.unicode, kTextEncodingUnknown, &fst.fsref ); // kTextEncodingUnicodeDefault
+ err = FSMakeFSRefUnicode ( &( *fsin ).fsref, name.length, name.unicode, kTextEncodingUnknown, &fst.fsref );
if ( err != noErr )
return ( false );
@@ -3686,3 +3686,153 @@
} // getfilespecparent
+
+boolean fileFromPathTextHandle ( Handle path, Handle fileName ) {
+
+ //
+ // return all the characters to the right of the last path seperator in the path
+ //
+ // example: "Work Disk #1:MORE Work:Status Center" returns "Status Center"
+ //
+ // 2007-02-23 creedon: created, cribbed from filefrompath function
+ //
+
+ #ifdef MACVERSION
+
+ return ( textHandleLastWord ( path, chpathseparator, &fileName ) );
+
+ #endif
+
+ #ifdef WIN95VERSION
+
+ char fn[300];
+ char * fileptr;
+ tyfilespec fs;
+
+ copystring (path, fsname (&fs));
+
+ if (stringlength (path) >= 255) { /* RAB 4/27/98 fix for to long a filename conversion attempt*/
+
+ setemptystring (fname);
+
+ return (true);
+
+ }
+
+ if (isemptystring (path) || fileisvolume (&fs)) {
+
+ copystring (path, fname);
+
+ return (true);
+
+ }
+
+ nullterminate (path);
+
+ GetFullPathName (stringbaseaddress(path), 298, fn, &fileptr);
+
+ /*the comparison of fileptr within the legal range of fn is a kludge
+ but if fixes GetFullPathName which goes wild on some strings and
+ there is no other way of determining that it has gone wild.
+ RAB 4/27/98 */
+
+ if ((fileptr == NULL) || (fileptr < fn) || (fileptr > (fn + 298)))
+ setemptystring (fname);
+ else
+ copyctopstring (fileptr, fname);
+
+ // strcpy (stringbaseaddress(fname), fileptr);
+ // setstringlength (fname, strlen (fileptr));
+
+ return (true);
+
+ #endif
+
+ } // fileFromPathTextHandle
+
+
+boolean popFromPathTextHandle ( Handle path, Handle *fileName, char characterDelimiter ) {
+
+ //
+ // pop the characters to the right of the last path seperator in the path
+ //
+ // example: "Work Disk #1:MORE Work:Status Center" returns "Status Center"
+ //
+ // 2007-02-23 creedon: created, cribbed from filefrompath function
+ //
+
+ if ( characterDelimiter == NULL )
+ characterDelimiter = chpathseparator;
+
+ #ifdef MACVERSION
+
+ Handle h;
+ long ix, length = gethandlesize ( path );
+ register ptrbyte p = ( ptrbyte ) *path;
+
+ for ( ix = length - 1; ix > 0; --ix ) {
+
+ if ( p [ ix ] == characterDelimiter )
+ break;
+
+ } // for
+
+ length = length - ++ix;
+
+ newhandle ( length, &h );
+
+ popfromhandle ( path, length, *h );
+
+ *fileName = h;
+
+ return ( true );
+
+ #endif
+
+ #ifdef WIN95VERSION
+
+ char fn[300];
+ char * fileptr;
+ tyfilespec fs;
+
+ copystring (path, fsname (&fs));
+
+ if (stringlength (path) >= 255) { /* RAB 4/27/98 fix for to long a filename conversion attempt*/
+
+ setemptystring (fname);
+
+ return (true);
+
+ }
+
+ if (isemptystring (path) || fileisvolume (&fs)) {
+
+ copystring (path, fname);
+
+ return (true);
+
+ }
+
+ nullterminate (path);
+
+ GetFullPathName (stringbaseaddress(path), 298, fn, &fileptr);
+
+ /*the comparison of fileptr within the legal range of fn is a kludge
+ but if fixes GetFullPathName which goes wild on some strings and
+ there is no other way of determining that it has gone wild.
+ RAB 4/27/98 */
+
+ if ((fileptr == NULL) || (fileptr < fn) || (fileptr > (fn + 298)))
+ setemptystring (fname);
+ else
+ copyctopstring (fileptr, fname);
+
+ // strcpy (stringbaseaddress(fname), fileptr);
+ // setstringlength (fname, strlen (fileptr));
+
+ return (true);
+
+ #endif
+
+ } // popFromPathTextHandle
+
Modified: Frontier/branches/Frontier_Long_File_Paths/Common/source/filepath.c
===================================================================
--- Frontier/branches/Frontier_Long_File_Paths/Common/source/filepath.c 2007-02-23 18:20:57 UTC (rev 1619)
+++ Frontier/branches/Frontier_Long_File_Paths/Common/source/filepath.c 2007-02-23 19:27:43 UTC (rev 1620)
@@ -52,9 +52,11 @@
static tyfilespec fsdefault; // we maintain our own default directory
- boolean directorytopath ( const ptrfilespec fs, bigstring path ) {
+ boolean directorytopath ( const ptrfilespec fs, Handle handlePath ) {
//
+ // 2007-02-23 creedon: support for long odb item names and file paths
+ //
// 2006-09-09 creedon: FSRef-ized
// another way might be to use FSRefMakePath and then push insert the volume name on it
//
@@ -73,7 +75,7 @@
if ( err == noErr ) {
- setemptystring ( path );
+ handlePath = NULL;
return ( true );
@@ -81,17 +83,18 @@
} // bail
- CFMutableStringRef ioPath = CFStringCreateMutable ( NULL, 0 );
FSCatalogInfo catalogInfo;
FSRef localRef = ( *fs ).fsref;
HFSUniStr255 names [ 100 ];
+ Handle handleText;
int i, n;
- UniChar inSepChar = ':';
err = noErr;
-
+
+ newemptyhandle ( &handleText );
+
clearbytes ( &catalogInfo, longsizeof ( catalogInfo ) );
-
+
for ( n = 0 ; err == noErr && catalogInfo.nodeID != fsRtDirID && n < 100 ; n++ )
err = FSGetCatalogInfo ( &localRef, kFSCatInfoNodeID, &catalogInfo, &names [ n ], NULL, &localRef );
@@ -99,17 +102,24 @@
return ( false );
for ( i = n - 1; i >= 0; --i ) {
- CFStringAppendCharacters ( ioPath, names [ i ].unicode, names [ i ].length );
-
- // if ( i > 0 )
+
+ sethandlesize ( handleText, names [ i ].length );
+
+ HFSUniStr255ToCString ( &names [ i ], *handleText );
- CFStringAppendCharacters ( ioPath, &inSepChar, 1 );
+ pushhandle ( handleText, handlePath );
+
+ pushcharhandle ( ':', handlePath );
+
}
- return ( CFStringGetPascalString ( ioPath, path, 256, kCFStringEncodingMacRoman ) );
-
+ disposehandle ( handleText );
+
+ return ( true );
+
} // directorytopath
+
#endif
@@ -185,9 +195,11 @@
} // filesetdefaultpath
-boolean filespectopath (const ptrfilespec fs, bigstring bspath) {
-
+boolean filespectopath ( const ptrfilespec fs, Handle *handlePath ) {
+
//
+ // 2007-02-23 creedon: support for long odb item names and file paths
+ //
// 2006-09-09 creedon: for Mac, FSRef-ized
//
// 2.1a7 dmb: if it's a null filespec, return the empty string
@@ -202,12 +214,12 @@
#ifdef MACVERSION
- bigstring bs;
- boolean flfolder;
FSCatalogInfo catalogInfo;
- tyfilespec fsp, fst = *fs;
HFSUniStr255 outName;
OSErr err;
+ boolean flfolder;
+ Handle hp;
+ tyfilespec fsp, fst = *fs;
( void ) extendfilespec ( &fst, &fst );
@@ -217,36 +229,49 @@
if ( err != noErr )
return ( false );
- setemptystring ( bspath );
+ if ( catalogInfo.parentDirID != fsRtParID ) { // it's not a volume so lets get the directory path
- if ( catalogInfo.parentDirID != fsRtParID ) // it's not a volume so lets get the directory path
- if ( ! directorytopath ( &fsp, bspath ) )
+ if ( ! directorytopath ( &fsp, *handlePath ) )
return ( false );
+ }
- HFSUniStr255ToStr255 ( &outName, bs );
+ newhandle ( outName.length + 1, &hp );
- pushstring ( bs, bspath );
+ HFSUniStr255ToCString ( &outName, *hp );
+ sethandlesize ( hp, outName.length );
+
+ pushhandle ( hp, *handlePath );
+
if ( fst.path != NULL ) {
+
+ CFIndex cfi = CFStringGetMaximumSizeForEncoding ( CFStringGetLength ( fst.path ),
+ kCFStringEncodingMacRoman );
- pushchar ( ':', bspath );
+ sethandlesize ( hp, cfi ); // resize hp
- CFStringRefToStr255 ( fst.path, bs );
+ pushcharhandle ( ':', *handlePath );
- pushstring ( bs, bspath );
-
+ CFStringGetBytes ( fst.path, CFRangeMake ( 0, cfi ), kCFStringEncodingMacRoman, '^', false, *hp, cfi, NULL );
+
+ pushhandle ( hp, *handlePath );
+
+ disposehandle ( hp );
+
return ( true );
}
if ( fileexists ( &fst, &flfolder ) )
if ( flfolder )
- assurelastchariscolon ( bspath );
+ textHandleAssureLastCharIsColon ( *handlePath );
+
+ disposehandle ( hp );
return ( true );
#endif
-
+
#ifdef WIN95VERSION
// 5.0d12 dmb: use GetFullPath to clean up 8.3 names
@@ -267,14 +292,16 @@
} // filespectopath
-boolean pathtofilespec ( bigstring bspath, ptrfilespec fs ) {
+boolean pathtofilespec ( Handle path, ptrfilespec fs ) {
//
+ // 2007-02-23 creedon: support for long odb item names and file paths
+ //
// 2006-10-16 creedon: for Mac, FSRef-ized
//
// 5.0d8 dmb: clear fs first thing
//
- // 2.1b2 dmb: use new fsdefault for building filespec. note that if bspath isn't a partial path, the vref and dirid will be
+ // 2.1b2 dmb: use new fsdefault for building filespec. note that if path isn't a partial path, the vref and dirid will be
// ignored.
//
// 2.1b2 dmb: added special case for empty string. also, added drive number interpretation here.
@@ -287,59 +314,80 @@
// non-existant files, we don't give up right away.
//
- bigstring bsfolder;
+ Handle handleFolder = NULL;
+ boolean flReturn = false;
clearbytes ( fs, sizeof ( *fs ) );
- if ( isemptystring ( bspath ) )
+ if ( isemptyhandle ( path ) )
return ( true );
#ifdef MACVERSION
FSRef fsr;
HFSUniStr255 name;
+ Handle colon = NULL, h = NULL, pT = NULL, fS = NULL;
OSErr err;
OSStatus status;
- bigstring bs, bspathtmp;
- short ix = 1, ixslashpos = 0, slashpos [ 255 ];
+ long ix = 0, slashpos [ 255 ];
+ unsigned char ixSlashPos = 0;
- copystring ( bspath, bspathtmp );
+ if ( ! newemptyhandle ( &pT ) )
+ return ( false );
+
+ if ( ! newtexthandle ( BIGSTRING ( "\x01" ":" ), &colon ) )
+ return ( false );
- cleanendoffilename ( bspathtmp );
+ if ( ! newtexthandle ( BIGSTRING ( "\x01" "/" ), &fS ) )
+ return ( false );
+
+ copyhandle ( path, &pT );
- if ( scanstring ( ':', bspath, &ix ) && ( ix > 1 ) ) { // full path, includes a colon, not the first character
+ handlepoptrailingchars ( pT, chpathseparator ); // clean up end of path
- bigstring bsfile, bsfullpath;
-
- copystring ( bspathtmp, bsfullpath );
-
- insertstring ( BIGSTRING ( "\x09" ":Volumes:" ), bsfullpath );
-
- copystring ( bsfullpath, bs );
-
+ if ( ( ix = searchhandle ( path, colon, ix, gethandlesize ( path ) ) ) && ( ix > 0 ) ) { // full path, includes a colon, not
+ // the first character
+
+ Handle handleFullPath;
+
+ copyhandle ( pT, &handleFullPath );
+
+ inserttextinhandle ( handleFullPath, 0, BIGSTRING ( "\x09" ":Volumes:" ) );
+
+ copyhandle ( handleFullPath, &h );
+
/* convert to / delimited path */ {
- while ( scanstring ( '/', bs, &ix ) )
- slashpos [ ixslashpos++ ] = ix++;
+ ix = 0;
- stringreplaceall ( ':', '/', bs );
+ while ( ( ix = searchhandle ( h, fS, ix, gethandlesize ( h ) ) ) != -1 )
+ slashpos [ ixSlashPos++ ] = ix++;
+
+ stringfindreplace ( BIGSTRING ( "\x01" ":" ), BIGSTRING ( "\x01" "/" ), h, true, false );
- while ( ixslashpos > 0 )
- setstringcharacter ( bs, slashpos [ --ixslashpos ] - 1, ':' );
+ while ( ixSlashPos > 0 )
+ setHandleCharacter ( h, slashpos [ --ixSlashPos ], ':' );
}
+
+ /* convert h from Mac Roman to UTF-8 */ {
- /* convert from Mac Roman to UTF-8 */ {
-
- CFStringRef csr = CFStringCreateWithPascalString ( kCFAllocatorDefault, bs,
- kCFStringEncodingMacRoman );
-
- CFStringGetCString ( csr, ( char * ) bs, sizeof ( bs ), kCFStringEncodingUTF8 );
+ CFStringRef cfsr = CFStringCreateWithBytes ( kCFAllocatorDefault, *h, ( CFIndex ) gethandlesize ( h ),
+ kCFStringEncodingMacRoman, false );
- CFRelease ( csr );
-
+ CFIndex cfi = CFStringGetMaximumSizeForEncoding ( CFStringGetLength ( cfsr ),
+ kCFStringEncodingUTF8 );
+
+ sethandlesize ( h, ++cfi ); // resize h plus one for c string terminator
+
+ CFStringGetCString ( cfsr, *h, cfi, kCFStringEncodingUTF8 );
+
+ CFRelease ( cfsr );
+
}
+
+ status = FSPathMakeRef ( *h, &fsr, NULL );
- status = FSPathMakeRef ( bs, &fsr, NULL );
+ disposehandle ( h );
if ( status == noErr ) {
@@ -349,114 +397,149 @@
( *fs ).path = CFStringCreateWithCharacters ( kCFAllocatorDefault, name.unicode, name.length );
- return ( true );
+ flReturn = true;
+ goto exit;
+
} // if
- filefrompath ( bsfullpath, bsfile );
+ if ( ! newemptyhandle ( &handleFolder ) )
+ return ( false );
+
+ copyhandle ( handleFullPath, &handleFolder );
- folderfrompath ( bsfullpath, bsfolder );
+ Handle handleFile;
- /* convert to / delimited path */ {
+ popFromPathTextHandle ( handleFolder, &handleFile, NULL );
- ix = 1;
- ixslashpos = 0;
+ if ( gethandlesize ( handleFile ) > 255 ) // leaf can't be more than 255 characters
+ goto exit;
+
+ /* convert handleFolder to / delimited path */ {
+
+ ix = 0;
+ ixSlashPos = 0;
- while ( scanstring ( '/', bsfolder, &ix ) )
- slashpos [ ixslashpos++ ] = ix++;
+ while ( ( ix = searchhandle ( handleFolder, fS, ix, gethandlesize ( handleFolder ) ) ) != -1 )
+ slashpos [ ixSlashPos++ ] = ix++;
- stringreplaceall ( ':', '/', bsfolder );
+ stringfindreplace ( BIGSTRING ( "\x01" ":" ), BIGSTRING ( "\x01" "/" ), handleFolder, true, false );
- while ( ixslashpos > 0 )
- setstringcharacter ( bsfolder, slashpos [ --ixslashpos ] - 1, ':' );
+ while ( ixSlashPos > 0 )
+ setHandleCharacter ( handleFolder, slashpos [ --ixSlashPos ] - 1, ':' );
}
+
+ /* convert h from Mac Roman to UTF-8 */ {
- /* convert from Mac Roman to UTF-8 */ {
-
- CFStringRef csr = CFStringCreateWithPascalString ( kCFAllocatorDefault, bsfolder,
- kCFStringEncodingMacRoman );
-
- CFStringGetCString ( csr, ( char * ) bsfolder, sizeof ( bsfolder ), kCFStringEncodingUTF8 );
+ CFStringRef cfsr = CFStringCreateWithBytes ( kCFAllocatorDefault, *handleFolder,
+ ( CFIndex ) gethandlesize ( handleFolder ), kCFStringEncodingMacRoman, false );
- CFRelease ( csr );
-
+ CFIndex cfi = CFStringGetMaximumSizeForEncoding ( CFStringGetLength ( cfsr ),
+ kCFStringEncodingUTF8 );
+
+ sethandlesize ( handleFolder, ++cfi ); // resize handleFolder plus one for c string terminator
+
+ CFStringGetCString ( cfsr, *handleFolder, cfi, kCFStringEncodingUTF8 );
+
+ CFRelease ( cfsr );
+
}
-
- status = FSPathMakeRef ( bsfolder, &fsr, NULL );
+
+ status = FSPathMakeRef ( *handleFolder, &fsr, NULL );
if ( status == noErr ) {
( *fs ).fsref = fsr;
- ( *fs ).path = CFStringCreateWithPascalString ( kCFAllocatorDefault, bsfile,
- kCFStringEncodingMacRoman );
-
- return ( true );
+ ( *fs ).path = CFStringCreateWithBytes ( kCFAllocatorDefault, *handleFile,
+ ( CFIndex ) gethandlesize ( handleFile ), kCFStringEncodingMacRoman, false );
+
+ disposehandle ( handleFile );
+ handleFile = NULL;
+
+ disposehandle ( handleFolder );
+
+ handleFolder = NULL;
+
+ flReturn = true;
+
+ goto exit;
+
} // if
} // end full path
else { // partial path
- bigstring bspartialpath;
+ Handle partialPath;
tyfilespec fst;
- copystring ( bspathtmp, bspartialpath );
+ if ( ! newhandle ( MAXPATHLEN, &h ) )
+ return ( false );
+
+ copyhandle ( pT, &partialPath );
- if ( bspartialpath [ 1 ] != chpathseparator )
- insertchar ( chpathseparator, bspartialpath );
+ if ( *partialPath [ 0 ] != chpathseparator )
+ insertCharInTextHandle ( chpathseparator, 0, partialPath );
( void ) extendfilespec ( &fsdefault, &fst );
- status = FSRefMakePath ( &fst.fsref, ( UInt8 * ) bs, 256 ); // bs is now a c string
+ status = FSRefMakePath ( &fst.fsref, ( UInt8 * ) *h, MAXPATHLEN );
- convertcstring ( bs ); // bs is now a bigstring
+ sethandlesize ( h, strlen ( *h ) );
- /* convert bs to colon delimited path */ {
+ /* convert h to : delimited path */ {
- ix = 1;
- ixslashpos = 0;
+ ix = 0;
+ ixSlashPos = 0;
- while ( scanstring ( ':', bs, &ix ) )
- slashpos [ ixslashpos++ ] = ix++;
+ while ( ( ix = searchhandle ( h, colon, ix, gethandlesize ( h ) ) ) != -1 )
+ slashpos [ ixSlashPos++ ] = ix++;
+
+ stringfindreplace ( BIGSTRING ( "\x01" "/" ), BIGSTRING ( "\x01" ":" ), h, true, false );
- stringreplaceall ( '/', ':', bs );
+ while ( ixSlashPos > 0 )
+ setHandleCharacter ( h, slashpos [ --ixSlashPos ] - 1, '/' );
+ }
- while ( ixslashpos > 0 )
- setstringcharacter ( bs, slashpos [ --ixslashpos ] - 1, '/' );
- }
+ insertinhandle ( partialPath, 0, *h, gethandlesize ( h ) ); // we now have a full path
- insertstring ( bs, bspartialpath ); // we now have a full path
+ copyhandle ( partialPath, &h );
- copystring ( bspartialpath, bs );
+ /* convert h to / delimited path */ {
- /* convert bs to / delimited path */ {
-
- ix = 1;
- ixslashpos = 0;
+ ix = 0;
+ ixSlashPos = 0;
- while ( scanstring ( '/', bs, &ix ) )
- slashpos [ ixslashpos++ ] = ix++;
+ while ( ( ix = searchhandle ( h, fS, ix, gethandlesize ( h ) ) ) != -1 )
+ slashpos [ ixSlashPos++ ] = ix++;
+
+ stringfindreplace ( BIGSTRING ( "\x01" ":" ), BIGSTRING ( "\x01" "/" ), h, true, false );
- stringreplaceall ( ':', '/', bs );
+ while ( ixSlashPos > 0 )
+ setHandleCharacter ( h, slashpos [ --ixSlashPos ] - 1, ':' );
+ }
- while ( ixslashpos > 0 )
- setstringcharacter ( bs, slashpos [ --ixslashpos ] - 1, ':' );
- }
+ /* convert h from Mac Roman to UTF-8 */ {
- /* convert from Mac Roman to UTF-8 */ {
-
- CFStringRef csr = CFStringCreateWithPascalString ( kCFAllocatorDefault, bsfolder,
- kCFStringEncodingMacRoman );
-
- CFStringGetCString ( csr, ( char * ) bsfolder, sizeof ( bsfolder ), kCFStringEncodingUTF8 );
+ CFStringRef cfsr = CFStringCreateWithBytes ( kCFAllocatorDefault, *h, ( CFIndex ) gethandlesize ( h ),
+ kCFStringEncodingMacRoman, false );
+
+ CFIndex cfi = CFStringGetMaximumSizeForEncoding ( CFStringGetLength ( cfsr ),
+ kCFStringEncodingUTF8 );
+
+ sethandlesize ( h, ++cfi ); // resize h plus one for c string terminator
- CFRelease ( csr );
-
+ CFStringGetCString ( cfsr, *h, cfi, kCFStringEncodingUTF8 );
+
+ CFRelease ( cfsr );
+
}
+
+ status = FSPathMakeRef ( *h, &fsr, NULL );
- status = FSPathMakeRef ( bs, &fsr, NULL );
+ disposehandle ( h );
if ( status == noErr ) {
@@ -465,76 +548,111 @@
( *fs ).fsref = fsr;
( *fs ).path = CFStringCreateWithCharacters ( kCFAllocatorDefault, name.unicode, name.length );
-
- return ( true );
+ flReturn = true;
+
+ goto exit;
+
} // if
/* try parent of path */ {
- bigstring bsfile;
-
- filefrompath ( bspartialpath, bsfile );
+ Handle handleFile;
- folderfrompath ( bspartialpath, bsfolder );
+ copyhandle ( partialPath, &handleFolder );
- /* convert to slash delimited path */ {
-
- ix = 1;
- ixslashpos = 0;
+ popFromPathTextHandle ( handleFolder, &handleFile, NULL );
+
+ if ( gethandlesize ( handleFile ) > 255 ) // leaf can't be more than 255 characters
+ goto exit;
- while ( scanstring ( '/', bsfolder, &ix ) )
- slashpos [ ixslashpos++ ] = ix++;
+ /* convert handleFolder to / delimited path */ {
+
+ ix = 0;
+ ixSlashPos = 0;
- stringreplaceall ( ':', '/', bsfolder );
+ while ( ( ix = searchhandle ( handleFolder, fS, ix, gethandlesize ( handleFolder ) ) ) != -1 )
+ slashpos [ ixSlashPos++ ] = ix++;
+
+ stringfindreplace ( BIGSTRING ( "\x01" ":" ), BIGSTRING ( "\x01" "/" ), handleFolder, true, false );
- while ( ixslashpos > 0 )
- setstringcharacter ( bsfolder, slashpos [ --ixslashpos ] - 1, ':' );
+ while ( ixSlashPos > 0 )
+ setHandleCharacter ( handleFolder, slashpos [ --ixSlashPos ] - 1, ':' );
}
+
+ /* convert handleFolder from Mac Roman to UTF-8 */ {
- /* convert from Mac Roman to UTF-8 */ {
-
- CFStringRef csr = CFStringCreateWithPascalString ( kCFAllocatorDefault, bsfolder,
- kCFStringEncodingMacRoman );
-
- CFStringGetCString ( csr, ( char * ) bsfolder, sizeof ( bsfolder ), kCFStringEncodingUTF8 );
+ CFStringRef cfsr = CFStringCreateWithBytes ( kCFAllocatorDefault, *handleFolder,
+ ( CFIndex ) gethandlesize ( handleFolder ), kCFStringEncodingMacRoman, false );
- CFRelease ( csr );
-
+ CFIndex cfi = CFStringGetMaximumSizeForEncoding ( CFStringGetLength ( cfsr ),
+ kCFStringEncodingUTF8 );
+
+ sethandlesize ( handleFolder, ++cfi ); // resize handleFolder plus one for c string terminator
+
+ CFStringGetCString ( cfsr, *handleFolder, cfi, kCFStringEncodingUTF8 );
+
+ CFRelease ( cfsr );
+
}
+
+ status = FSPathMakeRef ( *handleFolder, &fsr, NULL );
- status = FSPathMakeRef ( bsfolder, &fsr, NULL );
-
if ( status == noErr ) {
( *fs ).fsref = fsr;
- ( *fs ).path = CFStringCreateWithPascalString ( kCFAllocatorDefault, bsfile,
- kCFStringEncodingMacRoman );
-
- return ( true );
+ ( *fs ).path = CFStringCreateWithBytes ( kCFAllocatorDefault, *handleFile,
+ ( CFIndex ) gethandlesize ( handleFile ), kCFStringEncodingMacRoman, false );
+ disposehandle ( handleFile );
+
+ handleFile = NULL;
+
+ disposehandle ( handleFolder );
+
+ handleFolder = NULL;
+
+ flReturn = true;
+
+ goto exit;
+
} // if
} // end try parent of path
} // end partial path
+
+ exit:
- return ( false );
-
+ if ( colon != NULL )
+ disposehandle ( colon );
+
+ if ( fS != NULL )
+ disposehandle ( fS );
+
+ if ( handleFolder != NULL )
+ disposehandle ( handleFolder );
+
+ if ( pT != NULL )
+ disposehandle ( pT );
+
+ return ( flReturn );
+
#endif
#ifdef WIN95VERSION
- copystring (bspath, fsname (fs));
+ copystring (path, fsname (fs));
- folderfrompath (bspath, bsfolder);
+ folderFromPath (path, handleFolder);
- if ((isemptystring (bsfolder)) && (! fileisvolume(fs))) {
+ if ((isemptystring (handleFolder)) && (! fileisvolume(fs))) {
filegetdefaultpath (fs);
- pushstring (bspath, fsname (fs));
+ pushstring (path, fsname (fs));
+
}
nullterminate (fsname (fs));
@@ -542,7 +660,7 @@
return (true);
#endif
-
+
} // pathtofilespec
@@ -590,7 +708,7 @@
} // setfsfile
-boolean getfsfile (const ptrfilespec fs, bigstring bsfile) {
+boolean getfsfile ( const ptrfilespec fs, bigstring bsfile ) {
//
// 2006-06-18 creedon: for Mac, FSRef-ized
@@ -603,10 +721,9 @@
if ( CFStringRefToStr255 ( ( *fs ).path, bsfile ) )
return ( true );
}
- else {
+ else
FSRefGetNameStr255 ( &( *fs ).fsref, bsfile );
- }
-
+
if (stringlength ( bsfile ) > 0)
return (true);
@@ -625,6 +742,7 @@
return (true);
#endif
+
} // getfsfile
Modified: Frontier/branches/Frontier_Long_File_Paths/Common/source/fileverbs.c
===================================================================
--- Frontier/branches/Frontier_Long_File_Paths/Common/source/fileverbs.c 2007-02-23 18:20:57 UTC (rev 1619)
+++ Frontier/branches/Frontier_Long_File_Paths/Common/source/fileverbs.c 2007-02-23 19:27:43 UTC (rev 1620)
@@ -709,7 +709,7 @@
static boolean filedialogverb (tysfverb sfverb, hdltreenode hparam1, tyvaluerecord *vreturned) {
-
+
//
// put up one of the "standard file" dialogs. if sfverb is sfputfileverb we use the "put" dialog, otherwise the "get" dialog.
//
@@ -717,6 +717,8 @@
//
// if it's the getfile dialog, we take a second parameter -- it indicates the type of the file.
//
+ // 2007-02-23 creedon: support for long odb item names and file paths
+ //
// 2006-08-16 creedon: FSRef-ized
//
// 2005-10-06 creedon: added creator parameter
@@ -725,17 +727,16 @@
// potentially set default directory.
//
- bigstring bsprompt;
- bigstring bsvarname;
+ Handle handleVariableName;
+ OSType oscreator = kNavGenericSignature, ostype;
+ bigstring bsext, bsprompt;
+ boolean fl;
+ hdlhashnode hnode;
+ hdlhashtable htable;
+ ptrsftypelist typelist = nil;
tyfilespec fs;
+ tysftypelist filetypes;
tyvaluerecord val;
- tysftypelist filetypes;
- ptrsftypelist typelist = nil;
- hdlhashtable htable;
- boolean fl;
- OSType ostype, oscreator = kNavGenericSignature;
- bigstring bsext;
- hdlhashnode hnode;
if (!getstringvalue (hparam1, 1, bsprompt))
return (false);
@@ -743,13 +744,12 @@
if (sfverb != sfgetfileverb)
flnextparamislast = true;
- if (!getvarparam (hparam1, 2, &htable, bsvarname)) // returned filename holder
- return (false);
+ if ( ! getvarparam ( hparam1, 2, &htable, &handleVariableName ) ) // returned filename holder
+ return ( false );
if (sfverb == sfgetfileverb) { // get extra parameters for get file dialog, indicating file type(s) and file creator
- short ctconsumed = 3;
- short ctpositional = 3;
+ short ctconsumed = 3, ctpositional = 3;
tyvaluerecord lval;
if (!gettypelistvalue (hparam1, 3, &filetypes, &typelist))
@@ -768,15 +768,15 @@
clearbytes (&fs, sizeof (fs));
- //
- // if (idstringvalue (htable, bsvarname, bsfname))
- // filecheckdefaultpath (bsfname);
- //
-
- if (hashtablelookup (htable, bsvarname, &val, &hnode)) {
+ if ( hashtablelookup ( htable, handleVariableName, &val, &hnode ) ) {
- if (!copyvaluerecord (val, &val))
+ if (!copyvaluerecord (val, &val)) {
+
+ disposehandle ( handleVariableName );
+
return (false);
+
+ }
disablelangerror ();
@@ -784,8 +784,9 @@
fs = **val.data.filespecvalue;
enablelangerror ();
+
}
-
+
if (sfverb == sfputfileverb) {
bigstring bs;
@@ -795,30 +796,34 @@
lastword ( bs, '.', bsext);
if ( ! ( ( stringlength ( bs ) == stringlength ( bsext ) ) || ( stringlength ( bsext ) > 4 ) ) ) { // extension
+
stringtoostype (bsext, &ostype);
filetypes.cttypes = 1;
filetypes.types [0] = ostype;
typelist = &filetypes;
+
}
}
-
+
setbooleanvalue (false, vreturned);
if (!sfdialog (sfverb, bsprompt, typelist, &fs, oscreator)) // user hit cancel
return (true);
-
+
if (!setfilespecvalue (&fs, &val))
return (false);
-
+
pushhashtable (htable);
- fl = langsetsymbolval (bsvarname, val);
+ fl = langsetsymbolval ( handleVariableName, val );
+ disposehandle ( handleVariableName );
+
pophashtable ();
if (!fl)
return (false);
-
+
exemptfromtmpstack (&val);
(*vreturned).data.flvalue = true; // the user did select a file
@@ -859,18 +864,19 @@
static boolean getresourceverb (hdltreenode hparam1, boolean flnamed, tyvaluerecord *v) {
- /*
- 2005-09-02 creedon: added support for fork parameter, see resources.c: openresourcefile and pushresourcefile
- */
+ //
+ // 2007-02-23 creedon: support for long odb item names and file paths
+ //
+ // 2005-09-02 creedon: added support for fork parameter, see resources.c: openresourcefile and pushresourcefile
+ //
- tyfilespec fs;
+ Handle h, handleVariableName;
OSType type;
- short id, forktype;
- short ctconsumed = 4;
- short ctpositional = 4;
- Handle h;
+ bigstring bs;
+ boolean fl = false;
hdlhashtable htable;
- bigstring bs, bsvarname;
+ short ctconsumed = 4, ctpositional = 4, forktype, id;
+ tyfilespec fs;
tyvaluerecord val;
if (!getpathvalue (hparam1, 1, &fs))
@@ -882,7 +888,7 @@
if (!getstringorintvalue (hparam1, 3, flnamed, &id, bs))
return (false);
- if (!getvarparam (hparam1, 4, &htable, bsvarname)) /*returned handle holder*/
+ if ( ! getvarparam ( hparam1, 4, &htable, &handleVariableName ) ) // returned handle holder
return (false);
flnextparamislast = true;
@@ -890,7 +896,7 @@
setintvalue (resourcefork, &val); /* defaults to 1 */
if (!getoptionalparamvalue (hparam1, &ctconsumed, &ctpositional, BIGSTRING ("\x04""fork"), &val))
- return (false);
+ goto exit;
forktype = val.data.intvalue;
@@ -898,22 +904,27 @@
(*v).data.flvalue = false;
- return (true);
- }
-
- if (!insertinhandle (h, 0L, &type, sizeof (type))) { /*out of memory*/
+ fl = true;
- disposehandle (h);
+ goto exit;
- return (false);
}
- if (!langsetbinaryval (htable, bsvarname, h))
- return (false);
+ if (!insertinhandle (h, 0L, &type, sizeof (type))) /*out of memory*/
+ goto exit;
- (*v).data.flvalue = true;
+ if ( ! langsetbinaryval ( htable, handleVariableName, h ) )
+ goto exit;
- return (true);
+ fl = ( *v ).data.flvalue = true;
+
+ exit:
+
+ disposehandle ( h );
+ disposehandle ( handleVariableName );
+
+ return ( fl );
+
} /*getresourceverb*/
@@ -1001,19 +1012,19 @@
static boolean getnthrestypeverb (hdltreenode hparam1, tyvaluerecord *v) {
- /*
- 2005-09-02 creedon: added support for fork parameter, see resources.c: openresourcefile and pushresourcefile
- */
+ //
+ // 2007-02-23 creedon: support for long odb item names and file paths
+ //
+ // 2005-09-02 creedon: added support for fork parameter, see resources.c: openresourcefile and pushresourcefile
+ //
- tyfilespec fs;
- short n, forktype;
- short ctconsumed = 3;
- short ctpositional = 3;
+ Handle handleVariableName;
OSType type;
+ boolean fl;
hdlhashtable htable;
- bigstring bsvarname;
+ short ctconsumed = 3, ctpositional = 3, forktype, n;
+ tyfilespec fs;
tyvaluerecord val;
- boolean fl;
if (!getpathvalue (hparam1, 1, &fs))
return (false);
@@ -1021,7 +1032,7 @@
if (!getintvalue (hparam1, 2, &n))
return (false);
- if (!getvarparam (hparam1, 3, &htable, bsvarname)) /*returned handle holder*/
+ if ( ! getvarparam ( hparam1, 3, &htable, &handleVariableName ) ) /*returned handle holder*/
return (false);
flnextparamislast = true;
@@ -1042,11 +1053,12 @@
setostypevalue (type, &val);
- fl = langsetsymboltableval (htable, bsvarname, val);
+ fl = langsetsymboltableval (htable, handleVariableName, val);
(*v).data.flvalue = fl;
return (fl);
+
} /*getnthrestypeverb*/
@@ -1089,19 +1101,19 @@
static boolean getnthresourceverb (hdltreenode hparam1, tyvaluerecord *v) {
- /*
- 2005-09-02 creedon: added support for fork parameter, see resources.c: openresourcefile and pushresourcefile
- */
+ //
+ // 2007-02-23 creedon: support for long odb item names and file paths
+ //
+ // 2005-09-02 creedon: added support for fork parameter, see resources.c: openresourcefile and pushresourcefile
+ //
- tyfilespec fs;
+ Handle h, h2, h3, h4;
OSType type;
- short n, id, forktype;
- short ctconsumed = 5;
- short ctpositional = 5;
- Handle h;
+ bigstring bs;
+ boolean fl = false;
hdlhashtable ht1, ht2;
- bigstring bs, bs1, bs2;
- boolean fl;
+ short ctconsumed = 5, ctpositional = 5, forktype, id, n;
+ tyfilespec fs;
tyvaluerecord val;
if (!getpathvalue (hparam1, 1, &fs))
@@ -1113,76 +1125,92 @@
if (!getintvalue (hparam1, 3, &n))
return (false);
- if (!getvarparam (hparam1, 4, &ht1, bs1)) /*returned name holder*/
+ if ( ! getvarparam ( hparam1, 4, &ht1, &h2 ) ) // returned name holder
return (false);
- if (!getvarparam (hparam1, 5, &ht2, bs2)) /*returned handle holder*/
- return (false);
+ if ( ! getvarparam ( hparam1, 5, &ht2, &h3 ) ) // returned handle holder
+ goto exit;
flnextparamislast = true;
setintvalue (resourcefork, &val); /* defaults to 1 */
if (!getoptionalparamvalue (hparam1, &ctconsumed, &ctpositional, BIGSTRING ("\x04""fork"), &val))
- return (false);
+ goto exit;
forktype = val.data.intvalue;
- if (!getnthresourcehandle (&fs, type, n, &id, bs, &h, forktype)) {
+ if ( ! getnthresourcehandle (&fs, type, n, &id, bs, &h, forktype ) ) {
(*v).data.flvalue = false;
- return (true);
+ fl = true;
+
+ goto exit;
+
}
-
+
+ if ( ! newtexthandle ( bs, &h4 ) )
+ goto exit;
+
pushhashtable (ht1);
- fl = langsetstringval (bs1, bs);
+ fl = langsetstringval ( h2, h4 );
+ disposehandle ( h4 );
+
pophashtable ();
- if (!fl)
- return (false);
+ if ( ! fl ) {
- if (!insertinhandle (h, 0L, &type, sizeof (type))) {
+ fl = false;
- disposehandle (h);
+ goto exit;
- return (false);
}
- if (!langsetbinaryval (ht2, bs2, h))
- return (false);
+ fl = false;
- (*v).data.flvalue = true;
+ if (!insertinhandle (h, 0L, &type, sizeof (type)))
+ goto exit;
+
+ if ( ! langsetbinaryval ( ht2, h3, h ) )
+ goto exit;
- return (true);
+ fl = ( *v ).data.flvalue = true;
+
+ exit:
+ disposehandle ( h );
+ disposehandle ( h2 );
+ disposehandle ( h3 );
+ disposehandle ( h4 );
+
+ return ( fl );
+
} /*getnthresourceverb*/
static boolean getnthresinfoverb (hdltreenode hparam1, tyvaluerecord *v) {
+
+ //
+ // 2007-02-23 creedon: support for long odb item names and file paths
+ //
+ // 2005-12-26 creedon: commented out param count check
+ //
+ // 2005-09-02 creedon: added support for fork parameter, see resources.c: openresourcefile and pushresourcefile
+ //
+ // 1992-06-02 dmb: created.
+ //
- /*
- 2005-12-26 creedon: commented out param count check
-
- 2005-09-02 creedon: added support for fork parameter, see resources.c: openresourcefile and pushresourcefile
-
- 6/2/92 dmb: created.
- */
-
- tyfilespec fs;
+ Handle h, h2;
OSType type;
- short n, id, forktype;
- short ctconsumed = 5;
- short ctpositional = 5;
+ bigstring bs;
+ boolean fl;
hdlhashtable ht1;
- bigstring bs, bs1;
- boolean fl;
+ short ctconsumed = 5, ctpositional = 5, id, forktype, n;
+ tyfilespec fs;
tyvaluerecord val;
- /* if (!langcheckparamcount (hparam1, 5))
- return (false); */
-
if (!getpathvalue (hparam1, 1, &fs))
return (false);
@@ -1209,21 +1237,27 @@
if (!langsetlongvarparam (hparam1, 4, id))
return (false);
- if (!getvarparam (hparam1, 5, &ht1, bs1)) /*returned name holder*/
+ if ( ! getvarparam ( hparam1, 5, &ht1, &h ) ) /*returned name holder*/
return (false);
pushhashtable (ht1);
- fl = langsetstringval (bs1, bs);
+ if ( ! newtexthandle ( bs, &h2 ) )
+ return ( false );
+
+ fl = langsetstringval ( h, h2 );
pophashtable ();
+ disposehandle ( h );
+
if (!fl)
return (false);
(*v).data.flvalue = true;
return (true);
+
} /*getnthresinfoverb*/
@@ -2999,6 +3033,8 @@
// if we return false, we try to provide a descriptive error message in the
// returned string bserror.
//
+ // 2007-02-23 creedon: support for long odb item names and file paths
+ //
// 2006-10-23 creedon: for Mac, extend filespec for fs2 in case filemovefunc
//
// 2006-06-25 creedon: FSRef-ized
@@ -3905,7 +3941,7 @@
if (countwords (bsvol, chpathseparator) != 3) {
- langparamerror (badnetworkvolumespecificationerror, bsvol);
+ langParamErrBs ( badnetworkvolumespecificationerror, bsvol);
return (false);
}
@@ -3996,16 +4032,8 @@
if (!langcheckparamcount (hp1, 0)) /*no parameters expected*/
break;
-
- #ifdef flsystem6
-
- filegetpath (filegetsystemvnum (), bs);
- return (setstringvalue (bs, v));
-
- #else
-
- setemptystring (bsvol);
+ setemptystring (bsvol);
clearbytes ( &fs, sizeof ( fs ) );
@@ -4025,12 +4053,11 @@
break;
return (setfilespecvalue (&fs, v));
-
- #endif
-
+
}
case getspecialpathfunc: {
+
bigstring bsvol, bsfolder;
tyfilespec fs;
boolean flcreate;
Modified: Frontier/branches/Frontier_Long_File_Paths/Common/source/findinfile.c
===================================================================
--- Frontier/branches/Frontier_Long_File_Paths/Common/source/findinfile.c 2007-02-23 18:20:57 UTC (rev 1619)
+++ Frontier/branches/Frontier_Long_File_Paths/Common/source/findinfile.c 2007-02-23 19:27:43 UTC (rev 1620)
@@ -137,16 +137,24 @@
static void fifopenfileerror (const ptrfilespec fs) {
+
+ //
+ // 2007-02-23 creedon: support for long odb item names and file paths
+ //
+ // 5.0.1 dmb: new, additional error reporting
+ //
- /*
- 5.0.1 dmb: new, additional error reporting
- */
+ Handle h;
+ bigstring bsfile;
- bigstring bsfile;
-
getfsfile (fs, bsfile);
-
- lang2paramerror (filenotopenederror, bsfunctionname, bsfile);
+
+ newtexthandle ( bsfile, &h );
+
+ lang2paramerror ( filenotopenederror, handleFunctionName, h );
+
+ disposehandle ( h );
+
} /*fifopenfileerror*/
Modified: Frontier/branches/Frontier_Long_File_Paths/Common/source/font.c
===================================================================
--- Frontier/branches/Frontier_Long_File_Paths/Common/source/font.c 2007-02-23 18:20:57 UTC (rev 1619)
+++ Frontier/branches/Frontier_Long_File_Paths/Common/source/font.c 2007-02-23 19:27:43 UTC (rev 1620)
@@ -181,14 +181,15 @@
#endif
+
static boolean mapxfont (ptrstring bsfont) {
/*
2002-10-13 AR: Slight change to eliminate compiler warning about possible unwanted assignment
*/
- register pg_char_ptr table_ptr;
- short alternate_index, out_index;
+ register pg_char_ptr table_ptr;
+ short alternate_index, out_index;
if ((table_ptr = cross_font_table) == (pg_char_ptr)NULL)
return (false);
@@ -222,18 +223,21 @@
}
return (true);
+
} /*mapxfont*/
void fontgetnumber (bigstring fontname, short *fontnumber) {
+
+ //
+ // 2007-02-23 creedon: for Mac, use updated font calls
+ //
+ // 5.0.2b19 dmb: added cachedfont logic
+ //
+ // 5.0a13 dmb: operate on a copy; mapping modifies string (64 bytes!)
+ // map on Mac platform too
+ //
- /*
- 5.0a13 dmb: operate on a copy; mapping modifies string (64 bytes!)
- 5.0a13 dmb: map on Mac platform too
-
- 5.0.2b19 dmb: added cachedfont logic
- */
-
bigstring bsfont;
copystring (fontname, bsfont);
@@ -245,27 +249,32 @@
copystring (bsfont, cachedfontname);
-#ifdef MACVERSION
- GetFNum (bsfont, &cachedfontnum);
+ #ifdef MACVERSION
+
+ cachedfontnum = FMGetFontFamilyFromName ( bsfont ); // GetFNum (bsfont, &cachedfontnum);
+
+ if ( ( cachedfontnum == 0 ) && ! equalstrings ( bsfont, BIGSTRING ( "\x07" "Chicago" ) ) )
+ if ( mapxfont ( bsfont ) )
+ cachedfontnum = FMGetFontFamilyFromName ( bsfont ); // GetFNum (bsfont, &cachedfontnum);
+ #endif
+
+ #ifdef WIN95VERSION
+
+ if (findWindowsFont (bsfont, &cachedfontnum))
+ goto exit;
- if ((cachedfontnum == 0) && !equalstrings (bsfont, BIGSTRING ("\x07" "Chicago")))
if (mapxfont (bsfont))
- GetFNum (bsfont, &cachedfontnum);
-#endif
-#ifdef WIN95VERSION
- if (findWindowsFont (bsfont, &cachedfontnum))
- goto exit;
+ if (findWindowsFont (bsfont, &cachedfontnum))
+ goto exit;
- if (mapxfont (bsfont))
- if (findWindowsFont (bsfont, &cachedfontnum))
- goto exit;
-
- cachedfontnum = 0;
-#endif
-
+ cachedfontnum = 0;
+
+ #endif
+
exit:
- *fontnumber = cachedfontnum;
+ *fontnumber = cachedfontnum;
+
} /*fontgetnumber*/
@@ -285,83 +294,96 @@
void setfontsizestyle (short fontnum, short fontsize, short fontstyle) {
-#ifdef MACVERSION
- TextFont (fontnum);
+
+ #ifdef MACVERSION
- TextSize (fontsize);
+ TextFont (fontnum);
+
+ TextSize (fontsize);
+
+ TextFace (fontstyle);
+
+ #endif
- TextFace (fontstyle);
-#endif
-#ifdef WIN95VERSION
- if (fontnum > 0)
- currentFontNum = fontnum;
+ #ifdef WIN95VERSION
+
+ if (fontnum > 0)
+ currentFontNum = fontnum;
- if (fontsize != 0)
- currentFontSize = fontsize;
+ if (fontsize != 0)
+ currentFontSize = fontsize;
- currentFontStyle = fontstyle;
-#endif
+ currentFontStyle = fontstyle;
+
+ #endif
+
} /*setfontsizestyle*/
void setglobalfontsizestyle (short fontnum, short fontsize, short fontstyle) {
-#ifdef MACVERSION
- setfontsizestyle (fontnum, fontsize, fontstyle);
+
+ #ifdef MACVERSION
- GetFontInfo (&globalfontinfo);
-#endif
+ setfontsizestyle ( fontnum, fontsize, fontstyle );
+
+ GetFontInfo ( &globalfontinfo );
+
+ #endif
-#ifdef WIN95VERSION
- HFONT fnt, oldfnt;
- TEXTMETRIC tm;
- tywindowsfontinformation * wfi;
- short ctr;
- HDC hdc;
- long logpix;
+ #ifdef WIN95VERSION
+
+ HFONT fnt, oldfnt;
+ TEXTMETRIC tm;
+ tywindowsfontinformation * wfi;
+ short ctr;
+ HDC hdc;
+ long logpix;
- hdc = GetDC (GetDesktopWindow());
+ hdc = GetDC (GetDesktopWindow());
- if (fontnum > 0)
- currentFontNum = fontnum;
+ if (fontnum > 0)
+ currentFontNum = fontnum;
- if (fontsize != 0)
- currentFontSize = fontsize;
+ if (fontsize != 0)
+ currentFontSize = fontsize;
- currentFontStyle = fontstyle;
+ currentFontStyle = fontstyle;
- ctr = currentFontNum;
+ ctr = currentFontNum;
-// ctr = ctr + 1;
- wfi = *globalWindowsFontInfo + ctr;
+ // ctr = ctr + 1;
+ wfi = *globalWindowsFontInfo + ctr;
- wfi->lfi.lfHeight = -MulDiv(currentFontSize, GetDeviceCaps(getcurrentDC(), LOGPIXELSY), 72);
-
- wfi->lfi.lfWidth = 0;
-
- wfi->lfi.lfWeight = (currentFontStyle & bold)? FW_BOLD : FW_NORMAL;
-
- wfi->lfi.lfItalic = (currentFontStyle & italic)? true : false;
-
- wfi->lfi.lfUnderline = (currentFontStyle & underline)? true : false;
+ wfi->lfi.lfHeight = -MulDiv(currentFontSize, GetDeviceCaps(getcurrentDC(), LOGPIXELSY), 72);
+
+ wfi->lfi.lfWidth = 0;
+
+ wfi->lfi.lfWeight = (currentFontStyle & bold)? FW_BOLD : FW_NORMAL;
+
+ wfi->lfi.lfItalic = (currentFontStyle & italic)? true : false;
+
+ wfi->lfi.lfUnderline = (currentFontStyle & underline)? true : false;
- fnt = CreateFontIndirect (&(wfi->lfi));
+ fnt = CreateFontIndirect (&(wfi->lfi));
- oldfnt = SelectObject (hdc, fnt);
+ oldfnt = SelectObject (hdc, fnt);
- GetTextMetrics (hdc, &tm);
+ GetTextMetrics (hdc, &tm);
- logpix = GetDeviceCaps(getcurrentDC(), LOGPIXELSY);
+ logpix = GetDeviceCaps(getcurrentDC(), LOGPIXELSY);
- globalfontinfo.ascent = (short) tm.tmAscent;
- globalfontinfo.descent = (short) tm.tmDescent;
- globalfontinfo.leading = (short) tm.tmExternalLeading;
-// globalfontinfo.leading = (short)tm.tmInternalLeading;
+ globalfontinfo.ascent = (short) tm.tmAscent;
+ globalfontinfo.descent = (short) tm.tmDescent;
+ globalfontinfo.leading = (short) tm.tmExternalLeading;
+ // globalfontinfo.leading = (short)tm.tmInternalLeading;
- SelectObject (hdc, oldfnt);
- DeleteObject (fnt);
+ SelectObject (hdc, oldfnt);
+ DeleteObject (fnt);
- ReleaseDC (GetDesktopWindow(), hdc);
-#endif
+ ReleaseDC (GetDesktopWindow(), hdc);
+
+ #endif
+
} /*setglobalfontsizestyle*/
Modified: Frontier/branches/Frontier_Long_File_Paths/Common/source/frontierwindows.c
===================================================================
--- Frontier/branches/Frontier_Long_File_Paths/Common/source/frontierwindows.c 2007-02-23 18:20:57 UTC (rev 1619)
+++ Frontier/branches/Frontier_Long_File_Paths/Common/source/frontierwindows.c 2007-02-23 19:27:43 UTC (rev 1620)
@@ -218,16 +218,22 @@
grabthreadglobals ();
#endif
+
} /*disposewindow*/
void windowgettitle (WindowPtr w, bigstring bs) {
#ifdef MACVERSION
+
+ // OSStatus CopyWindowTitleAsCFString ( WindowRef inWindow, CFStringRef * outString );
+
GetWTitle (w, bs);
+
#endif
-
+
#ifdef WIN95VERSION
+
releasethreadglobals ();
GetWindowText(w, bs, lenbigstring);
@@ -235,59 +241,59 @@
grabthreadglobals ();
convertcstring (bs);
+
#endif
+
} /*windowgettitle*/
-
+
#if !flruntime
-void windowsettitle (WindowPtr w, bigstring bs) {
+void windowsettitle ( WindowPtr w, const Handle h ) {
+
+ //
+ // 2007-02-23 creedon: for Mac, support for long odb item names and file
+ // paths
+ //
#ifdef MACVERSION
- bigstring bsorig;
+
+ CFStringRef csr = CFStringCreateWithBytes ( kCFAllocatorDefault, *h,
+ gethandlesize ( h ), kCFStringEncodingMacRoman, false );
+
+ SetWindowTitleWithCFString ( w, csr );
- GetWTitle (w, bsorig);
+ CFRelease ( csr );
- if (!equalstrings (bs, bsorig)) /*save a little flickering*/
- SetWTitle (w, bs);
#endif
-
+
#ifdef WIN95VERSION
- #ifdef PASCALSTRINGVERSION
- bs[stringlength(bs)+1] = 0;
- #endif
+
+ #ifdef PASCALSTRINGVERSION
+ bs[stringlength(bs)+1] = 0;
+
+ #endif
+
releasethreadglobals ();
-
- SetWindowText(w, stringbaseaddress(bs));
-
+
+ SetWindowText ( w, *h );
+
grabthreadglobals ();
+
#endif
+
} /*windowsettitle*/
void windowinval (WindowPtr w) {
+
+ Rect r;
- Rect r;
-
getlocalwindowrect (w, &r);
-
+
invalwindowrect (w, r);
-
- /*
- #ifdef MACVERSION
- invalwindowrect (w, (*w).portRect);
- #endif
- #ifdef WIN95VERSION
- releasethreadglobals ();
-
- ShowWindow (w, SW_SHOWNA);
-
- grabthreadglobals ();
-
- #endif
- */
} /*windowinval*/
@@ -314,6 +320,7 @@
popport ();
return (true);
+
} /*graywindow*/
#endif
@@ -405,6 +412,7 @@
sizewindow (w, r.right - r.left, r.bottom - r.top);
movewindow (w, r.left, r.top);
+
} /*moveandsizewindow*/
@@ -475,6 +483,7 @@
shellwindowmenudirty (); /*the checked item changes*/
return (true);
+
} /*windowbringtofront*/
@@ -501,6 +510,7 @@
shellwindowmenudirty (); /*the checked item changes*/
return (true);
+
} /*windowsendtoback*/
@@ -545,6 +555,7 @@
#endif
return (true);
+
} /*getlocalwindowrect*/
@@ -572,6 +583,7 @@
#endif
return (true);
+
} /*getglobalwindowrect*/
@@ -616,6 +628,7 @@
shellwindowmenudirty (); /*the checked item changes*/
return (true);
+
} /*windowsendbehind*/
@@ -633,6 +646,7 @@
#endif
return (*w != nil);
+
} /*findmousewindow*/
@@ -666,6 +680,7 @@
#endif
return (true);
+
} /*windowsetcolor**/
@@ -683,6 +698,7 @@
#ifdef WIN95VERSION
return (false);
#endif
+
} /*isdeskaccessorywindow*/
#endif
@@ -701,6 +717,7 @@
grabthreadglobals ();
#endif
+
} /*showwindow*/
@@ -751,6 +768,7 @@
grabthreadglobals ();
#endif
+
} /*hidewindow*/
boolean windowvisible (WindowPtr w) {
@@ -766,6 +784,7 @@
#ifdef WIN95VERSION
return (IsWindowVisible (w));
#endif
+
} /*windowvisible*/
@@ -798,6 +817,7 @@
GetUpdateRgn (w, (HRGN) rgn, false);
return (rgn);
#endif
+
} /*getupdateregion*/
@@ -837,6 +857,7 @@
// ReleaseDC(w, hdc);
return (rgn);
#endif
+
} /*getupdateregion*/
@@ -853,6 +874,7 @@
#ifdef WIN95VERSION
SetWindowLong (w, 0, (LONG) refcon);
#endif
+
} /*setwindowrefcon*/
@@ -869,7 +891,6 @@
#ifdef WIN95VERSION
return (GetWindowLong (w, 0));
#endif
+
} /*getwindowrefcon*/
-
-
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|