[futurebasic] Re: [FB] Make file invisible & force finder update

Message: < previous - next > : Reply : Subscribe : Cleanse
Home   : November 2007 : Group Archive : Group : All Groups

From: Brian Stevens <bstevens33@...>
Date: Fri, 23 Nov 2007 09:28:07 -0700
Bernie,

I recently built two quick utilities to hide/show all files in the  
finder. They are just wrappers for shell scripts that do:

defaults write com.apple.finder AppleShowAllFiles ON

defaults write com.apple.finder AppleShowAllFiles OFF

What I noticed is all the invisible files shown have this ghost  
appearance.  I can send these utils backchannel if you'd like to  
experiment with them.

Brian



On Nov 23, 2007, at 7:38 AM, Bernie wrote:

>
> I've combined a couple RP demos to make a file invisible then force  
> a finder update. The problem I'm having is the icon doesn't vanish  
> but instead turns into a sort of ghost of itself and only  
> disappears after switching directory views or opening/closing the  
> directory. Anyone know how to make it vanish toute suite?
>
> Bernie
>
>
> '------------ example ------------
> include "Tlbx MoreFilesX.incl"
>
> _kAEFinderSuite = _"fndr"
> _kAESync = _"fupd"
>
> local mode
> local fn FSpSendSyncAppleEventToFinder( f as ^FSSpec )
> '~'1
> dim as AEDesc addrDesc, theAE
> dim as OSType @ creator
> dim as OSErr err, ignore
>
> creator = _"MACS"
> err = fn AECreateDesc( _typeApplSignature, @creator, sizeof 
> ( OSType ), @addrDesc )
> if ( err ) then exit fn
> err = fn AECreateAppleEvent( _kAEFinderSuite, _kAESync, addrDesc,  
> _kAutoGenerateReturnID, _kAnyTransactionID, @theAE )
> ignore = fn AEDisposeDesc( addrDesc )
> if ( err ) then exit fn
> err = fn AECreateDesc( _typeFSS, #f, sizeof( FSSpec ), @addrDesc )
> long if ( err == _noErr )
> err = fn AEPutParamDesc( theAE, _keyDirectObject, addrDesc )
> ignore = fn AEDisposeDesc( addrDesc )
> end if
> if ( err == _noErr ) then err = fn AESend( theAE, #0, _kAENoReply,  
> _kAENormalPriority, _kAEDefaultTimeout, 0, 0 )
> ignore = fn AEDisposeDesc( theAE )
> end fn = err
>
>
> // adapted from MoreFilesX
> local mode
> local fn FSpBumpDate( f as ^FSSpec )
> '~'1
> dim as FSRef ref
> dim as OSStatus result, ignore
> dim as FSCatalogInfo catalogInfo
> dim as UTCDateTime oldDateTime
>
> result = fn FSpMakeFSRef( #f, @ref )
> if ( result ) then exit fn
>
> /* Get the content modification date and time */
> result = fn FSGetCatalogInfo( #ref, _kFSCatInfoContentMod,  
> @catalogInfo, #0, #0, #0 )
> if ( result ) then exit fn
> oldDateTime = catalogInfo.contentModDate
>
> /* Get the current date and time */
> result = fn GetUTCDateTime( @catalogInfo.contentModDate,  
> _kUTCDefaultOptions )
> if ( result ) then exit fn
>
> /* if the old date and time is the same as the current, bump the  
> seconds by one */
> long if ( (catalogInfo.contentModDate.fraction ==  
> oldDateTime.fraction) and ¬
> (catalogInfo.contentModDate.lowSeconds == oldDateTime.lowSeconds)  
> and ¬
> (catalogInfo.contentModDate.highSeconds == oldDateTime.highSeconds) )
> catalogInfo.contentModDate.lowSeconds++
> if ( 0 == catalogInfo.contentModDate.lowSeconds ) then  
> catalogInfo.contentModDate.highSeconds++
> end if
>
> /* Bump the content modification date and time */
> ignore = fn FSSetCatalogInfo( @ref, _kFSCatInfoContentMod,  
> @catalogInfo )
> /* ignore errors from FSSetCatalogInfo (volume might be write  
> protected) */
> end fn = result
>
>
> local mode
> local fn FSpForceFinderToUpdateFile( f as ^FSSpec )
> '~'1
> if ( _noErr == fn FSpBumpDate( f ) ) then fn  
> FSpSendSyncAppleEventToFinder( f )
> end fn
>
>
> local mode
> local fn FSpHideShowObject( hide as Boolean, f as ^FSSpec )
> '~'1
> dim as FSRef ref
> dim as FSCatalogInfo info
> dim as OSErr err
> dim as Boolean needChange
>
> if ( f == 0 ) then err = _paramErr : exit fn
> err = fn FSpMakeFSRef( #f, @ref )
> if ( err ) then exit fn
> err = fn FSGetCatalogInfo( ref, _kFSCatInfoFinderInfo, @info, #0,  
> #0, #0 )
> if ( err ) then exit fn
> long if ( hide )// make invisible
> needChange = ( (info.finderInfo.file.finderFlags and _kIsInvisible)  
> == 0 )
> info.finderInfo.file.finderFlags = info.finderInfo.file.finderFlags  
> or _kIsInvisible
> xelse// make visible
> needChange = ( (info.finderInfo.file.finderFlags and  
> _kIsInvisible) != 0 )
> info.finderInfo.file.finderFlags = info.finderInfo.file.finderFlags  
> and not( _kIsInvisible )
> end if
> if ( needChange ) then err = fn FSSetCatalogInfo( ref,  
> _kFSCatInfoFinderInfo, info )
> end fn = err
>
>
> dim as FSSpec spec
>
> long if ( files$( _FSSpecOpen,,, spec ) )
>
> fn FSpHideShowObject( _zTrue, @spec )
> fn FSpForceFinderToUpdateFile( @spec )
>
> delay 2000
>
> fn FSpHideShowObject( _false, @spec )
> fn FSpForceFinderToUpdateFile( @spec )
>
> end if
> '------------
>
> --
> To unsubscribe, send ANY message to: futurebasic- 
> unsubscribe@...
>

Brian S.