|
From: <cre...@us...> - 2006-07-08 00:57:30
|
Revision: 1449 Author: creecode Date: 2006-07-07 17:57:27 -0700 (Fri, 07 Jul 2006) ViewCVS: http://svn.sourceforge.net/frontierkernel/?rev=1449&view=rev Log Message: ----------- minor code formatting tweaks in setfserrorparam function on Mac check that FSRef is valid before trying to set bs on Mac in filegetinfo function remove extraneous call to setfserrorparam, also check that FSRef is valid before getting info 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-07-08 00:48:38 UTC (rev 1448) +++ Frontier/branches/FSRef_Migration/Common/source/fileops.c 2006-07-08 00:57:27 UTC (rev 1449) @@ -132,7 +132,7 @@ void setfserrorparam ( const tyfilespec *fs ) { // - // 2006-06-25 creedon; for Mac, FSRef-ized + // 2006-07-05 creedon; for Mac, FSRef-ized // #ifdef MACVERSION @@ -140,9 +140,10 @@ bigstring bs; if ( ( *fs ).path != NULL ) - CFStringToStr255 ( ( *fs ).path, bs ); + CFStringRefToStr255 ( ( *fs ).path, bs ); else - FSRefGetNameStr255 ( &( *fs ).fsref, bs ); + if ( FSRefValid ( &( *fs ).fsref ) ) + FSRefGetNameStr255 ( &( *fs ).fsref, bs ); setoserrorparam ( bs ); @@ -154,7 +155,7 @@ #endif - } /* setfserrorparam */ + } // setfserrorparam boolean endswithpathsep (bigstring bs) { @@ -253,11 +254,9 @@ 4/26/96 dmb: use mask, not BitTst (a toolbox call) */ - /* - return (BitTst (&pb->dirInfo.ioFlAttrib, 3)); - */ - return ((pb->dirInfo.ioFlAttrib & ioDirMask) != 0); - } /*foldertest*/ + return ( ( pb -> dirInfo.ioFlAttrib & kioFlAttribDirMask ) != 0 ); + + } // foldertest /* @@ -520,8 +519,8 @@ ( *info ).vnum = ( *( *pb ).catInfo ).volume; - if ( ( *info ).dirid == fsRtParID) - filegetvolumeinfo (( *info ).vnum, info); + if ( ( *info ).dirid == fsRtParID ) + filegetvolumeinfo ( ( *info ).vnum, info ); else ( *info ).flvolume = false; @@ -854,7 +853,7 @@ #endif -boolean filegetinfo (const ptrfilespec fs, tyfileinfo *info) { +boolean filegetinfo ( const ptrfilespec fs, tyfileinfo *info ) { // // 2006-06-25 creedon: for Mac, FSRef-ized @@ -864,26 +863,22 @@ #ifdef MACVERSION - setfserrorparam ( fs ); + setfserrorparam ( fs ); // in case error message takes a filename parameter if ( ( *fs ).path != NULL ) return ( ! oserror ( fnfErr ) ); + if ( ! FSRefValid ( &( *fs ).fsref ) ) + return ( false ); + FSCatalogInfo catinfo; FSRefParam pb; OSErr err; clearbytes ( &pb, sizeof ( pb ) ); - setfserrorparam ( fs ); // in case error message takes a filename parameter - pb.catInfo = &catinfo; - /* - pb.outName = NULL; - pb.parentRef = NULL; - */ - pb.ref = &( *fs ).fsref; - // pb.spec = NULL; + pb.ref = &( *fs ).fsref; pb.whichInfo = kFSCatInfoGettableInfo; err = PBGetCatalogInfoSync ( &pb ); @@ -891,22 +886,10 @@ if ( oserror ( err ) ) return ( false ); - /* - if (isvolumefilespec (pfs)) { - - return (filegetfsvolumeinfo (pfs, info)); - } - */ + filegetinfofrompb ( &pb, info ); - /* - if (!getmacfileinfo (fs, &pb)) - return (false); - */ + #endif // MACVERSION - filegetinfofrompb (&pb, info); - - #endif - #ifdef WIN95VERSION HANDLE findHandle; @@ -914,7 +897,7 @@ WIN32_FIND_DATA fileinfo; char fn[300]; - clearbytes (info, sizeof (tyfileinfo)); /*init all fields to zero*/ + clearbytes (info, sizeof (tyfileinfo)); // init all fields to zero info->filecreator = ' '; info->filetype = ' '; @@ -924,7 +907,7 @@ copystring (fsname (fs), fn); - /*if ends with \ get ride of it... and handle the root*/ + // if ends with \ get ride of it... and handle the root cleanendoffilename (fn); @@ -944,7 +927,8 @@ FindClose(findHandle); - //Set the file busy flag (this should be in winsetfileinfo, but we do not have the filename there) + // Set the file busy flag (this should be in winsetfileinfo, but we do not have the filename there) + if (info->flfolder) { strcat (stringbaseaddress (fn), "\\*"); @@ -953,15 +937,15 @@ findHandle = FindFirstFile (stringbaseaddress(fn), &fileinfo); if (findHandle != INVALID_HANDLE_VALUE) { - info->flbusy = true; //Found something + info->flbusy = true; // Found something while ((strcmp (fileinfo.cFileName, ".") == 0) || (strcmp (fileinfo.cFileName, "..") == 0)) { info->flbusy = false; // Just . or .. if (FindNextFile (findHandle, &fileinfo)) - info->flbusy = true; //Found something else... + info->flbusy = true; // Found something else... else - break; //exit while loop if FindNext fails (this is normal) + break; // exit while loop if FindNext fails (this is normal) } FindClose (findHandle); @@ -980,9 +964,10 @@ } } - #endif + #endif // WIN95VERSION return (true); + } // filegetinfo @@ -1844,7 +1829,7 @@ return ( false ); if ( oserror ( FSCopyObject ( &( *fsource ).fsref, &( *fdest ).fsref, 0, kFSCatInfoNone, kDupeActionReplace, &name, - FALSE, FALSE, NULL, NULL, NULL, NULL ) ) ) + false, false, NULL, NULL, NULL, NULL ) ) ) return ( false ); return ( true ); // the file copy was successful @@ -2958,7 +2943,7 @@ setfserrorparam ( fs ); - return ( ! oserror ( FSResolveAliasFile ( &( *fs ).fsref, TRUE, &flfolder, &flalias ) ) ); + return ( ! oserror ( FSResolveAliasFile ( &( *fs ).fsref, true, &flfolder, &flalias ) ) ); } // fileresolvealias @@ -3654,8 +3639,6 @@ *fsout = fst; - // ( *fsin ).path = NULL; - #endif // MACVERSION return ( true ); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |