|
From: <cre...@us...> - 2006-08-25 23:31:21
|
Revision: 1483 Author: creecode Date: 2006-08-25 16:31:17 -0700 (Fri, 25 Aug 2006) ViewCVS: http://svn.sourceforge.net/frontierkernel/?rev=1483&view=rev Log Message: ----------- in function getspecialfolderpath use FSFindFolder in getfileparentfolder function, deal better with tyfilespec that may point to no longer existing file objects Modified Paths: -------------- Frontier/branches/FSRef_Migration/Common/source/fileops.c Modified: Frontier/branches/FSRef_Migration/Common/source/fileops.c =================================================================== --- Frontier/branches/FSRef_Migration/Common/source/fileops.c 2006-08-19 18:39:05 UTC (rev 1482) +++ Frontier/branches/FSRef_Migration/Common/source/fileops.c 2006-08-25 23:31:17 UTC (rev 1483) @@ -1953,11 +1953,13 @@ boolean getspecialfolderpath ( bigstring bsvol, bigstring bsfolder, boolean flcreate, ptrfilespec fs ) { // - // 2006-06-17 creedon: for Mac, FSRef-ized + // 2006-08-24 creedon: for Mac, FSRef-ized // // 2006-04-11 creedon: windows now honors flcreate + // // for windows added; CSIDL_PROGRAM_FILES, CSIDL_MYDOCUMENTS, CSIDL_MYMUSIC, - // CSIDL_MYPICTURES, CSIDL_MYVIDEO; + // CSIDL_MYPICTURES, CSIDL_MYVIDEO + // // for windows replaced more complex code with CSIDL_SYSTEM, CSIDL_WINDOWS // // 1992-09-01 dmb: last new verb for 2.0. (?) @@ -1967,7 +1969,6 @@ short vnum; short ixlist; - long dirid; OSType foldertype; long attrs; OSErr err = errorNone; @@ -2007,20 +2008,16 @@ err = dirNFErr; } - if (err == noErr) - err = FindFolder (vnum, foldertype, flcreate, &vnum, &dirid); + if ( err == noErr ) { + + err = FSFindFolder ( vnum, foldertype, flcreate, &( *fs ).fsref ); - - if (err == noErr) { - - err = FSMakeFSRef ( vnum, dirid, nil, &( *fs ).fsref ); - getfilespecparent ( fs ); } - - return (!oserror (err)); + return ( ! oserror ( err ) ); + #endif #ifdef WIN95VERSION @@ -3021,11 +3018,31 @@ boolean getfileparentfolder ( const ptrfilespec fs, ptrfilespec fsparent ) { // - // 2006-06-18 creedon: FSRef-ized + // 2006-08-24 creedon: FSRef-ized // - return ( ! oserror ( FSGetCatalogInfo ( &( *fs ).fsref, kFSCatInfoNone, NULL, NULL, NULL, &( *fsparent ).fsref ) ) ); + // this function used to use oserror but I don't think oserror can handle osstatus properly + HFSUniStr255 name; + OSStatus status; + + status = FSGetCatalogInfo ( &( *fs ).fsref, kFSCatInfoNone, NULL, &name, NULL, &( *fsparent ).fsref ); + + if ( status != noErr ) + return ( false ); + + if ( ( *fs ).path == NULL ) { + + status = FSGetCatalogInfo ( &( *fsparent ).fsref, kFSCatInfoNone, NULL, &name, NULL, &( *fsparent ).fsref ); + + if ( status != noErr ) + return ( false ); + } + + ( *fsparent ).path = CFStringCreateWithCharacters ( kCFAllocatorDefault, name.unicode, name.length ); + + return ( true ); + } // getfileparentfolder This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |